babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vector3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Gets the list of observers
  4360. */
  4361. readonly observers: Array<Observer<T>>;
  4362. /**
  4363. * Creates a new observable
  4364. * @param onObserverAdded defines a callback to call when a new observer is added
  4365. */
  4366. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4367. /**
  4368. * Create a new Observer with the specified callback
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @param mask the mask used to filter observers
  4371. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4372. * @param scope optional scope for the callback to be called from
  4373. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4374. * @returns the new observer created for the callback
  4375. */
  4376. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4377. /**
  4378. * Create a new Observer with the specified callback and unregisters after the next notification
  4379. * @param callback the callback that will be executed for that Observer
  4380. * @returns the new observer created for the callback
  4381. */
  4382. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4383. /**
  4384. * Remove an Observer from the Observable object
  4385. * @param observer the instance of the Observer to remove
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. remove(observer: Nullable<Observer<T>>): boolean;
  4389. /**
  4390. * Remove a callback from the Observable object
  4391. * @param callback the callback to remove
  4392. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4393. * @returns false if it doesn't belong to this Observable
  4394. */
  4395. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4396. private _deferUnregister;
  4397. private _remove;
  4398. /**
  4399. * Moves the observable to the top of the observer list making it get called first when notified
  4400. * @param observer the observer to move
  4401. */
  4402. makeObserverTopPriority(observer: Observer<T>): void;
  4403. /**
  4404. * Moves the observable to the bottom of the observer list making it get called last when notified
  4405. * @param observer the observer to move
  4406. */
  4407. makeObserverBottomPriority(observer: Observer<T>): void;
  4408. /**
  4409. * Notify all Observers by calling their respective callback with the given data
  4410. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4411. * @param eventData defines the data to send to all observers
  4412. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4413. * @param target defines the original target of the state
  4414. * @param currentTarget defines the current target of the state
  4415. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4416. */
  4417. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4418. /**
  4419. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4420. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4421. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4422. * and it is crucial that all callbacks will be executed.
  4423. * The order of the callbacks is kept, callbacks are not executed parallel.
  4424. *
  4425. * @param eventData The data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. * @param target defines the callback target (see EventState)
  4428. * @param currentTarget defines he current object in the bubbling phase
  4429. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4430. */
  4431. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4432. /**
  4433. * Notify a specific observer
  4434. * @param observer defines the observer to notify
  4435. * @param eventData defines the data to be sent to each callback
  4436. * @param mask is used to filter observers defaults to -1
  4437. */
  4438. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4439. /**
  4440. * Gets a boolean indicating if the observable has at least one observer
  4441. * @returns true is the Observable has at least one Observer registered
  4442. */
  4443. hasObservers(): boolean;
  4444. /**
  4445. * Clear the list of observers
  4446. */
  4447. clear(): void;
  4448. /**
  4449. * Clone the current observable
  4450. * @returns a new observable
  4451. */
  4452. clone(): Observable<T>;
  4453. /**
  4454. * Does this observable handles observer registered with a given mask
  4455. * @param mask defines the mask to be tested
  4456. * @return whether or not one observer registered with the given mask is handeled
  4457. **/
  4458. hasSpecificMask(mask?: number): boolean;
  4459. }
  4460. }
  4461. declare module "babylonjs/Misc/filesInputStore" {
  4462. /**
  4463. * Class used to help managing file picking and drag'n'drop
  4464. * File Storage
  4465. */
  4466. export class FilesInputStore {
  4467. /**
  4468. * List of files ready to be loaded
  4469. */
  4470. static FilesToLoad: {
  4471. [key: string]: File;
  4472. };
  4473. }
  4474. }
  4475. declare module "babylonjs/Engines/constants" {
  4476. /** Defines the cross module used constants to avoid circular dependncies */
  4477. export class Constants {
  4478. /** Defines that alpha blending is disabled */
  4479. static readonly ALPHA_DISABLE: number;
  4480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4481. static readonly ALPHA_ADD: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_COMBINE: number;
  4484. /** Defines that alpha blending to DEST - SRC * DEST */
  4485. static readonly ALPHA_SUBTRACT: number;
  4486. /** Defines that alpha blending to SRC * DEST */
  4487. static readonly ALPHA_MULTIPLY: number;
  4488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4489. static readonly ALPHA_MAXIMIZED: number;
  4490. /** Defines that alpha blending to SRC + DEST */
  4491. static readonly ALPHA_ONEONE: number;
  4492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4493. static readonly ALPHA_PREMULTIPLIED: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4500. static readonly ALPHA_INTERPOLATE: number;
  4501. /**
  4502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4504. */
  4505. static readonly ALPHA_SCREENMODE: number;
  4506. /** Defines that the ressource is not delayed*/
  4507. static readonly DELAYLOADSTATE_NONE: number;
  4508. /** Defines that the ressource was successfully delay loaded */
  4509. static readonly DELAYLOADSTATE_LOADED: number;
  4510. /** Defines that the ressource is currently delay loading */
  4511. static readonly DELAYLOADSTATE_LOADING: number;
  4512. /** Defines that the ressource is delayed and has not started loading */
  4513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4515. static readonly NEVER: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4517. static readonly ALWAYS: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4519. static readonly LESS: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4521. static readonly EQUAL: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4523. static readonly LEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4525. static readonly GREATER: number;
  4526. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4527. static readonly GEQUAL: number;
  4528. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4529. static readonly NOTEQUAL: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be kept */
  4531. static readonly KEEP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4533. static readonly REPLACE: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4535. static readonly INCR: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4537. static readonly DECR: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4539. static readonly INVERT: number;
  4540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4541. static readonly INCR_WRAP: number;
  4542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4543. static readonly DECR_WRAP: number;
  4544. /** Texture is not repeating outside of 0..1 UVs */
  4545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4546. /** Texture is repeating outside of 0..1 UVs */
  4547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4548. /** Texture is repeating and mirrored */
  4549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4550. /** ALPHA */
  4551. static readonly TEXTUREFORMAT_ALPHA: number;
  4552. /** LUMINANCE */
  4553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4554. /** LUMINANCE_ALPHA */
  4555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4556. /** RGB */
  4557. static readonly TEXTUREFORMAT_RGB: number;
  4558. /** RGBA */
  4559. static readonly TEXTUREFORMAT_RGBA: number;
  4560. /** RED */
  4561. static readonly TEXTUREFORMAT_RED: number;
  4562. /** RED (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R: number;
  4564. /** RG */
  4565. static readonly TEXTUREFORMAT_RG: number;
  4566. /** RED_INTEGER */
  4567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4568. /** RED_INTEGER (2nd reference) */
  4569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4570. /** RG_INTEGER */
  4571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4572. /** RGB_INTEGER */
  4573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4574. /** RGBA_INTEGER */
  4575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4576. /** UNSIGNED_BYTE */
  4577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4578. /** UNSIGNED_BYTE (2nd reference) */
  4579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4580. /** FLOAT */
  4581. static readonly TEXTURETYPE_FLOAT: number;
  4582. /** HALF_FLOAT */
  4583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4584. /** BYTE */
  4585. static readonly TEXTURETYPE_BYTE: number;
  4586. /** SHORT */
  4587. static readonly TEXTURETYPE_SHORT: number;
  4588. /** UNSIGNED_SHORT */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4590. /** INT */
  4591. static readonly TEXTURETYPE_INT: number;
  4592. /** UNSIGNED_INT */
  4593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4594. /** UNSIGNED_SHORT_4_4_4_4 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4596. /** UNSIGNED_SHORT_5_5_5_1 */
  4597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4598. /** UNSIGNED_SHORT_5_6_5 */
  4599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4600. /** UNSIGNED_INT_2_10_10_10_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4602. /** UNSIGNED_INT_24_8 */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4604. /** UNSIGNED_INT_10F_11F_11F_REV */
  4605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4606. /** UNSIGNED_INT_5_9_9_9_REV */
  4607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4616. /** nearest is mag = nearest and min = nearest and mip = linear */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4620. /** Trilinear is mag = linear and min = linear and mip = linear */
  4621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4624. /** mag = nearest and min = linear and mip = nearest */
  4625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4626. /** mag = nearest and min = linear and mip = linear */
  4627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4628. /** mag = nearest and min = linear and mip = none */
  4629. static readonly TEXTURE_NEAREST_LINEAR: number;
  4630. /** mag = nearest and min = nearest and mip = none */
  4631. static readonly TEXTURE_NEAREST_NEAREST: number;
  4632. /** mag = linear and min = nearest and mip = nearest */
  4633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4634. /** mag = linear and min = nearest and mip = linear */
  4635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4636. /** mag = linear and min = linear and mip = none */
  4637. static readonly TEXTURE_LINEAR_LINEAR: number;
  4638. /** mag = linear and min = nearest and mip = none */
  4639. static readonly TEXTURE_LINEAR_NEAREST: number;
  4640. /** Explicit coordinates mode */
  4641. static readonly TEXTURE_EXPLICIT_MODE: number;
  4642. /** Spherical coordinates mode */
  4643. static readonly TEXTURE_SPHERICAL_MODE: number;
  4644. /** Planar coordinates mode */
  4645. static readonly TEXTURE_PLANAR_MODE: number;
  4646. /** Cubic coordinates mode */
  4647. static readonly TEXTURE_CUBIC_MODE: number;
  4648. /** Projection coordinates mode */
  4649. static readonly TEXTURE_PROJECTION_MODE: number;
  4650. /** Skybox coordinates mode */
  4651. static readonly TEXTURE_SKYBOX_MODE: number;
  4652. /** Inverse Cubic coordinates mode */
  4653. static readonly TEXTURE_INVCUBIC_MODE: number;
  4654. /** Equirectangular coordinates mode */
  4655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4656. /** Equirectangular Fixed coordinates mode */
  4657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4658. /** Equirectangular Fixed Mirrored coordinates mode */
  4659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4661. static readonly SCALEMODE_FLOOR: number;
  4662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4663. static readonly SCALEMODE_NEAREST: number;
  4664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4665. static readonly SCALEMODE_CEILING: number;
  4666. /**
  4667. * The dirty texture flag value
  4668. */
  4669. static readonly MATERIAL_TextureDirtyFlag: number;
  4670. /**
  4671. * The dirty light flag value
  4672. */
  4673. static readonly MATERIAL_LightDirtyFlag: number;
  4674. /**
  4675. * The dirty fresnel flag value
  4676. */
  4677. static readonly MATERIAL_FresnelDirtyFlag: number;
  4678. /**
  4679. * The dirty attribute flag value
  4680. */
  4681. static readonly MATERIAL_AttributesDirtyFlag: number;
  4682. /**
  4683. * The dirty misc flag value
  4684. */
  4685. static readonly MATERIAL_MiscDirtyFlag: number;
  4686. /**
  4687. * The all dirty flag value
  4688. */
  4689. static readonly MATERIAL_AllDirtyFlag: number;
  4690. /**
  4691. * Returns the triangle fill mode
  4692. */
  4693. static readonly MATERIAL_TriangleFillMode: number;
  4694. /**
  4695. * Returns the wireframe mode
  4696. */
  4697. static readonly MATERIAL_WireFrameFillMode: number;
  4698. /**
  4699. * Returns the point fill mode
  4700. */
  4701. static readonly MATERIAL_PointFillMode: number;
  4702. /**
  4703. * Returns the point list draw mode
  4704. */
  4705. static readonly MATERIAL_PointListDrawMode: number;
  4706. /**
  4707. * Returns the line list draw mode
  4708. */
  4709. static readonly MATERIAL_LineListDrawMode: number;
  4710. /**
  4711. * Returns the line loop draw mode
  4712. */
  4713. static readonly MATERIAL_LineLoopDrawMode: number;
  4714. /**
  4715. * Returns the line strip draw mode
  4716. */
  4717. static readonly MATERIAL_LineStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle strip draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleStripDrawMode: number;
  4722. /**
  4723. * Returns the triangle fan draw mode
  4724. */
  4725. static readonly MATERIAL_TriangleFanDrawMode: number;
  4726. /**
  4727. * Stores the clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4730. /**
  4731. * Stores the counter clock-wise side orientation
  4732. */
  4733. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4734. /**
  4735. * Nothing
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_NothingTrigger: number;
  4739. /**
  4740. * On pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickTrigger: number;
  4744. /**
  4745. * On left pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLeftPickTrigger: number;
  4749. /**
  4750. * On right pick
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnRightPickTrigger: number;
  4754. /**
  4755. * On center pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnCenterPickTrigger: number;
  4759. /**
  4760. * On pick down
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickDownTrigger: number;
  4764. /**
  4765. * On double pick
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnDoublePickTrigger: number;
  4769. /**
  4770. * On pick up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickUpTrigger: number;
  4774. /**
  4775. * On pick out.
  4776. * This trigger will only be raised if you also declared a OnPickDown
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPickOutTrigger: number;
  4780. /**
  4781. * On long press
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnLongPressTrigger: number;
  4785. /**
  4786. * On pointer over
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnPointerOverTrigger: number;
  4790. /**
  4791. * On pointer out
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnPointerOutTrigger: number;
  4795. /**
  4796. * On every frame
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnEveryFrameTrigger: number;
  4800. /**
  4801. * On intersection enter
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4805. /**
  4806. * On intersection exit
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnIntersectionExitTrigger: number;
  4810. /**
  4811. * On key down
  4812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4813. */
  4814. static readonly ACTION_OnKeyDownTrigger: number;
  4815. /**
  4816. * On key up
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4818. */
  4819. static readonly ACTION_OnKeyUpTrigger: number;
  4820. /**
  4821. * Billboard mode will only apply to Y axis
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4824. /**
  4825. * Billboard mode will apply to all axes
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4828. /**
  4829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4830. */
  4831. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4832. /**
  4833. * Gets or sets base Assets URL
  4834. */
  4835. static PARTICLES_BaseAssetsUrl: string;
  4836. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4837. * Test order :
  4838. * Is the bounding sphere outside the frustum ?
  4839. * If not, are the bounding box vertices outside the frustum ?
  4840. * It not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4843. /** Culling strategy : Bounding Sphere Only.
  4844. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4845. * It's also less accurate than the standard because some not visible objects can still be selected.
  4846. * Test : is the bounding sphere outside the frustum ?
  4847. * If not, then the cullable object is in the frustum.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4850. /** Culling strategy : Optimistic Inclusion.
  4851. * This in an inclusion test first, then the standard exclusion test.
  4852. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4853. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4854. * Anyway, it's as accurate as the standard strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the default culling strategy.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4860. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4861. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4862. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4863. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4864. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4865. * Test :
  4866. * Is the cullable object bounding sphere center in the frustum ?
  4867. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4868. */
  4869. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4870. /**
  4871. * No logging while loading
  4872. */
  4873. static readonly SCENELOADER_NO_LOGGING: number;
  4874. /**
  4875. * Minimal logging while loading
  4876. */
  4877. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4878. /**
  4879. * Summary logging while loading
  4880. */
  4881. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4882. /**
  4883. * Detailled logging while loading
  4884. */
  4885. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4886. }
  4887. }
  4888. declare module "babylonjs/Misc/domManagement" {
  4889. /**
  4890. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4891. * Babylon.js
  4892. */
  4893. export class DomManagement {
  4894. /**
  4895. * Checks if the window object exists
  4896. * @returns true if the window object exists
  4897. */
  4898. static IsWindowObjectExist(): boolean;
  4899. /**
  4900. * Extracts text content from a DOM element hierarchy
  4901. * @param element defines the root element
  4902. * @returns a string
  4903. */
  4904. static GetDOMTextContent(element: HTMLElement): string;
  4905. }
  4906. }
  4907. declare module "babylonjs/Misc/logger" {
  4908. /**
  4909. * Logger used througouht the application to allow configuration of
  4910. * the log level required for the messages.
  4911. */
  4912. export class Logger {
  4913. /**
  4914. * No log
  4915. */
  4916. static readonly NoneLogLevel: number;
  4917. /**
  4918. * Only message logs
  4919. */
  4920. static readonly MessageLogLevel: number;
  4921. /**
  4922. * Only warning logs
  4923. */
  4924. static readonly WarningLogLevel: number;
  4925. /**
  4926. * Only error logs
  4927. */
  4928. static readonly ErrorLogLevel: number;
  4929. /**
  4930. * All logs
  4931. */
  4932. static readonly AllLogLevel: number;
  4933. private static _LogCache;
  4934. /**
  4935. * Gets a value indicating the number of loading errors
  4936. * @ignorenaming
  4937. */
  4938. static errorsCount: number;
  4939. /**
  4940. * Callback called when a new log is added
  4941. */
  4942. static OnNewCacheEntry: (entry: string) => void;
  4943. private static _AddLogEntry;
  4944. private static _FormatMessage;
  4945. private static _LogDisabled;
  4946. private static _LogEnabled;
  4947. private static _WarnDisabled;
  4948. private static _WarnEnabled;
  4949. private static _ErrorDisabled;
  4950. private static _ErrorEnabled;
  4951. /**
  4952. * Log a message to the console
  4953. */
  4954. static Log: (message: string) => void;
  4955. /**
  4956. * Write a warning message to the console
  4957. */
  4958. static Warn: (message: string) => void;
  4959. /**
  4960. * Write an error message to the console
  4961. */
  4962. static Error: (message: string) => void;
  4963. /**
  4964. * Gets current log cache (list of logs)
  4965. */
  4966. static readonly LogCache: string;
  4967. /**
  4968. * Clears the log cache
  4969. */
  4970. static ClearLogCache(): void;
  4971. /**
  4972. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4973. */
  4974. static LogLevels: number;
  4975. }
  4976. }
  4977. declare module "babylonjs/Misc/typeStore" {
  4978. /** @hidden */
  4979. export class _TypeStore {
  4980. /** @hidden */
  4981. static RegisteredTypes: {
  4982. [key: string]: Object;
  4983. };
  4984. /** @hidden */
  4985. static GetClass(fqdn: string): any;
  4986. }
  4987. }
  4988. declare module "babylonjs/Misc/deepCopier" {
  4989. /**
  4990. * Class containing a set of static utilities functions for deep copy.
  4991. */
  4992. export class DeepCopier {
  4993. /**
  4994. * Tries to copy an object by duplicating every property
  4995. * @param source defines the source object
  4996. * @param destination defines the target object
  4997. * @param doNotCopyList defines a list of properties to avoid
  4998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4999. */
  5000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5001. }
  5002. }
  5003. declare module "babylonjs/Misc/precisionDate" {
  5004. /**
  5005. * Class containing a set of static utilities functions for precision date
  5006. */
  5007. export class PrecisionDate {
  5008. /**
  5009. * Gets either window.performance.now() if supported or Date.now() else
  5010. */
  5011. static readonly Now: number;
  5012. }
  5013. }
  5014. declare module "babylonjs/Misc/devTools" {
  5015. /** @hidden */
  5016. export class _DevTools {
  5017. static WarnImport(name: string): string;
  5018. }
  5019. }
  5020. declare module "babylonjs/Misc/webRequest" {
  5021. /**
  5022. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5023. */
  5024. export class WebRequest {
  5025. private _xhr;
  5026. /**
  5027. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5028. * i.e. when loading files, where the server/service expects an Authorization header
  5029. */
  5030. static CustomRequestHeaders: {
  5031. [key: string]: string;
  5032. };
  5033. /**
  5034. * Add callback functions in this array to update all the requests before they get sent to the network
  5035. */
  5036. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5037. private _injectCustomRequestHeaders;
  5038. /**
  5039. * Gets or sets a function to be called when loading progress changes
  5040. */
  5041. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5042. /**
  5043. * Returns client's state
  5044. */
  5045. readonly readyState: number;
  5046. /**
  5047. * Returns client's status
  5048. */
  5049. readonly status: number;
  5050. /**
  5051. * Returns client's status as a text
  5052. */
  5053. readonly statusText: string;
  5054. /**
  5055. * Returns client's response
  5056. */
  5057. readonly response: any;
  5058. /**
  5059. * Returns client's response url
  5060. */
  5061. readonly responseURL: string;
  5062. /**
  5063. * Returns client's response as text
  5064. */
  5065. readonly responseText: string;
  5066. /**
  5067. * Gets or sets the expected response type
  5068. */
  5069. responseType: XMLHttpRequestResponseType;
  5070. /** @hidden */
  5071. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5072. /** @hidden */
  5073. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5074. /**
  5075. * Cancels any network activity
  5076. */
  5077. abort(): void;
  5078. /**
  5079. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5080. * @param body defines an optional request body
  5081. */
  5082. send(body?: Document | BodyInit | null): void;
  5083. /**
  5084. * Sets the request method, request URL
  5085. * @param method defines the method to use (GET, POST, etc..)
  5086. * @param url defines the url to connect with
  5087. */
  5088. open(method: string, url: string): void;
  5089. }
  5090. }
  5091. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5092. /**
  5093. * Class used to evalaute queries containing `and` and `or` operators
  5094. */
  5095. export class AndOrNotEvaluator {
  5096. /**
  5097. * Evaluate a query
  5098. * @param query defines the query to evaluate
  5099. * @param evaluateCallback defines the callback used to filter result
  5100. * @returns true if the query matches
  5101. */
  5102. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5103. private static _HandleParenthesisContent;
  5104. private static _SimplifyNegation;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/tags" {
  5108. /**
  5109. * Class used to store custom tags
  5110. */
  5111. export class Tags {
  5112. /**
  5113. * Adds support for tags on the given object
  5114. * @param obj defines the object to use
  5115. */
  5116. static EnableFor(obj: any): void;
  5117. /**
  5118. * Removes tags support
  5119. * @param obj defines the object to use
  5120. */
  5121. static DisableFor(obj: any): void;
  5122. /**
  5123. * Gets a boolean indicating if the given object has tags
  5124. * @param obj defines the object to use
  5125. * @returns a boolean
  5126. */
  5127. static HasTags(obj: any): boolean;
  5128. /**
  5129. * Gets the tags available on a given object
  5130. * @param obj defines the object to use
  5131. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5132. * @returns the tags
  5133. */
  5134. static GetTags(obj: any, asString?: boolean): any;
  5135. /**
  5136. * Adds tags to an object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5139. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5140. */
  5141. static AddTagsTo(obj: any, tagsString: string): void;
  5142. /**
  5143. * @hidden
  5144. */
  5145. static _AddTagTo(obj: any, tag: string): void;
  5146. /**
  5147. * Removes specific tags from a specific object
  5148. * @param obj defines the object to use
  5149. * @param tagsString defines the tags to remove
  5150. */
  5151. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5152. /**
  5153. * @hidden
  5154. */
  5155. static _RemoveTagFrom(obj: any, tag: string): void;
  5156. /**
  5157. * Defines if tags hosted on an object match a given query
  5158. * @param obj defines the object to use
  5159. * @param tagsQuery defines the tag query
  5160. * @returns a boolean
  5161. */
  5162. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5163. }
  5164. }
  5165. declare module "babylonjs/Materials/materialDefines" {
  5166. /**
  5167. * Manages the defines for the Material
  5168. */
  5169. export class MaterialDefines {
  5170. /** @hidden */
  5171. protected _keys: string[];
  5172. private _isDirty;
  5173. /** @hidden */
  5174. _renderId: number;
  5175. /** @hidden */
  5176. _areLightsDirty: boolean;
  5177. /** @hidden */
  5178. _areAttributesDirty: boolean;
  5179. /** @hidden */
  5180. _areTexturesDirty: boolean;
  5181. /** @hidden */
  5182. _areFresnelDirty: boolean;
  5183. /** @hidden */
  5184. _areMiscDirty: boolean;
  5185. /** @hidden */
  5186. _areImageProcessingDirty: boolean;
  5187. /** @hidden */
  5188. _normals: boolean;
  5189. /** @hidden */
  5190. _uvs: boolean;
  5191. /** @hidden */
  5192. _needNormals: boolean;
  5193. /** @hidden */
  5194. _needUVs: boolean;
  5195. [id: string]: any;
  5196. /**
  5197. * Specifies if the material needs to be re-calculated
  5198. */
  5199. readonly isDirty: boolean;
  5200. /**
  5201. * Marks the material to indicate that it has been re-calculated
  5202. */
  5203. markAsProcessed(): void;
  5204. /**
  5205. * Marks the material to indicate that it needs to be re-calculated
  5206. */
  5207. markAsUnprocessed(): void;
  5208. /**
  5209. * Marks the material to indicate all of its defines need to be re-calculated
  5210. */
  5211. markAllAsDirty(): void;
  5212. /**
  5213. * Marks the material to indicate that image processing needs to be re-calculated
  5214. */
  5215. markAsImageProcessingDirty(): void;
  5216. /**
  5217. * Marks the material to indicate the lights need to be re-calculated
  5218. */
  5219. markAsLightDirty(): void;
  5220. /**
  5221. * Marks the attribute state as changed
  5222. */
  5223. markAsAttributesDirty(): void;
  5224. /**
  5225. * Marks the texture state as changed
  5226. */
  5227. markAsTexturesDirty(): void;
  5228. /**
  5229. * Marks the fresnel state as changed
  5230. */
  5231. markAsFresnelDirty(): void;
  5232. /**
  5233. * Marks the misc state as changed
  5234. */
  5235. markAsMiscDirty(): void;
  5236. /**
  5237. * Rebuilds the material defines
  5238. */
  5239. rebuild(): void;
  5240. /**
  5241. * Specifies if two material defines are equal
  5242. * @param other - A material define instance to compare to
  5243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5244. */
  5245. isEqual(other: MaterialDefines): boolean;
  5246. /**
  5247. * Clones this instance's defines to another instance
  5248. * @param other - material defines to clone values to
  5249. */
  5250. cloneTo(other: MaterialDefines): void;
  5251. /**
  5252. * Resets the material define values
  5253. */
  5254. reset(): void;
  5255. /**
  5256. * Converts the material define values to a string
  5257. * @returns - String of material define information
  5258. */
  5259. toString(): string;
  5260. }
  5261. }
  5262. declare module "babylonjs/Engines/IPipelineContext" {
  5263. /**
  5264. * Class used to store and describe the pipeline context associated with an effect
  5265. */
  5266. export interface IPipelineContext {
  5267. /**
  5268. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5269. */
  5270. isAsync: boolean;
  5271. /**
  5272. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5273. */
  5274. isReady: boolean;
  5275. /** @hidden */
  5276. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5277. }
  5278. }
  5279. declare module "babylonjs/Meshes/dataBuffer" {
  5280. /**
  5281. * Class used to store gfx data (like WebGLBuffer)
  5282. */
  5283. export class DataBuffer {
  5284. /**
  5285. * Gets or sets the number of objects referencing this buffer
  5286. */
  5287. references: number;
  5288. /** Gets or sets the size of the underlying buffer */
  5289. capacity: number;
  5290. /**
  5291. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5292. */
  5293. is32Bits: boolean;
  5294. /**
  5295. * Gets the underlying buffer
  5296. */
  5297. readonly underlyingResource: any;
  5298. }
  5299. }
  5300. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5301. /** @hidden */
  5302. export interface IShaderProcessor {
  5303. attributeProcessor?: (attribute: string) => string;
  5304. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5305. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5306. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5307. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5308. lineProcessor?: (line: string, isFragment: boolean) => string;
  5309. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5310. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5311. }
  5312. }
  5313. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5314. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5315. /** @hidden */
  5316. export interface ProcessingOptions {
  5317. defines: string[];
  5318. indexParameters: any;
  5319. isFragment: boolean;
  5320. shouldUseHighPrecisionShader: boolean;
  5321. supportsUniformBuffers: boolean;
  5322. shadersRepository: string;
  5323. includesShadersStore: {
  5324. [key: string]: string;
  5325. };
  5326. processor?: IShaderProcessor;
  5327. version: string;
  5328. platformName: string;
  5329. lookForClosingBracketForUniformBuffer?: boolean;
  5330. }
  5331. }
  5332. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5333. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5334. /** @hidden */
  5335. export class ShaderCodeNode {
  5336. line: string;
  5337. children: ShaderCodeNode[];
  5338. additionalDefineKey?: string;
  5339. additionalDefineValue?: string;
  5340. isValid(preprocessors: {
  5341. [key: string]: string;
  5342. }): boolean;
  5343. process(preprocessors: {
  5344. [key: string]: string;
  5345. }, options: ProcessingOptions): string;
  5346. }
  5347. }
  5348. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5349. /** @hidden */
  5350. export class ShaderCodeCursor {
  5351. private _lines;
  5352. lineIndex: number;
  5353. readonly currentLine: string;
  5354. readonly canRead: boolean;
  5355. lines: string[];
  5356. }
  5357. }
  5358. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5359. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5360. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5361. /** @hidden */
  5362. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5363. process(preprocessors: {
  5364. [key: string]: string;
  5365. }, options: ProcessingOptions): string;
  5366. }
  5367. }
  5368. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5369. /** @hidden */
  5370. export class ShaderDefineExpression {
  5371. isTrue(preprocessors: {
  5372. [key: string]: string;
  5373. }): boolean;
  5374. }
  5375. }
  5376. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5377. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5378. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5379. /** @hidden */
  5380. export class ShaderCodeTestNode extends ShaderCodeNode {
  5381. testExpression: ShaderDefineExpression;
  5382. isValid(preprocessors: {
  5383. [key: string]: string;
  5384. }): boolean;
  5385. }
  5386. }
  5387. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5388. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5389. /** @hidden */
  5390. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. not: boolean;
  5393. constructor(define: string, not?: boolean);
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5400. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5401. /** @hidden */
  5402. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5403. leftOperand: ShaderDefineExpression;
  5404. rightOperand: ShaderDefineExpression;
  5405. isTrue(preprocessors: {
  5406. [key: string]: string;
  5407. }): boolean;
  5408. }
  5409. }
  5410. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5411. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5412. /** @hidden */
  5413. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5414. leftOperand: ShaderDefineExpression;
  5415. rightOperand: ShaderDefineExpression;
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5422. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5423. /** @hidden */
  5424. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5425. define: string;
  5426. operand: string;
  5427. testValue: string;
  5428. constructor(define: string, operand: string, testValue: string);
  5429. isTrue(preprocessors: {
  5430. [key: string]: string;
  5431. }): boolean;
  5432. }
  5433. }
  5434. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5435. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5436. /** @hidden */
  5437. export class ShaderProcessor {
  5438. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5439. private static _ProcessPrecision;
  5440. private static _ExtractOperation;
  5441. private static _BuildSubExpression;
  5442. private static _BuildExpression;
  5443. private static _MoveCursorWithinIf;
  5444. private static _MoveCursor;
  5445. private static _EvaluatePreProcessors;
  5446. private static _PreparePreProcessors;
  5447. private static _ProcessShaderConversion;
  5448. private static _ProcessIncludes;
  5449. }
  5450. }
  5451. declare module "babylonjs/Misc/performanceMonitor" {
  5452. /**
  5453. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5454. */
  5455. export class PerformanceMonitor {
  5456. private _enabled;
  5457. private _rollingFrameTime;
  5458. private _lastFrameTimeMs;
  5459. /**
  5460. * constructor
  5461. * @param frameSampleSize The number of samples required to saturate the sliding window
  5462. */
  5463. constructor(frameSampleSize?: number);
  5464. /**
  5465. * Samples current frame
  5466. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5467. */
  5468. sampleFrame(timeMs?: number): void;
  5469. /**
  5470. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTime: number;
  5473. /**
  5474. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5475. */
  5476. readonly averageFrameTimeVariance: number;
  5477. /**
  5478. * Returns the frame time of the most recent frame
  5479. */
  5480. readonly instantaneousFrameTime: number;
  5481. /**
  5482. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5483. */
  5484. readonly averageFPS: number;
  5485. /**
  5486. * Returns the average framerate in frames per second using the most recent frame time
  5487. */
  5488. readonly instantaneousFPS: number;
  5489. /**
  5490. * Returns true if enough samples have been taken to completely fill the sliding window
  5491. */
  5492. readonly isSaturated: boolean;
  5493. /**
  5494. * Enables contributions to the sliding window sample set
  5495. */
  5496. enable(): void;
  5497. /**
  5498. * Disables contributions to the sliding window sample set
  5499. * Samples will not be interpolated over the disabled period
  5500. */
  5501. disable(): void;
  5502. /**
  5503. * Returns true if sampling is enabled
  5504. */
  5505. readonly isEnabled: boolean;
  5506. /**
  5507. * Resets performance monitor
  5508. */
  5509. reset(): void;
  5510. }
  5511. /**
  5512. * RollingAverage
  5513. *
  5514. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5515. */
  5516. export class RollingAverage {
  5517. /**
  5518. * Current average
  5519. */
  5520. average: number;
  5521. /**
  5522. * Current variance
  5523. */
  5524. variance: number;
  5525. protected _samples: Array<number>;
  5526. protected _sampleCount: number;
  5527. protected _pos: number;
  5528. protected _m2: number;
  5529. /**
  5530. * constructor
  5531. * @param length The number of samples required to saturate the sliding window
  5532. */
  5533. constructor(length: number);
  5534. /**
  5535. * Adds a sample to the sample set
  5536. * @param v The sample value
  5537. */
  5538. add(v: number): void;
  5539. /**
  5540. * Returns previously added values or null if outside of history or outside the sliding window domain
  5541. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5542. * @return Value previously recorded with add() or null if outside of range
  5543. */
  5544. history(i: number): number;
  5545. /**
  5546. * Returns true if enough samples have been taken to completely fill the sliding window
  5547. * @return true if sample-set saturated
  5548. */
  5549. isSaturated(): boolean;
  5550. /**
  5551. * Resets the rolling average (equivalent to 0 samples taken so far)
  5552. */
  5553. reset(): void;
  5554. /**
  5555. * Wraps a value around the sample range boundaries
  5556. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5557. * @return Wrapped position in sample range
  5558. */
  5559. protected _wrapPosition(i: number): number;
  5560. }
  5561. }
  5562. declare module "babylonjs/Misc/stringDictionary" {
  5563. import { Nullable } from "babylonjs/types";
  5564. /**
  5565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5566. * The underlying implementation relies on an associative array to ensure the best performances.
  5567. * The value can be anything including 'null' but except 'undefined'
  5568. */
  5569. export class StringDictionary<T> {
  5570. /**
  5571. * This will clear this dictionary and copy the content from the 'source' one.
  5572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5573. * @param source the dictionary to take the content from and copy to this dictionary
  5574. */
  5575. copyFrom(source: StringDictionary<T>): void;
  5576. /**
  5577. * Get a value based from its key
  5578. * @param key the given key to get the matching value from
  5579. * @return the value if found, otherwise undefined is returned
  5580. */
  5581. get(key: string): T | undefined;
  5582. /**
  5583. * Get a value from its key or add it if it doesn't exist.
  5584. * This method will ensure you that a given key/data will be present in the dictionary.
  5585. * @param key the given key to get the matching value from
  5586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5587. * The factory will only be invoked if there's no data for the given key.
  5588. * @return the value corresponding to the key.
  5589. */
  5590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5591. /**
  5592. * Get a value from its key if present in the dictionary otherwise add it
  5593. * @param key the key to get the value from
  5594. * @param val if there's no such key/value pair in the dictionary add it with this value
  5595. * @return the value corresponding to the key
  5596. */
  5597. getOrAdd(key: string, val: T): T;
  5598. /**
  5599. * Check if there's a given key in the dictionary
  5600. * @param key the key to check for
  5601. * @return true if the key is present, false otherwise
  5602. */
  5603. contains(key: string): boolean;
  5604. /**
  5605. * Add a new key and its corresponding value
  5606. * @param key the key to add
  5607. * @param value the value corresponding to the key
  5608. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5609. */
  5610. add(key: string, value: T): boolean;
  5611. /**
  5612. * Update a specific value associated to a key
  5613. * @param key defines the key to use
  5614. * @param value defines the value to store
  5615. * @returns true if the value was updated (or false if the key was not found)
  5616. */
  5617. set(key: string, value: T): boolean;
  5618. /**
  5619. * Get the element of the given key and remove it from the dictionary
  5620. * @param key defines the key to search
  5621. * @returns the value associated with the key or null if not found
  5622. */
  5623. getAndRemove(key: string): Nullable<T>;
  5624. /**
  5625. * Remove a key/value from the dictionary.
  5626. * @param key the key to remove
  5627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5628. */
  5629. remove(key: string): boolean;
  5630. /**
  5631. * Clear the whole content of the dictionary
  5632. */
  5633. clear(): void;
  5634. /**
  5635. * Gets the current count
  5636. */
  5637. readonly count: number;
  5638. /**
  5639. * Execute a callback on each key/val of the dictionary.
  5640. * Note that you can remove any element in this dictionary in the callback implementation
  5641. * @param callback the callback to execute on a given key/value pair
  5642. */
  5643. forEach(callback: (key: string, val: T) => void): void;
  5644. /**
  5645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5647. * Note that you can remove any element in this dictionary in the callback implementation
  5648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5649. * @returns the first item
  5650. */
  5651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5652. private _count;
  5653. private _data;
  5654. }
  5655. }
  5656. declare module "babylonjs/Misc/promise" {
  5657. /**
  5658. * Helper class that provides a small promise polyfill
  5659. */
  5660. export class PromisePolyfill {
  5661. /**
  5662. * Static function used to check if the polyfill is required
  5663. * If this is the case then the function will inject the polyfill to window.Promise
  5664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5665. */
  5666. static Apply(force?: boolean): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/Meshes/buffer" {
  5670. import { Nullable, DataArray } from "babylonjs/types";
  5671. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5672. /**
  5673. * Class used to store data that will be store in GPU memory
  5674. */
  5675. export class Buffer {
  5676. private _engine;
  5677. private _buffer;
  5678. /** @hidden */
  5679. _data: Nullable<DataArray>;
  5680. private _updatable;
  5681. private _instanced;
  5682. /**
  5683. * Gets the byte stride.
  5684. */
  5685. readonly byteStride: number;
  5686. /**
  5687. * Constructor
  5688. * @param engine the engine
  5689. * @param data the data to use for this buffer
  5690. * @param updatable whether the data is updatable
  5691. * @param stride the stride (optional)
  5692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5693. * @param instanced whether the buffer is instanced (optional)
  5694. * @param useBytes set to true if the stride in in bytes (optional)
  5695. */
  5696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5697. /**
  5698. * Create a new VertexBuffer based on the current buffer
  5699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5700. * @param offset defines offset in the buffer (0 by default)
  5701. * @param size defines the size in floats of attributes (position is 3 for instance)
  5702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5703. * @param instanced defines if the vertex buffer contains indexed data
  5704. * @param useBytes defines if the offset and stride are in bytes
  5705. * @returns the new vertex buffer
  5706. */
  5707. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5708. /**
  5709. * Gets a boolean indicating if the Buffer is updatable?
  5710. * @returns true if the buffer is updatable
  5711. */
  5712. isUpdatable(): boolean;
  5713. /**
  5714. * Gets current buffer's data
  5715. * @returns a DataArray or null
  5716. */
  5717. getData(): Nullable<DataArray>;
  5718. /**
  5719. * Gets underlying native buffer
  5720. * @returns underlying native buffer
  5721. */
  5722. getBuffer(): Nullable<DataBuffer>;
  5723. /**
  5724. * Gets the stride in float32 units (i.e. byte stride / 4).
  5725. * May not be an integer if the byte stride is not divisible by 4.
  5726. * DEPRECATED. Use byteStride instead.
  5727. * @returns the stride in float32 units
  5728. */
  5729. getStrideSize(): number;
  5730. /**
  5731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5732. * @param data defines the data to store
  5733. */
  5734. create(data?: Nullable<DataArray>): void;
  5735. /** @hidden */
  5736. _rebuild(): void;
  5737. /**
  5738. * Update current buffer data
  5739. * @param data defines the data to store
  5740. */
  5741. update(data: DataArray): void;
  5742. /**
  5743. * Updates the data directly.
  5744. * @param data the new data
  5745. * @param offset the new offset
  5746. * @param vertexCount the vertex count (optional)
  5747. * @param useBytes set to true if the offset is in bytes
  5748. */
  5749. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5750. /**
  5751. * Release all resources
  5752. */
  5753. dispose(): void;
  5754. }
  5755. /**
  5756. * Specialized buffer used to store vertex data
  5757. */
  5758. export class VertexBuffer {
  5759. /** @hidden */
  5760. _buffer: Buffer;
  5761. private _kind;
  5762. private _size;
  5763. private _ownsBuffer;
  5764. private _instanced;
  5765. private _instanceDivisor;
  5766. /**
  5767. * The byte type.
  5768. */
  5769. static readonly BYTE: number;
  5770. /**
  5771. * The unsigned byte type.
  5772. */
  5773. static readonly UNSIGNED_BYTE: number;
  5774. /**
  5775. * The short type.
  5776. */
  5777. static readonly SHORT: number;
  5778. /**
  5779. * The unsigned short type.
  5780. */
  5781. static readonly UNSIGNED_SHORT: number;
  5782. /**
  5783. * The integer type.
  5784. */
  5785. static readonly INT: number;
  5786. /**
  5787. * The unsigned integer type.
  5788. */
  5789. static readonly UNSIGNED_INT: number;
  5790. /**
  5791. * The float type.
  5792. */
  5793. static readonly FLOAT: number;
  5794. /**
  5795. * Gets or sets the instance divisor when in instanced mode
  5796. */
  5797. instanceDivisor: number;
  5798. /**
  5799. * Gets the byte stride.
  5800. */
  5801. readonly byteStride: number;
  5802. /**
  5803. * Gets the byte offset.
  5804. */
  5805. readonly byteOffset: number;
  5806. /**
  5807. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5808. */
  5809. readonly normalized: boolean;
  5810. /**
  5811. * Gets the data type of each component in the array.
  5812. */
  5813. readonly type: number;
  5814. /**
  5815. * Constructor
  5816. * @param engine the engine
  5817. * @param data the data to use for this vertex buffer
  5818. * @param kind the vertex buffer kind
  5819. * @param updatable whether the data is updatable
  5820. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5821. * @param stride the stride (optional)
  5822. * @param instanced whether the buffer is instanced (optional)
  5823. * @param offset the offset of the data (optional)
  5824. * @param size the number of components (optional)
  5825. * @param type the type of the component (optional)
  5826. * @param normalized whether the data contains normalized data (optional)
  5827. * @param useBytes set to true if stride and offset are in bytes (optional)
  5828. */
  5829. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5830. /** @hidden */
  5831. _rebuild(): void;
  5832. /**
  5833. * Returns the kind of the VertexBuffer (string)
  5834. * @returns a string
  5835. */
  5836. getKind(): string;
  5837. /**
  5838. * Gets a boolean indicating if the VertexBuffer is updatable?
  5839. * @returns true if the buffer is updatable
  5840. */
  5841. isUpdatable(): boolean;
  5842. /**
  5843. * Gets current buffer's data
  5844. * @returns a DataArray or null
  5845. */
  5846. getData(): Nullable<DataArray>;
  5847. /**
  5848. * Gets underlying native buffer
  5849. * @returns underlying native buffer
  5850. */
  5851. getBuffer(): Nullable<DataBuffer>;
  5852. /**
  5853. * Gets the stride in float32 units (i.e. byte stride / 4).
  5854. * May not be an integer if the byte stride is not divisible by 4.
  5855. * DEPRECATED. Use byteStride instead.
  5856. * @returns the stride in float32 units
  5857. */
  5858. getStrideSize(): number;
  5859. /**
  5860. * Returns the offset as a multiple of the type byte length.
  5861. * DEPRECATED. Use byteOffset instead.
  5862. * @returns the offset in bytes
  5863. */
  5864. getOffset(): number;
  5865. /**
  5866. * Returns the number of components per vertex attribute (integer)
  5867. * @returns the size in float
  5868. */
  5869. getSize(): number;
  5870. /**
  5871. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5872. * @returns true if this buffer is instanced
  5873. */
  5874. getIsInstanced(): boolean;
  5875. /**
  5876. * Returns the instancing divisor, zero for non-instanced (integer).
  5877. * @returns a number
  5878. */
  5879. getInstanceDivisor(): number;
  5880. /**
  5881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5882. * @param data defines the data to store
  5883. */
  5884. create(data?: DataArray): void;
  5885. /**
  5886. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5887. * This function will create a new buffer if the current one is not updatable
  5888. * @param data defines the data to store
  5889. */
  5890. update(data: DataArray): void;
  5891. /**
  5892. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5893. * Returns the directly updated WebGLBuffer.
  5894. * @param data the new data
  5895. * @param offset the new offset
  5896. * @param useBytes set to true if the offset is in bytes
  5897. */
  5898. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5899. /**
  5900. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5901. */
  5902. dispose(): void;
  5903. /**
  5904. * Enumerates each value of this vertex buffer as numbers.
  5905. * @param count the number of values to enumerate
  5906. * @param callback the callback function called for each value
  5907. */
  5908. forEach(count: number, callback: (value: number, index: number) => void): void;
  5909. /**
  5910. * Positions
  5911. */
  5912. static readonly PositionKind: string;
  5913. /**
  5914. * Normals
  5915. */
  5916. static readonly NormalKind: string;
  5917. /**
  5918. * Tangents
  5919. */
  5920. static readonly TangentKind: string;
  5921. /**
  5922. * Texture coordinates
  5923. */
  5924. static readonly UVKind: string;
  5925. /**
  5926. * Texture coordinates 2
  5927. */
  5928. static readonly UV2Kind: string;
  5929. /**
  5930. * Texture coordinates 3
  5931. */
  5932. static readonly UV3Kind: string;
  5933. /**
  5934. * Texture coordinates 4
  5935. */
  5936. static readonly UV4Kind: string;
  5937. /**
  5938. * Texture coordinates 5
  5939. */
  5940. static readonly UV5Kind: string;
  5941. /**
  5942. * Texture coordinates 6
  5943. */
  5944. static readonly UV6Kind: string;
  5945. /**
  5946. * Colors
  5947. */
  5948. static readonly ColorKind: string;
  5949. /**
  5950. * Matrix indices (for bones)
  5951. */
  5952. static readonly MatricesIndicesKind: string;
  5953. /**
  5954. * Matrix weights (for bones)
  5955. */
  5956. static readonly MatricesWeightsKind: string;
  5957. /**
  5958. * Additional matrix indices (for bones)
  5959. */
  5960. static readonly MatricesIndicesExtraKind: string;
  5961. /**
  5962. * Additional matrix weights (for bones)
  5963. */
  5964. static readonly MatricesWeightsExtraKind: string;
  5965. /**
  5966. * Deduces the stride given a kind.
  5967. * @param kind The kind string to deduce
  5968. * @returns The deduced stride
  5969. */
  5970. static DeduceStride(kind: string): number;
  5971. /**
  5972. * Gets the byte length of the given type.
  5973. * @param type the type
  5974. * @returns the number of bytes
  5975. */
  5976. static GetTypeByteLength(type: number): number;
  5977. /**
  5978. * Enumerates each value of the given parameters as numbers.
  5979. * @param data the data to enumerate
  5980. * @param byteOffset the byte offset of the data
  5981. * @param byteStride the byte stride of the data
  5982. * @param componentCount the number of components per element
  5983. * @param componentType the type of the component
  5984. * @param count the number of values to enumerate
  5985. * @param normalized whether the data is normalized
  5986. * @param callback the callback function called for each value
  5987. */
  5988. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5989. private static _GetFloatValue;
  5990. }
  5991. }
  5992. declare module "babylonjs/Maths/sphericalPolynomial" {
  5993. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5994. /**
  5995. * Class representing spherical harmonics coefficients to the 3rd degree
  5996. */
  5997. export class SphericalHarmonics {
  5998. /**
  5999. * Defines whether or not the harmonics have been prescaled for rendering.
  6000. */
  6001. preScaled: boolean;
  6002. /**
  6003. * The l0,0 coefficients of the spherical harmonics
  6004. */
  6005. l00: Vector3;
  6006. /**
  6007. * The l1,-1 coefficients of the spherical harmonics
  6008. */
  6009. l1_1: Vector3;
  6010. /**
  6011. * The l1,0 coefficients of the spherical harmonics
  6012. */
  6013. l10: Vector3;
  6014. /**
  6015. * The l1,1 coefficients of the spherical harmonics
  6016. */
  6017. l11: Vector3;
  6018. /**
  6019. * The l2,-2 coefficients of the spherical harmonics
  6020. */
  6021. l2_2: Vector3;
  6022. /**
  6023. * The l2,-1 coefficients of the spherical harmonics
  6024. */
  6025. l2_1: Vector3;
  6026. /**
  6027. * The l2,0 coefficients of the spherical harmonics
  6028. */
  6029. l20: Vector3;
  6030. /**
  6031. * The l2,1 coefficients of the spherical harmonics
  6032. */
  6033. l21: Vector3;
  6034. /**
  6035. * The l2,2 coefficients of the spherical harmonics
  6036. */
  6037. l22: Vector3;
  6038. /**
  6039. * Adds a light to the spherical harmonics
  6040. * @param direction the direction of the light
  6041. * @param color the color of the light
  6042. * @param deltaSolidAngle the delta solid angle of the light
  6043. */
  6044. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6045. /**
  6046. * Scales the spherical harmonics by the given amount
  6047. * @param scale the amount to scale
  6048. */
  6049. scaleInPlace(scale: number): void;
  6050. /**
  6051. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6052. *
  6053. * ```
  6054. * E_lm = A_l * L_lm
  6055. * ```
  6056. *
  6057. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6058. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6059. * the scaling factors are given in equation 9.
  6060. */
  6061. convertIncidentRadianceToIrradiance(): void;
  6062. /**
  6063. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6064. *
  6065. * ```
  6066. * L = (1/pi) * E * rho
  6067. * ```
  6068. *
  6069. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6070. */
  6071. convertIrradianceToLambertianRadiance(): void;
  6072. /**
  6073. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6074. * required operations at run time.
  6075. *
  6076. * This is simply done by scaling back the SH with Ylm constants parameter.
  6077. * The trigonometric part being applied by the shader at run time.
  6078. */
  6079. preScaleForRendering(): void;
  6080. /**
  6081. * Constructs a spherical harmonics from an array.
  6082. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6083. * @returns the spherical harmonics
  6084. */
  6085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6086. /**
  6087. * Gets the spherical harmonics from polynomial
  6088. * @param polynomial the spherical polynomial
  6089. * @returns the spherical harmonics
  6090. */
  6091. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6092. }
  6093. /**
  6094. * Class representing spherical polynomial coefficients to the 3rd degree
  6095. */
  6096. export class SphericalPolynomial {
  6097. private _harmonics;
  6098. /**
  6099. * The spherical harmonics used to create the polynomials.
  6100. */
  6101. readonly preScaledHarmonics: SphericalHarmonics;
  6102. /**
  6103. * The x coefficients of the spherical polynomial
  6104. */
  6105. x: Vector3;
  6106. /**
  6107. * The y coefficients of the spherical polynomial
  6108. */
  6109. y: Vector3;
  6110. /**
  6111. * The z coefficients of the spherical polynomial
  6112. */
  6113. z: Vector3;
  6114. /**
  6115. * The xx coefficients of the spherical polynomial
  6116. */
  6117. xx: Vector3;
  6118. /**
  6119. * The yy coefficients of the spherical polynomial
  6120. */
  6121. yy: Vector3;
  6122. /**
  6123. * The zz coefficients of the spherical polynomial
  6124. */
  6125. zz: Vector3;
  6126. /**
  6127. * The xy coefficients of the spherical polynomial
  6128. */
  6129. xy: Vector3;
  6130. /**
  6131. * The yz coefficients of the spherical polynomial
  6132. */
  6133. yz: Vector3;
  6134. /**
  6135. * The zx coefficients of the spherical polynomial
  6136. */
  6137. zx: Vector3;
  6138. /**
  6139. * Adds an ambient color to the spherical polynomial
  6140. * @param color the color to add
  6141. */
  6142. addAmbient(color: Color3): void;
  6143. /**
  6144. * Scales the spherical polynomial by the given amount
  6145. * @param scale the amount to scale
  6146. */
  6147. scaleInPlace(scale: number): void;
  6148. /**
  6149. * Gets the spherical polynomial from harmonics
  6150. * @param harmonics the spherical harmonics
  6151. * @returns the spherical polynomial
  6152. */
  6153. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6154. /**
  6155. * Constructs a spherical polynomial from an array.
  6156. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6157. * @returns the spherical polynomial
  6158. */
  6159. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6160. }
  6161. }
  6162. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6166. */
  6167. export interface CubeMapInfo {
  6168. /**
  6169. * The pixel array for the front face.
  6170. * This is stored in format, left to right, up to down format.
  6171. */
  6172. front: Nullable<ArrayBufferView>;
  6173. /**
  6174. * The pixel array for the back face.
  6175. * This is stored in format, left to right, up to down format.
  6176. */
  6177. back: Nullable<ArrayBufferView>;
  6178. /**
  6179. * The pixel array for the left face.
  6180. * This is stored in format, left to right, up to down format.
  6181. */
  6182. left: Nullable<ArrayBufferView>;
  6183. /**
  6184. * The pixel array for the right face.
  6185. * This is stored in format, left to right, up to down format.
  6186. */
  6187. right: Nullable<ArrayBufferView>;
  6188. /**
  6189. * The pixel array for the up face.
  6190. * This is stored in format, left to right, up to down format.
  6191. */
  6192. up: Nullable<ArrayBufferView>;
  6193. /**
  6194. * The pixel array for the down face.
  6195. * This is stored in format, left to right, up to down format.
  6196. */
  6197. down: Nullable<ArrayBufferView>;
  6198. /**
  6199. * The size of the cubemap stored.
  6200. *
  6201. * Each faces will be size * size pixels.
  6202. */
  6203. size: number;
  6204. /**
  6205. * The format of the texture.
  6206. *
  6207. * RGBA, RGB.
  6208. */
  6209. format: number;
  6210. /**
  6211. * The type of the texture data.
  6212. *
  6213. * UNSIGNED_INT, FLOAT.
  6214. */
  6215. type: number;
  6216. /**
  6217. * Specifies whether the texture is in gamma space.
  6218. */
  6219. gammaSpace: boolean;
  6220. }
  6221. /**
  6222. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6223. */
  6224. export class PanoramaToCubeMapTools {
  6225. private static FACE_FRONT;
  6226. private static FACE_BACK;
  6227. private static FACE_RIGHT;
  6228. private static FACE_LEFT;
  6229. private static FACE_DOWN;
  6230. private static FACE_UP;
  6231. /**
  6232. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6233. *
  6234. * @param float32Array The source data.
  6235. * @param inputWidth The width of the input panorama.
  6236. * @param inputHeight The height of the input panorama.
  6237. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6238. * @return The cubemap data
  6239. */
  6240. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6241. private static CreateCubemapTexture;
  6242. private static CalcProjectionSpherical;
  6243. }
  6244. }
  6245. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6249. /**
  6250. * Helper class dealing with the extraction of spherical polynomial dataArray
  6251. * from a cube map.
  6252. */
  6253. export class CubeMapToSphericalPolynomialTools {
  6254. private static FileFaces;
  6255. /**
  6256. * Converts a texture to the according Spherical Polynomial data.
  6257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6258. *
  6259. * @param texture The texture to extract the information from.
  6260. * @return The Spherical Polynomial data.
  6261. */
  6262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6263. /**
  6264. * Converts a cubemap to the according Spherical Polynomial data.
  6265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6266. *
  6267. * @param cubeInfo The Cube map to extract the information from.
  6268. * @return The Spherical Polynomial data.
  6269. */
  6270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6271. }
  6272. }
  6273. declare module "babylonjs/Engines/engineStore" {
  6274. import { Nullable } from "babylonjs/types";
  6275. import { Engine } from "babylonjs/Engines/engine";
  6276. import { Scene } from "babylonjs/scene";
  6277. /**
  6278. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6279. * during the life time of the application.
  6280. */
  6281. export class EngineStore {
  6282. /** Gets the list of created engines */
  6283. static Instances: import("babylonjs/Engines/engine").Engine[];
  6284. /** @hidden */
  6285. static _LastCreatedScene: Nullable<Scene>;
  6286. /**
  6287. * Gets the latest created engine
  6288. */
  6289. static readonly LastCreatedEngine: Nullable<Engine>;
  6290. /**
  6291. * Gets the latest created scene
  6292. */
  6293. static readonly LastCreatedScene: Nullable<Scene>;
  6294. }
  6295. }
  6296. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6297. /**
  6298. * Define options used to create a render target texture
  6299. */
  6300. export class RenderTargetCreationOptions {
  6301. /**
  6302. * Specifies is mipmaps must be generated
  6303. */
  6304. generateMipMaps?: boolean;
  6305. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6306. generateDepthBuffer?: boolean;
  6307. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6308. generateStencilBuffer?: boolean;
  6309. /** Defines texture type (int by default) */
  6310. type?: number;
  6311. /** Defines sampling mode (trilinear by default) */
  6312. samplingMode?: number;
  6313. /** Defines format (RGBA by default) */
  6314. format?: number;
  6315. }
  6316. }
  6317. declare module "babylonjs/States/alphaCullingState" {
  6318. /**
  6319. * @hidden
  6320. **/
  6321. export class _AlphaState {
  6322. private _isAlphaBlendDirty;
  6323. private _isBlendFunctionParametersDirty;
  6324. private _isBlendEquationParametersDirty;
  6325. private _isBlendConstantsDirty;
  6326. private _alphaBlend;
  6327. private _blendFunctionParameters;
  6328. private _blendEquationParameters;
  6329. private _blendConstants;
  6330. /**
  6331. * Initializes the state.
  6332. */
  6333. constructor();
  6334. readonly isDirty: boolean;
  6335. alphaBlend: boolean;
  6336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6339. reset(): void;
  6340. apply(gl: WebGLRenderingContext): void;
  6341. }
  6342. }
  6343. declare module "babylonjs/States/depthCullingState" {
  6344. import { Nullable } from "babylonjs/types";
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _DepthCullingState {
  6349. private _isDepthTestDirty;
  6350. private _isDepthMaskDirty;
  6351. private _isDepthFuncDirty;
  6352. private _isCullFaceDirty;
  6353. private _isCullDirty;
  6354. private _isZOffsetDirty;
  6355. private _isFrontFaceDirty;
  6356. private _depthTest;
  6357. private _depthMask;
  6358. private _depthFunc;
  6359. private _cull;
  6360. private _cullFace;
  6361. private _zOffset;
  6362. private _frontFace;
  6363. /**
  6364. * Initializes the state.
  6365. */
  6366. constructor();
  6367. readonly isDirty: boolean;
  6368. zOffset: number;
  6369. cullFace: Nullable<number>;
  6370. cull: Nullable<boolean>;
  6371. depthFunc: Nullable<number>;
  6372. depthMask: boolean;
  6373. depthTest: boolean;
  6374. frontFace: Nullable<number>;
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module "babylonjs/States/stencilState" {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _StencilState {
  6384. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6385. static readonly ALWAYS: number;
  6386. /** Passed to stencilOperation to specify that stencil value must be kept */
  6387. static readonly KEEP: number;
  6388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6389. static readonly REPLACE: number;
  6390. private _isStencilTestDirty;
  6391. private _isStencilMaskDirty;
  6392. private _isStencilFuncDirty;
  6393. private _isStencilOpDirty;
  6394. private _stencilTest;
  6395. private _stencilMask;
  6396. private _stencilFunc;
  6397. private _stencilFuncRef;
  6398. private _stencilFuncMask;
  6399. private _stencilOpStencilFail;
  6400. private _stencilOpDepthFail;
  6401. private _stencilOpStencilDepthPass;
  6402. readonly isDirty: boolean;
  6403. stencilFunc: number;
  6404. stencilFuncRef: number;
  6405. stencilFuncMask: number;
  6406. stencilOpStencilFail: number;
  6407. stencilOpDepthFail: number;
  6408. stencilOpStencilDepthPass: number;
  6409. stencilMask: number;
  6410. stencilTest: boolean;
  6411. constructor();
  6412. reset(): void;
  6413. apply(gl: WebGLRenderingContext): void;
  6414. }
  6415. }
  6416. declare module "babylonjs/States/index" {
  6417. export * from "babylonjs/States/alphaCullingState";
  6418. export * from "babylonjs/States/depthCullingState";
  6419. export * from "babylonjs/States/stencilState";
  6420. }
  6421. declare module "babylonjs/Instrumentation/timeToken" {
  6422. import { Nullable } from "babylonjs/types";
  6423. /**
  6424. * @hidden
  6425. **/
  6426. export class _TimeToken {
  6427. _startTimeQuery: Nullable<WebGLQuery>;
  6428. _endTimeQuery: Nullable<WebGLQuery>;
  6429. _timeElapsedQuery: Nullable<WebGLQuery>;
  6430. _timeElapsedQueryEnded: boolean;
  6431. }
  6432. }
  6433. declare module "babylonjs/Materials/Textures/internalTexture" {
  6434. import { Observable } from "babylonjs/Misc/observable";
  6435. import { Nullable, int } from "babylonjs/types";
  6436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6437. import { Engine } from "babylonjs/Engines/engine";
  6438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6439. /**
  6440. * Class used to store data associated with WebGL texture data for the engine
  6441. * This class should not be used directly
  6442. */
  6443. export class InternalTexture {
  6444. /** @hidden */
  6445. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6446. /**
  6447. * The source of the texture data is unknown
  6448. */
  6449. static DATASOURCE_UNKNOWN: number;
  6450. /**
  6451. * Texture data comes from an URL
  6452. */
  6453. static DATASOURCE_URL: number;
  6454. /**
  6455. * Texture data is only used for temporary storage
  6456. */
  6457. static DATASOURCE_TEMP: number;
  6458. /**
  6459. * Texture data comes from raw data (ArrayBuffer)
  6460. */
  6461. static DATASOURCE_RAW: number;
  6462. /**
  6463. * Texture content is dynamic (video or dynamic texture)
  6464. */
  6465. static DATASOURCE_DYNAMIC: number;
  6466. /**
  6467. * Texture content is generated by rendering to it
  6468. */
  6469. static DATASOURCE_RENDERTARGET: number;
  6470. /**
  6471. * Texture content is part of a multi render target process
  6472. */
  6473. static DATASOURCE_MULTIRENDERTARGET: number;
  6474. /**
  6475. * Texture data comes from a cube data file
  6476. */
  6477. static DATASOURCE_CUBE: number;
  6478. /**
  6479. * Texture data comes from a raw cube data
  6480. */
  6481. static DATASOURCE_CUBERAW: number;
  6482. /**
  6483. * Texture data come from a prefiltered cube data file
  6484. */
  6485. static DATASOURCE_CUBEPREFILTERED: number;
  6486. /**
  6487. * Texture content is raw 3D data
  6488. */
  6489. static DATASOURCE_RAW3D: number;
  6490. /**
  6491. * Texture content is a depth texture
  6492. */
  6493. static DATASOURCE_DEPTHTEXTURE: number;
  6494. /**
  6495. * Texture data comes from a raw cube data encoded with RGBD
  6496. */
  6497. static DATASOURCE_CUBERAW_RGBD: number;
  6498. /**
  6499. * Defines if the texture is ready
  6500. */
  6501. isReady: boolean;
  6502. /**
  6503. * Defines if the texture is a cube texture
  6504. */
  6505. isCube: boolean;
  6506. /**
  6507. * Defines if the texture contains 3D data
  6508. */
  6509. is3D: boolean;
  6510. /**
  6511. * Defines if the texture contains multiview data
  6512. */
  6513. isMultiview: boolean;
  6514. /**
  6515. * Gets the URL used to load this texture
  6516. */
  6517. url: string;
  6518. /**
  6519. * Gets the sampling mode of the texture
  6520. */
  6521. samplingMode: number;
  6522. /**
  6523. * Gets a boolean indicating if the texture needs mipmaps generation
  6524. */
  6525. generateMipMaps: boolean;
  6526. /**
  6527. * Gets the number of samples used by the texture (WebGL2+ only)
  6528. */
  6529. samples: number;
  6530. /**
  6531. * Gets the type of the texture (int, float...)
  6532. */
  6533. type: number;
  6534. /**
  6535. * Gets the format of the texture (RGB, RGBA...)
  6536. */
  6537. format: number;
  6538. /**
  6539. * Observable called when the texture is loaded
  6540. */
  6541. onLoadedObservable: Observable<InternalTexture>;
  6542. /**
  6543. * Gets the width of the texture
  6544. */
  6545. width: number;
  6546. /**
  6547. * Gets the height of the texture
  6548. */
  6549. height: number;
  6550. /**
  6551. * Gets the depth of the texture
  6552. */
  6553. depth: number;
  6554. /**
  6555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseWidth: number;
  6558. /**
  6559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseHeight: number;
  6562. /**
  6563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6564. */
  6565. baseDepth: number;
  6566. /**
  6567. * Gets a boolean indicating if the texture is inverted on Y axis
  6568. */
  6569. invertY: boolean;
  6570. /** @hidden */
  6571. _invertVScale: boolean;
  6572. /** @hidden */
  6573. _associatedChannel: number;
  6574. /** @hidden */
  6575. _dataSource: number;
  6576. /** @hidden */
  6577. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6578. /** @hidden */
  6579. _bufferView: Nullable<ArrayBufferView>;
  6580. /** @hidden */
  6581. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6582. /** @hidden */
  6583. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6584. /** @hidden */
  6585. _size: number;
  6586. /** @hidden */
  6587. _extension: string;
  6588. /** @hidden */
  6589. _files: Nullable<string[]>;
  6590. /** @hidden */
  6591. _workingCanvas: Nullable<HTMLCanvasElement>;
  6592. /** @hidden */
  6593. _workingContext: Nullable<CanvasRenderingContext2D>;
  6594. /** @hidden */
  6595. _framebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6600. /** @hidden */
  6601. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6602. /** @hidden */
  6603. _attachments: Nullable<number[]>;
  6604. /** @hidden */
  6605. _cachedCoordinatesMode: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapU: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedWrapV: Nullable<number>;
  6610. /** @hidden */
  6611. _cachedWrapR: Nullable<number>;
  6612. /** @hidden */
  6613. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6614. /** @hidden */
  6615. _isDisabled: boolean;
  6616. /** @hidden */
  6617. _compression: Nullable<string>;
  6618. /** @hidden */
  6619. _generateStencilBuffer: boolean;
  6620. /** @hidden */
  6621. _generateDepthBuffer: boolean;
  6622. /** @hidden */
  6623. _comparisonFunction: number;
  6624. /** @hidden */
  6625. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6626. /** @hidden */
  6627. _lodGenerationScale: number;
  6628. /** @hidden */
  6629. _lodGenerationOffset: number;
  6630. /** @hidden */
  6631. _colorTextureArray: Nullable<WebGLTexture>;
  6632. /** @hidden */
  6633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6634. /** @hidden */
  6635. _lodTextureHigh: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _lodTextureMid: Nullable<BaseTexture>;
  6638. /** @hidden */
  6639. _lodTextureLow: Nullable<BaseTexture>;
  6640. /** @hidden */
  6641. _isRGBD: boolean;
  6642. /** @hidden */
  6643. _linearSpecularLOD: boolean;
  6644. /** @hidden */
  6645. _irradianceTexture: Nullable<BaseTexture>;
  6646. /** @hidden */
  6647. _webGLTexture: Nullable<WebGLTexture>;
  6648. /** @hidden */
  6649. _references: number;
  6650. private _engine;
  6651. /**
  6652. * Gets the Engine the texture belongs to.
  6653. * @returns The babylon engine
  6654. */
  6655. getEngine(): Engine;
  6656. /**
  6657. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6658. */
  6659. readonly dataSource: number;
  6660. /**
  6661. * Creates a new InternalTexture
  6662. * @param engine defines the engine to use
  6663. * @param dataSource defines the type of data that will be used
  6664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6665. */
  6666. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6667. /**
  6668. * Increments the number of references (ie. the number of Texture that point to it)
  6669. */
  6670. incrementReferences(): void;
  6671. /**
  6672. * Change the size of the texture (not the size of the content)
  6673. * @param width defines the new width
  6674. * @param height defines the new height
  6675. * @param depth defines the new depth (1 by default)
  6676. */
  6677. updateSize(width: int, height: int, depth?: int): void;
  6678. /** @hidden */
  6679. _rebuild(): void;
  6680. /** @hidden */
  6681. _swapAndDie(target: InternalTexture): void;
  6682. /**
  6683. * Dispose the current allocated resources
  6684. */
  6685. dispose(): void;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/easing" {
  6689. /**
  6690. * This represents the main contract an easing function should follow.
  6691. * Easing functions are used throughout the animation system.
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export interface IEasingFunction {
  6695. /**
  6696. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6697. * of the easing function.
  6698. * The link below provides some of the most common examples of easing functions.
  6699. * @see https://easings.net/
  6700. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6701. * @returns the corresponding value on the curve defined by the easing function
  6702. */
  6703. ease(gradient: number): number;
  6704. }
  6705. /**
  6706. * Base class used for every default easing function.
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class EasingFunction implements IEasingFunction {
  6710. /**
  6711. * Interpolation follows the mathematical formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEIN: number;
  6714. /**
  6715. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6716. */
  6717. static readonly EASINGMODE_EASEOUT: number;
  6718. /**
  6719. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6720. */
  6721. static readonly EASINGMODE_EASEINOUT: number;
  6722. private _easingMode;
  6723. /**
  6724. * Sets the easing mode of the current function.
  6725. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6726. */
  6727. setEasingMode(easingMode: number): void;
  6728. /**
  6729. * Gets the current easing mode.
  6730. * @returns the easing mode
  6731. */
  6732. getEasingMode(): number;
  6733. /**
  6734. * @hidden
  6735. */
  6736. easeInCore(gradient: number): number;
  6737. /**
  6738. * Given an input gradient between 0 and 1, this returns the corresponding value
  6739. * of the easing function.
  6740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6741. * @returns the corresponding value on the curve defined by the easing function
  6742. */
  6743. ease(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a circle shape (see link below).
  6747. * @see https://easings.net/#easeInCirc
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class CircleEase extends EasingFunction implements IEasingFunction {
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. /**
  6755. * Easing function with a ease back shape (see link below).
  6756. * @see https://easings.net/#easeInBack
  6757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6758. */
  6759. export class BackEase extends EasingFunction implements IEasingFunction {
  6760. /** Defines the amplitude of the function */
  6761. amplitude: number;
  6762. /**
  6763. * Instantiates a back ease easing
  6764. * @see https://easings.net/#easeInBack
  6765. * @param amplitude Defines the amplitude of the function
  6766. */
  6767. constructor(
  6768. /** Defines the amplitude of the function */
  6769. amplitude?: number);
  6770. /** @hidden */
  6771. easeInCore(gradient: number): number;
  6772. }
  6773. /**
  6774. * Easing function with a bouncing shape (see link below).
  6775. * @see https://easings.net/#easeInBounce
  6776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6777. */
  6778. export class BounceEase extends EasingFunction implements IEasingFunction {
  6779. /** Defines the number of bounces */
  6780. bounces: number;
  6781. /** Defines the amplitude of the bounce */
  6782. bounciness: number;
  6783. /**
  6784. * Instantiates a bounce easing
  6785. * @see https://easings.net/#easeInBounce
  6786. * @param bounces Defines the number of bounces
  6787. * @param bounciness Defines the amplitude of the bounce
  6788. */
  6789. constructor(
  6790. /** Defines the number of bounces */
  6791. bounces?: number,
  6792. /** Defines the amplitude of the bounce */
  6793. bounciness?: number);
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with a power of 3 shape (see link below).
  6799. * @see https://easings.net/#easeInCubic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class CubicEase extends EasingFunction implements IEasingFunction {
  6803. /** @hidden */
  6804. easeInCore(gradient: number): number;
  6805. }
  6806. /**
  6807. * Easing function with an elastic shape (see link below).
  6808. * @see https://easings.net/#easeInElastic
  6809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6810. */
  6811. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6812. /** Defines the number of oscillations*/
  6813. oscillations: number;
  6814. /** Defines the amplitude of the oscillations*/
  6815. springiness: number;
  6816. /**
  6817. * Instantiates an elastic easing function
  6818. * @see https://easings.net/#easeInElastic
  6819. * @param oscillations Defines the number of oscillations
  6820. * @param springiness Defines the amplitude of the oscillations
  6821. */
  6822. constructor(
  6823. /** Defines the number of oscillations*/
  6824. oscillations?: number,
  6825. /** Defines the amplitude of the oscillations*/
  6826. springiness?: number);
  6827. /** @hidden */
  6828. easeInCore(gradient: number): number;
  6829. }
  6830. /**
  6831. * Easing function with an exponential shape (see link below).
  6832. * @see https://easings.net/#easeInExpo
  6833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6834. */
  6835. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6836. /** Defines the exponent of the function */
  6837. exponent: number;
  6838. /**
  6839. * Instantiates an exponential easing function
  6840. * @see https://easings.net/#easeInExpo
  6841. * @param exponent Defines the exponent of the function
  6842. */
  6843. constructor(
  6844. /** Defines the exponent of the function */
  6845. exponent?: number);
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power shape (see link below).
  6851. * @see https://easings.net/#easeInQuad
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class PowerEase extends EasingFunction implements IEasingFunction {
  6855. /** Defines the power of the function */
  6856. power: number;
  6857. /**
  6858. * Instantiates an power base easing function
  6859. * @see https://easings.net/#easeInQuad
  6860. * @param power Defines the power of the function
  6861. */
  6862. constructor(
  6863. /** Defines the power of the function */
  6864. power?: number);
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 2 shape (see link below).
  6870. * @see https://easings.net/#easeInQuad
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 4 shape (see link below).
  6879. * @see https://easings.net/#easeInQuart
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a power of 5 shape (see link below).
  6888. * @see https://easings.net/#easeInQuint
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a sin shape (see link below).
  6897. * @see https://easings.net/#easeInSine
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class SineEase extends EasingFunction implements IEasingFunction {
  6901. /** @hidden */
  6902. easeInCore(gradient: number): number;
  6903. }
  6904. /**
  6905. * Easing function with a bezier shape (see link below).
  6906. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6908. */
  6909. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6910. /** Defines the x component of the start tangent in the bezier curve */
  6911. x1: number;
  6912. /** Defines the y component of the start tangent in the bezier curve */
  6913. y1: number;
  6914. /** Defines the x component of the end tangent in the bezier curve */
  6915. x2: number;
  6916. /** Defines the y component of the end tangent in the bezier curve */
  6917. y2: number;
  6918. /**
  6919. * Instantiates a bezier function
  6920. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6921. * @param x1 Defines the x component of the start tangent in the bezier curve
  6922. * @param y1 Defines the y component of the start tangent in the bezier curve
  6923. * @param x2 Defines the x component of the end tangent in the bezier curve
  6924. * @param y2 Defines the y component of the end tangent in the bezier curve
  6925. */
  6926. constructor(
  6927. /** Defines the x component of the start tangent in the bezier curve */
  6928. x1?: number,
  6929. /** Defines the y component of the start tangent in the bezier curve */
  6930. y1?: number,
  6931. /** Defines the x component of the end tangent in the bezier curve */
  6932. x2?: number,
  6933. /** Defines the y component of the end tangent in the bezier curve */
  6934. y2?: number);
  6935. /** @hidden */
  6936. easeInCore(gradient: number): number;
  6937. }
  6938. }
  6939. declare module "babylonjs/Animations/animationKey" {
  6940. /**
  6941. * Defines an interface which represents an animation key frame
  6942. */
  6943. export interface IAnimationKey {
  6944. /**
  6945. * Frame of the key frame
  6946. */
  6947. frame: number;
  6948. /**
  6949. * Value at the specifies key frame
  6950. */
  6951. value: any;
  6952. /**
  6953. * The input tangent for the cubic hermite spline
  6954. */
  6955. inTangent?: any;
  6956. /**
  6957. * The output tangent for the cubic hermite spline
  6958. */
  6959. outTangent?: any;
  6960. /**
  6961. * The animation interpolation type
  6962. */
  6963. interpolation?: AnimationKeyInterpolation;
  6964. }
  6965. /**
  6966. * Enum for the animation key frame interpolation type
  6967. */
  6968. export enum AnimationKeyInterpolation {
  6969. /**
  6970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6971. */
  6972. STEP = 1
  6973. }
  6974. }
  6975. declare module "babylonjs/Animations/animationRange" {
  6976. /**
  6977. * Represents the range of an animation
  6978. */
  6979. export class AnimationRange {
  6980. /**The name of the animation range**/
  6981. name: string;
  6982. /**The starting frame of the animation */
  6983. from: number;
  6984. /**The ending frame of the animation*/
  6985. to: number;
  6986. /**
  6987. * Initializes the range of an animation
  6988. * @param name The name of the animation range
  6989. * @param from The starting frame of the animation
  6990. * @param to The ending frame of the animation
  6991. */
  6992. constructor(
  6993. /**The name of the animation range**/
  6994. name: string,
  6995. /**The starting frame of the animation */
  6996. from: number,
  6997. /**The ending frame of the animation*/
  6998. to: number);
  6999. /**
  7000. * Makes a copy of the animation range
  7001. * @returns A copy of the animation range
  7002. */
  7003. clone(): AnimationRange;
  7004. }
  7005. }
  7006. declare module "babylonjs/Animations/animationEvent" {
  7007. /**
  7008. * Composed of a frame, and an action function
  7009. */
  7010. export class AnimationEvent {
  7011. /** The frame for which the event is triggered **/
  7012. frame: number;
  7013. /** The event to perform when triggered **/
  7014. action: (currentFrame: number) => void;
  7015. /** Specifies if the event should be triggered only once**/
  7016. onlyOnce?: boolean | undefined;
  7017. /**
  7018. * Specifies if the animation event is done
  7019. */
  7020. isDone: boolean;
  7021. /**
  7022. * Initializes the animation event
  7023. * @param frame The frame for which the event is triggered
  7024. * @param action The event to perform when triggered
  7025. * @param onlyOnce Specifies if the event should be triggered only once
  7026. */
  7027. constructor(
  7028. /** The frame for which the event is triggered **/
  7029. frame: number,
  7030. /** The event to perform when triggered **/
  7031. action: (currentFrame: number) => void,
  7032. /** Specifies if the event should be triggered only once**/
  7033. onlyOnce?: boolean | undefined);
  7034. /** @hidden */
  7035. _clone(): AnimationEvent;
  7036. }
  7037. }
  7038. declare module "babylonjs/Behaviors/behavior" {
  7039. import { Nullable } from "babylonjs/types";
  7040. /**
  7041. * Interface used to define a behavior
  7042. */
  7043. export interface Behavior<T> {
  7044. /** gets or sets behavior's name */
  7045. name: string;
  7046. /**
  7047. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7048. */
  7049. init(): void;
  7050. /**
  7051. * Called when the behavior is attached to a target
  7052. * @param target defines the target where the behavior is attached to
  7053. */
  7054. attach(target: T): void;
  7055. /**
  7056. * Called when the behavior is detached from its target
  7057. */
  7058. detach(): void;
  7059. }
  7060. /**
  7061. * Interface implemented by classes supporting behaviors
  7062. */
  7063. export interface IBehaviorAware<T> {
  7064. /**
  7065. * Attach a behavior
  7066. * @param behavior defines the behavior to attach
  7067. * @returns the current host
  7068. */
  7069. addBehavior(behavior: Behavior<T>): T;
  7070. /**
  7071. * Remove a behavior from the current object
  7072. * @param behavior defines the behavior to detach
  7073. * @returns the current host
  7074. */
  7075. removeBehavior(behavior: Behavior<T>): T;
  7076. /**
  7077. * Gets a behavior using its name to search
  7078. * @param name defines the name to search
  7079. * @returns the behavior or null if not found
  7080. */
  7081. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/intersectionInfo" {
  7085. import { Nullable } from "babylonjs/types";
  7086. /**
  7087. * @hidden
  7088. */
  7089. export class IntersectionInfo {
  7090. bu: Nullable<number>;
  7091. bv: Nullable<number>;
  7092. distance: number;
  7093. faceId: number;
  7094. subMeshId: number;
  7095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7096. }
  7097. }
  7098. declare module "babylonjs/Culling/boundingSphere" {
  7099. import { DeepImmutable } from "babylonjs/types";
  7100. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7101. /**
  7102. * Class used to store bounding sphere information
  7103. */
  7104. export class BoundingSphere {
  7105. /**
  7106. * Gets the center of the bounding sphere in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Radius of the bounding sphere in local space
  7111. */
  7112. radius: number;
  7113. /**
  7114. * Gets the center of the bounding sphere in world space
  7115. */
  7116. readonly centerWorld: Vector3;
  7117. /**
  7118. * Radius of the bounding sphere in world space
  7119. */
  7120. radiusWorld: number;
  7121. /**
  7122. * Gets the minimum vector in local space
  7123. */
  7124. readonly minimum: Vector3;
  7125. /**
  7126. * Gets the maximum vector in local space
  7127. */
  7128. readonly maximum: Vector3;
  7129. private _worldMatrix;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Creates a new bounding sphere
  7133. * @param min defines the minimum vector (in local space)
  7134. * @param max defines the maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Scale the current bounding sphere by applying a scale factor
  7147. * @param factor defines the scale factor to apply
  7148. * @returns the current bounding box
  7149. */
  7150. scale(factor: number): BoundingSphere;
  7151. /**
  7152. * Gets the world matrix of the bounding box
  7153. * @returns a matrix
  7154. */
  7155. getWorldMatrix(): DeepImmutable<Matrix>;
  7156. /** @hidden */
  7157. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7158. /**
  7159. * Tests if the bounding sphere is intersecting the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an intersection
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if the bounding sphere center is in between the frustum planes.
  7166. * Used for optimistic fast inclusion.
  7167. * @param frustumPlanes defines the frustum planes to test
  7168. * @returns true if the sphere center is in between the frustum planes
  7169. */
  7170. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7171. /**
  7172. * Tests if a point is inside the bounding sphere
  7173. * @param point defines the point to test
  7174. * @returns true if the point is inside the bounding sphere
  7175. */
  7176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7177. /**
  7178. * Checks if two sphere intersct
  7179. * @param sphere0 sphere 0
  7180. * @param sphere1 sphere 1
  7181. * @returns true if the speres intersect
  7182. */
  7183. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7184. }
  7185. }
  7186. declare module "babylonjs/Culling/boundingBox" {
  7187. import { DeepImmutable } from "babylonjs/types";
  7188. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7189. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7190. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7191. /**
  7192. * Class used to store bounding box information
  7193. */
  7194. export class BoundingBox implements ICullable {
  7195. /**
  7196. * Gets the 8 vectors representing the bounding box in local space
  7197. */
  7198. readonly vectors: Vector3[];
  7199. /**
  7200. * Gets the center of the bounding box in local space
  7201. */
  7202. readonly center: Vector3;
  7203. /**
  7204. * Gets the center of the bounding box in world space
  7205. */
  7206. readonly centerWorld: Vector3;
  7207. /**
  7208. * Gets the extend size in local space
  7209. */
  7210. readonly extendSize: Vector3;
  7211. /**
  7212. * Gets the extend size in world space
  7213. */
  7214. readonly extendSizeWorld: Vector3;
  7215. /**
  7216. * Gets the OBB (object bounding box) directions
  7217. */
  7218. readonly directions: Vector3[];
  7219. /**
  7220. * Gets the 8 vectors representing the bounding box in world space
  7221. */
  7222. readonly vectorsWorld: Vector3[];
  7223. /**
  7224. * Gets the minimum vector in world space
  7225. */
  7226. readonly minimumWorld: Vector3;
  7227. /**
  7228. * Gets the maximum vector in world space
  7229. */
  7230. readonly maximumWorld: Vector3;
  7231. /**
  7232. * Gets the minimum vector in local space
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * Gets the maximum vector in local space
  7237. */
  7238. readonly maximum: Vector3;
  7239. private _worldMatrix;
  7240. private static readonly TmpVector3;
  7241. /**
  7242. * @hidden
  7243. */
  7244. _tag: number;
  7245. /**
  7246. * Creates a new bounding box
  7247. * @param min defines the minimum vector (in local space)
  7248. * @param max defines the maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7252. /**
  7253. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7254. * @param min defines the new minimum vector (in local space)
  7255. * @param max defines the new maximum vector (in local space)
  7256. * @param worldMatrix defines the new world matrix
  7257. */
  7258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7259. /**
  7260. * Scale the current bounding box by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding box
  7263. */
  7264. scale(factor: number): BoundingBox;
  7265. /**
  7266. * Gets the world matrix of the bounding box
  7267. * @returns a matrix
  7268. */
  7269. getWorldMatrix(): DeepImmutable<Matrix>;
  7270. /** @hidden */
  7271. _update(world: DeepImmutable<Matrix>): void;
  7272. /**
  7273. * Tests if the bounding box is intersecting the frustum planes
  7274. * @param frustumPlanes defines the frustum planes to test
  7275. * @returns true if there is an intersection
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7278. /**
  7279. * Tests if the bounding box is entirely inside the frustum planes
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @returns true if there is an inclusion
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /**
  7285. * Tests if a point is inside the bounding box
  7286. * @param point defines the point to test
  7287. * @returns true if the point is inside the bounding box
  7288. */
  7289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7290. /**
  7291. * Tests if the bounding box intersects with a bounding sphere
  7292. * @param sphere defines the sphere to test
  7293. * @returns true if there is an intersection
  7294. */
  7295. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7296. /**
  7297. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7298. * @param min defines the min vector to use
  7299. * @param max defines the max vector to use
  7300. * @returns true if there is an intersection
  7301. */
  7302. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7303. /**
  7304. * Tests if two bounding boxes are intersections
  7305. * @param box0 defines the first box to test
  7306. * @param box1 defines the second box to test
  7307. * @returns true if there is an intersection
  7308. */
  7309. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7310. /**
  7311. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7312. * @param minPoint defines the minimum vector of the bounding box
  7313. * @param maxPoint defines the maximum vector of the bounding box
  7314. * @param sphereCenter defines the sphere center
  7315. * @param sphereRadius defines the sphere radius
  7316. * @returns true if there is an intersection
  7317. */
  7318. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7319. /**
  7320. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @return true if there is an inclusion
  7324. */
  7325. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7328. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @return true if there is an intersection
  7331. */
  7332. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. }
  7334. }
  7335. declare module "babylonjs/Collisions/collider" {
  7336. import { Nullable, IndicesArray } from "babylonjs/types";
  7337. import { Vector3, Plane } from "babylonjs/Maths/math";
  7338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7339. /** @hidden */
  7340. export class Collider {
  7341. /** Define if a collision was found */
  7342. collisionFound: boolean;
  7343. /**
  7344. * Define last intersection point in local space
  7345. */
  7346. intersectionPoint: Vector3;
  7347. /**
  7348. * Define last collided mesh
  7349. */
  7350. collidedMesh: Nullable<AbstractMesh>;
  7351. private _collisionPoint;
  7352. private _planeIntersectionPoint;
  7353. private _tempVector;
  7354. private _tempVector2;
  7355. private _tempVector3;
  7356. private _tempVector4;
  7357. private _edge;
  7358. private _baseToVertex;
  7359. private _destinationPoint;
  7360. private _slidePlaneNormal;
  7361. private _displacementVector;
  7362. /** @hidden */
  7363. _radius: Vector3;
  7364. /** @hidden */
  7365. _retry: number;
  7366. private _velocity;
  7367. private _basePoint;
  7368. private _epsilon;
  7369. /** @hidden */
  7370. _velocityWorldLength: number;
  7371. /** @hidden */
  7372. _basePointWorld: Vector3;
  7373. private _velocityWorld;
  7374. private _normalizedVelocity;
  7375. /** @hidden */
  7376. _initialVelocity: Vector3;
  7377. /** @hidden */
  7378. _initialPosition: Vector3;
  7379. private _nearestDistance;
  7380. private _collisionMask;
  7381. collisionMask: number;
  7382. /**
  7383. * Gets the plane normal used to compute the sliding response (in local space)
  7384. */
  7385. readonly slidePlaneNormal: Vector3;
  7386. /** @hidden */
  7387. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7388. /** @hidden */
  7389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7390. /** @hidden */
  7391. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7392. /** @hidden */
  7393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7394. /** @hidden */
  7395. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7396. /** @hidden */
  7397. _getResponse(pos: Vector3, vel: Vector3): void;
  7398. }
  7399. }
  7400. declare module "babylonjs/Culling/boundingInfo" {
  7401. import { DeepImmutable } from "babylonjs/types";
  7402. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7403. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7405. import { Collider } from "babylonjs/Collisions/collider";
  7406. /**
  7407. * Interface for cullable objects
  7408. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7409. */
  7410. export interface ICullable {
  7411. /**
  7412. * Checks if the object or part of the object is in the frustum
  7413. * @param frustumPlanes Camera near/planes
  7414. * @returns true if the object is in frustum otherwise false
  7415. */
  7416. isInFrustum(frustumPlanes: Plane[]): boolean;
  7417. /**
  7418. * Checks if a cullable object (mesh...) is in the camera frustum
  7419. * Unlike isInFrustum this cheks the full bounding box
  7420. * @param frustumPlanes Camera near/planes
  7421. * @returns true if the object is in frustum otherwise false
  7422. */
  7423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7424. }
  7425. /**
  7426. * Info for a bounding data of a mesh
  7427. */
  7428. export class BoundingInfo implements ICullable {
  7429. /**
  7430. * Bounding box for the mesh
  7431. */
  7432. readonly boundingBox: BoundingBox;
  7433. /**
  7434. * Bounding sphere for the mesh
  7435. */
  7436. readonly boundingSphere: BoundingSphere;
  7437. private _isLocked;
  7438. private static readonly TmpVector3;
  7439. /**
  7440. * Constructs bounding info
  7441. * @param minimum min vector of the bounding box/sphere
  7442. * @param maximum max vector of the bounding box/sphere
  7443. * @param worldMatrix defines the new world matrix
  7444. */
  7445. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7446. /**
  7447. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7448. * @param min defines the new minimum vector (in local space)
  7449. * @param max defines the new maximum vector (in local space)
  7450. * @param worldMatrix defines the new world matrix
  7451. */
  7452. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7453. /**
  7454. * min vector of the bounding box/sphere
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * max vector of the bounding box/sphere
  7459. */
  7460. readonly maximum: Vector3;
  7461. /**
  7462. * If the info is locked and won't be updated to avoid perf overhead
  7463. */
  7464. isLocked: boolean;
  7465. /**
  7466. * Updates the bounding sphere and box
  7467. * @param world world matrix to be used to update
  7468. */
  7469. update(world: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7472. * @param center New center of the bounding info
  7473. * @param extend New extend of the bounding info
  7474. * @returns the current bounding info
  7475. */
  7476. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7477. /**
  7478. * Scale the current bounding info by applying a scale factor
  7479. * @param factor defines the scale factor to apply
  7480. * @returns the current bounding info
  7481. */
  7482. scale(factor: number): BoundingInfo;
  7483. /**
  7484. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7485. * @param frustumPlanes defines the frustum to test
  7486. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7487. * @returns true if the bounding info is in the frustum planes
  7488. */
  7489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7490. /**
  7491. * Gets the world distance between the min and max points of the bounding box
  7492. */
  7493. readonly diagonalLength: number;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * Unlike isInFrustum this cheks the full bounding box
  7497. * @param frustumPlanes Camera near/planes
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7501. /** @hidden */
  7502. _checkCollision(collider: Collider): boolean;
  7503. /**
  7504. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7505. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7506. * @param point the point to check intersection with
  7507. * @returns if the point intersects
  7508. */
  7509. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7510. /**
  7511. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7512. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7513. * @param boundingInfo the bounding info to check intersection with
  7514. * @param precise if the intersection should be done using OBB
  7515. * @returns if the bounding info intersects
  7516. */
  7517. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/smartArray" {
  7521. /**
  7522. * Defines an array and its length.
  7523. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7524. */
  7525. export interface ISmartArrayLike<T> {
  7526. /**
  7527. * The data of the array.
  7528. */
  7529. data: Array<T>;
  7530. /**
  7531. * The active length of the array.
  7532. */
  7533. length: number;
  7534. }
  7535. /**
  7536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7537. */
  7538. export class SmartArray<T> implements ISmartArrayLike<T> {
  7539. /**
  7540. * The full set of data from the array.
  7541. */
  7542. data: Array<T>;
  7543. /**
  7544. * The active length of the array.
  7545. */
  7546. length: number;
  7547. protected _id: number;
  7548. /**
  7549. * Instantiates a Smart Array.
  7550. * @param capacity defines the default capacity of the array.
  7551. */
  7552. constructor(capacity: number);
  7553. /**
  7554. * Pushes a value at the end of the active data.
  7555. * @param value defines the object to push in the array.
  7556. */
  7557. push(value: T): void;
  7558. /**
  7559. * Iterates over the active data and apply the lambda to them.
  7560. * @param func defines the action to apply on each value.
  7561. */
  7562. forEach(func: (content: T) => void): void;
  7563. /**
  7564. * Sorts the full sets of data.
  7565. * @param compareFn defines the comparison function to apply.
  7566. */
  7567. sort(compareFn: (a: T, b: T) => number): void;
  7568. /**
  7569. * Resets the active data to an empty array.
  7570. */
  7571. reset(): void;
  7572. /**
  7573. * Releases all the data from the array as well as the array.
  7574. */
  7575. dispose(): void;
  7576. /**
  7577. * Concats the active data with a given array.
  7578. * @param array defines the data to concatenate with.
  7579. */
  7580. concat(array: any): void;
  7581. /**
  7582. * Returns the position of a value in the active data.
  7583. * @param value defines the value to find the index for
  7584. * @returns the index if found in the active data otherwise -1
  7585. */
  7586. indexOf(value: T): number;
  7587. /**
  7588. * Returns whether an element is part of the active data.
  7589. * @param value defines the value to look for
  7590. * @returns true if found in the active data otherwise false
  7591. */
  7592. contains(value: T): boolean;
  7593. private static _GlobalId;
  7594. }
  7595. /**
  7596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7597. * The data in this array can only be present once
  7598. */
  7599. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7600. private _duplicateId;
  7601. /**
  7602. * Pushes a value at the end of the active data.
  7603. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7604. * @param value defines the object to push in the array.
  7605. */
  7606. push(value: T): void;
  7607. /**
  7608. * Pushes a value at the end of the active data.
  7609. * If the data is already present, it won t be added again
  7610. * @param value defines the object to push in the array.
  7611. * @returns true if added false if it was already present
  7612. */
  7613. pushNoDuplicate(value: T): boolean;
  7614. /**
  7615. * Resets the active data to an empty array.
  7616. */
  7617. reset(): void;
  7618. /**
  7619. * Concats the active data with a given array.
  7620. * This ensures no dupplicate will be present in the result.
  7621. * @param array defines the data to concatenate with.
  7622. */
  7623. concatWithNoDuplicate(array: any): void;
  7624. }
  7625. }
  7626. declare module "babylonjs/Misc/iInspectable" {
  7627. /**
  7628. * Enum that determines the text-wrapping mode to use.
  7629. */
  7630. export enum InspectableType {
  7631. /**
  7632. * Checkbox for booleans
  7633. */
  7634. Checkbox = 0,
  7635. /**
  7636. * Sliders for numbers
  7637. */
  7638. Slider = 1,
  7639. /**
  7640. * Vector3
  7641. */
  7642. Vector3 = 2,
  7643. /**
  7644. * Quaternions
  7645. */
  7646. Quaternion = 3,
  7647. /**
  7648. * Color3
  7649. */
  7650. Color3 = 4
  7651. }
  7652. /**
  7653. * Interface used to define custom inspectable properties.
  7654. * This interface is used by the inspector to display custom property grids
  7655. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7656. */
  7657. export interface IInspectable {
  7658. /**
  7659. * Gets the label to display
  7660. */
  7661. label: string;
  7662. /**
  7663. * Gets the name of the property to edit
  7664. */
  7665. propertyName: string;
  7666. /**
  7667. * Gets the type of the editor to use
  7668. */
  7669. type: InspectableType;
  7670. /**
  7671. * Gets the minimum value of the property when using in "slider" mode
  7672. */
  7673. min?: number;
  7674. /**
  7675. * Gets the maximum value of the property when using in "slider" mode
  7676. */
  7677. max?: number;
  7678. /**
  7679. * Gets the setp to use when using in "slider" mode
  7680. */
  7681. step?: number;
  7682. }
  7683. }
  7684. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7685. import { Nullable } from "babylonjs/types";
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. /**
  7688. * This represents the required contract to create a new type of texture loader.
  7689. */
  7690. export interface IInternalTextureLoader {
  7691. /**
  7692. * Defines wether the loader supports cascade loading the different faces.
  7693. */
  7694. supportCascades: boolean;
  7695. /**
  7696. * This returns if the loader support the current file information.
  7697. * @param extension defines the file extension of the file being loaded
  7698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7699. * @param fallback defines the fallback internal texture if any
  7700. * @param isBase64 defines whether the texture is encoded as a base64
  7701. * @param isBuffer defines whether the texture data are stored as a buffer
  7702. * @returns true if the loader can load the specified file
  7703. */
  7704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7705. /**
  7706. * Transform the url before loading if required.
  7707. * @param rootUrl the url of the texture
  7708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7709. * @returns the transformed texture
  7710. */
  7711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7712. /**
  7713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7714. * @param rootUrl the url of the texture
  7715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7716. * @returns the fallback texture
  7717. */
  7718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7719. /**
  7720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7721. * @param data contains the texture data
  7722. * @param texture defines the BabylonJS internal texture
  7723. * @param createPolynomials will be true if polynomials have been requested
  7724. * @param onLoad defines the callback to trigger once the texture is ready
  7725. * @param onError defines the callback to trigger in case of error
  7726. */
  7727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /**
  7729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7730. * @param data contains the texture data
  7731. * @param texture defines the BabylonJS internal texture
  7732. * @param callback defines the method to call once ready to upload
  7733. */
  7734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7735. }
  7736. }
  7737. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7739. import { Nullable } from "babylonjs/types";
  7740. import { Scene } from "babylonjs/scene";
  7741. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7742. module "babylonjs/Engines/engine" {
  7743. interface Engine {
  7744. /**
  7745. * Creates a depth stencil cube texture.
  7746. * This is only available in WebGL 2.
  7747. * @param size The size of face edge in the cube texture.
  7748. * @param options The options defining the cube texture.
  7749. * @returns The cube texture
  7750. */
  7751. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7766. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7767. * @returns the cube texture as an InternalTexture
  7768. */
  7769. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7770. /**
  7771. * Creates a cube texture
  7772. * @param rootUrl defines the url where the files to load is located
  7773. * @param scene defines the current scene
  7774. * @param files defines the list of files to load (1 per face)
  7775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7776. * @param onLoad defines an optional callback raised when the texture is loaded
  7777. * @param onError defines an optional callback raised if there is an issue to load the texture
  7778. * @param format defines the format of the data
  7779. * @param forcedExtension defines the extension to use to pick the right loader
  7780. * @returns the cube texture as an InternalTexture
  7781. */
  7782. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7783. /**
  7784. * Creates a cube texture
  7785. * @param rootUrl defines the url where the files to load is located
  7786. * @param scene defines the current scene
  7787. * @param files defines the list of files to load (1 per face)
  7788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7789. * @param onLoad defines an optional callback raised when the texture is loaded
  7790. * @param onError defines an optional callback raised if there is an issue to load the texture
  7791. * @param format defines the format of the data
  7792. * @param forcedExtension defines the extension to use to pick the right loader
  7793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7796. * @returns the cube texture as an InternalTexture
  7797. */
  7798. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7799. /** @hidden */
  7800. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7803. /** @hidden */
  7804. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7805. /** @hidden */
  7806. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7807. }
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7811. import { Nullable } from "babylonjs/types";
  7812. import { Scene } from "babylonjs/scene";
  7813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7815. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7816. /**
  7817. * Class for creating a cube texture
  7818. */
  7819. export class CubeTexture extends BaseTexture {
  7820. private _delayedOnLoad;
  7821. /**
  7822. * The url of the texture
  7823. */
  7824. url: string;
  7825. /**
  7826. * Gets or sets the center of the bounding box associated with the cube texture.
  7827. * It must define where the camera used to render the texture was set
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. boundingBoxPosition: Vector3;
  7831. private _boundingBoxSize;
  7832. /**
  7833. * Gets or sets the size of the bounding box associated with the cube texture
  7834. * When defined, the cubemap will switch to local mode
  7835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7836. * @example https://www.babylonjs-playground.com/#RNASML
  7837. */
  7838. /**
  7839. * Returns the bounding box size
  7840. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7841. */
  7842. boundingBoxSize: Vector3;
  7843. protected _rotationY: number;
  7844. /**
  7845. * Sets texture matrix rotation angle around Y axis in radians.
  7846. */
  7847. /**
  7848. * Gets texture matrix rotation angle around Y axis radians.
  7849. */
  7850. rotationY: number;
  7851. /**
  7852. * Are mip maps generated for this texture or not.
  7853. */
  7854. readonly noMipmap: boolean;
  7855. private _noMipmap;
  7856. private _files;
  7857. private _extensions;
  7858. private _textureMatrix;
  7859. private _format;
  7860. private _createPolynomials;
  7861. /** @hidden */
  7862. _prefiltered: boolean;
  7863. /**
  7864. * Creates a cube texture from an array of image urls
  7865. * @param files defines an array of image urls
  7866. * @param scene defines the hosting scene
  7867. * @param noMipmap specifies if mip maps are not used
  7868. * @returns a cube texture
  7869. */
  7870. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7871. /**
  7872. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7873. * @param url defines the url of the prefiltered texture
  7874. * @param scene defines the scene the texture is attached to
  7875. * @param forcedExtension defines the extension of the file if different from the url
  7876. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7877. * @return the prefiltered texture
  7878. */
  7879. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7880. /**
  7881. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7882. * as prefiltered data.
  7883. * @param rootUrl defines the url of the texture or the root name of the six images
  7884. * @param scene defines the scene the texture is attached to
  7885. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7886. * @param noMipmap defines if mipmaps should be created or not
  7887. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7888. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7889. * @param onError defines a callback triggered in case of error during load
  7890. * @param format defines the internal format to use for the texture once loaded
  7891. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7892. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7896. * @return the cube texture
  7897. */
  7898. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7899. /**
  7900. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7901. */
  7902. readonly isPrefiltered: boolean;
  7903. /**
  7904. * Get the current class name of the texture useful for serialization or dynamic coding.
  7905. * @returns "CubeTexture"
  7906. */
  7907. getClassName(): string;
  7908. /**
  7909. * Update the url (and optional buffer) of this texture if url was null during construction.
  7910. * @param url the url of the texture
  7911. * @param forcedExtension defines the extension to use
  7912. * @param onLoad callback called when the texture is loaded (defaults to null)
  7913. */
  7914. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7915. /**
  7916. * Delays loading of the cube texture
  7917. * @param forcedExtension defines the extension to use
  7918. */
  7919. delayLoad(forcedExtension?: string): void;
  7920. /**
  7921. * Returns the reflection texture matrix
  7922. * @returns the reflection texture matrix
  7923. */
  7924. getReflectionTextureMatrix(): Matrix;
  7925. /**
  7926. * Sets the reflection texture matrix
  7927. * @param value Reflection texture matrix
  7928. */
  7929. setReflectionTextureMatrix(value: Matrix): void;
  7930. /**
  7931. * Parses text to create a cube texture
  7932. * @param parsedTexture define the serialized text to read from
  7933. * @param scene defines the hosting scene
  7934. * @param rootUrl defines the root url of the cube texture
  7935. * @returns a cube texture
  7936. */
  7937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7938. /**
  7939. * Makes a clone, or deep copy, of the cube texture
  7940. * @returns a new cube texture
  7941. */
  7942. clone(): CubeTexture;
  7943. }
  7944. }
  7945. declare module "babylonjs/Shaders/postprocess.vertex" {
  7946. /** @hidden */
  7947. export var postprocessVertexShader: {
  7948. name: string;
  7949. shader: string;
  7950. };
  7951. }
  7952. declare module "babylonjs/Cameras/targetCamera" {
  7953. import { Nullable } from "babylonjs/types";
  7954. import { Camera } from "babylonjs/Cameras/camera";
  7955. import { Scene } from "babylonjs/scene";
  7956. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7957. /**
  7958. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7959. * This is the base of the follow, arc rotate cameras and Free camera
  7960. * @see http://doc.babylonjs.com/features/cameras
  7961. */
  7962. export class TargetCamera extends Camera {
  7963. private static _RigCamTransformMatrix;
  7964. private static _TargetTransformMatrix;
  7965. private static _TargetFocalPoint;
  7966. /**
  7967. * Define the current direction the camera is moving to
  7968. */
  7969. cameraDirection: Vector3;
  7970. /**
  7971. * Define the current rotation the camera is rotating to
  7972. */
  7973. cameraRotation: Vector2;
  7974. /**
  7975. * When set, the up vector of the camera will be updated by the rotation of the camera
  7976. */
  7977. updateUpVectorFromRotation: boolean;
  7978. private _tmpQuaternion;
  7979. /**
  7980. * Define the current rotation of the camera
  7981. */
  7982. rotation: Vector3;
  7983. /**
  7984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7985. */
  7986. rotationQuaternion: Quaternion;
  7987. /**
  7988. * Define the current speed of the camera
  7989. */
  7990. speed: number;
  7991. /**
  7992. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7993. * around all axis.
  7994. */
  7995. noRotationConstraint: boolean;
  7996. /**
  7997. * Define the current target of the camera as an object or a position.
  7998. */
  7999. lockedTarget: any;
  8000. /** @hidden */
  8001. _currentTarget: Vector3;
  8002. /** @hidden */
  8003. _initialFocalDistance: number;
  8004. /** @hidden */
  8005. _viewMatrix: Matrix;
  8006. /** @hidden */
  8007. _camMatrix: Matrix;
  8008. /** @hidden */
  8009. _cameraTransformMatrix: Matrix;
  8010. /** @hidden */
  8011. _cameraRotationMatrix: Matrix;
  8012. /** @hidden */
  8013. _referencePoint: Vector3;
  8014. /** @hidden */
  8015. _transformedReferencePoint: Vector3;
  8016. protected _globalCurrentTarget: Vector3;
  8017. protected _globalCurrentUpVector: Vector3;
  8018. /** @hidden */
  8019. _reset: () => void;
  8020. private _defaultUp;
  8021. /**
  8022. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8023. * This is the base of the follow, arc rotate cameras and Free camera
  8024. * @see http://doc.babylonjs.com/features/cameras
  8025. * @param name Defines the name of the camera in the scene
  8026. * @param position Defines the start position of the camera in the scene
  8027. * @param scene Defines the scene the camera belongs to
  8028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8029. */
  8030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8031. /**
  8032. * Gets the position in front of the camera at a given distance.
  8033. * @param distance The distance from the camera we want the position to be
  8034. * @returns the position
  8035. */
  8036. getFrontPosition(distance: number): Vector3;
  8037. /** @hidden */
  8038. _getLockedTargetPosition(): Nullable<Vector3>;
  8039. private _storedPosition;
  8040. private _storedRotation;
  8041. private _storedRotationQuaternion;
  8042. /**
  8043. * Store current camera state of the camera (fov, position, rotation, etc..)
  8044. * @returns the camera
  8045. */
  8046. storeState(): Camera;
  8047. /**
  8048. * Restored camera state. You must call storeState() first
  8049. * @returns whether it was successful or not
  8050. * @hidden
  8051. */
  8052. _restoreStateValues(): boolean;
  8053. /** @hidden */
  8054. _initCache(): void;
  8055. /** @hidden */
  8056. _updateCache(ignoreParentClass?: boolean): void;
  8057. /** @hidden */
  8058. _isSynchronizedViewMatrix(): boolean;
  8059. /** @hidden */
  8060. _computeLocalCameraSpeed(): number;
  8061. /**
  8062. * Defines the target the camera should look at.
  8063. * @param target Defines the new target as a Vector or a mesh
  8064. */
  8065. setTarget(target: Vector3): void;
  8066. /**
  8067. * Return the current target position of the camera. This value is expressed in local space.
  8068. * @returns the target position
  8069. */
  8070. getTarget(): Vector3;
  8071. /** @hidden */
  8072. _decideIfNeedsToMove(): boolean;
  8073. /** @hidden */
  8074. _updatePosition(): void;
  8075. /** @hidden */
  8076. _checkInputs(): void;
  8077. protected _updateCameraRotationMatrix(): void;
  8078. /**
  8079. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8080. * @returns the current camera
  8081. */
  8082. private _rotateUpVectorWithCameraRotationMatrix;
  8083. private _cachedRotationZ;
  8084. private _cachedQuaternionRotationZ;
  8085. /** @hidden */
  8086. _getViewMatrix(): Matrix;
  8087. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8088. /**
  8089. * @hidden
  8090. */
  8091. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8092. /**
  8093. * @hidden
  8094. */
  8095. _updateRigCameras(): void;
  8096. private _getRigCamPositionAndTarget;
  8097. /**
  8098. * Gets the current object class name.
  8099. * @return the class name
  8100. */
  8101. getClassName(): string;
  8102. }
  8103. }
  8104. declare module "babylonjs/Cameras/cameraInputsManager" {
  8105. import { Nullable } from "babylonjs/types";
  8106. import { Camera } from "babylonjs/Cameras/camera";
  8107. /**
  8108. * @ignore
  8109. * This is a list of all the different input types that are available in the application.
  8110. * Fo instance: ArcRotateCameraGamepadInput...
  8111. */
  8112. export var CameraInputTypes: {};
  8113. /**
  8114. * This is the contract to implement in order to create a new input class.
  8115. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8116. */
  8117. export interface ICameraInput<TCamera extends Camera> {
  8118. /**
  8119. * Defines the camera the input is attached to.
  8120. */
  8121. camera: Nullable<TCamera>;
  8122. /**
  8123. * Gets the class name of the current intput.
  8124. * @returns the class name
  8125. */
  8126. getClassName(): string;
  8127. /**
  8128. * Get the friendly name associated with the input class.
  8129. * @returns the input friendly name
  8130. */
  8131. getSimpleName(): string;
  8132. /**
  8133. * Attach the input controls to a specific dom element to get the input from.
  8134. * @param element Defines the element the controls should be listened from
  8135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8136. */
  8137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8138. /**
  8139. * Detach the current controls from the specified dom element.
  8140. * @param element Defines the element to stop listening the inputs from
  8141. */
  8142. detachControl(element: Nullable<HTMLElement>): void;
  8143. /**
  8144. * Update the current camera state depending on the inputs that have been used this frame.
  8145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8146. */
  8147. checkInputs?: () => void;
  8148. }
  8149. /**
  8150. * Represents a map of input types to input instance or input index to input instance.
  8151. */
  8152. export interface CameraInputsMap<TCamera extends Camera> {
  8153. /**
  8154. * Accessor to the input by input type.
  8155. */
  8156. [name: string]: ICameraInput<TCamera>;
  8157. /**
  8158. * Accessor to the input by input index.
  8159. */
  8160. [idx: number]: ICameraInput<TCamera>;
  8161. }
  8162. /**
  8163. * This represents the input manager used within a camera.
  8164. * It helps dealing with all the different kind of input attached to a camera.
  8165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8166. */
  8167. export class CameraInputsManager<TCamera extends Camera> {
  8168. /**
  8169. * Defines the list of inputs attahed to the camera.
  8170. */
  8171. attached: CameraInputsMap<TCamera>;
  8172. /**
  8173. * Defines the dom element the camera is collecting inputs from.
  8174. * This is null if the controls have not been attached.
  8175. */
  8176. attachedElement: Nullable<HTMLElement>;
  8177. /**
  8178. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8179. */
  8180. noPreventDefault: boolean;
  8181. /**
  8182. * Defined the camera the input manager belongs to.
  8183. */
  8184. camera: TCamera;
  8185. /**
  8186. * Update the current camera state depending on the inputs that have been used this frame.
  8187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8188. */
  8189. checkInputs: () => void;
  8190. /**
  8191. * Instantiate a new Camera Input Manager.
  8192. * @param camera Defines the camera the input manager blongs to
  8193. */
  8194. constructor(camera: TCamera);
  8195. /**
  8196. * Add an input method to a camera
  8197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8198. * @param input camera input method
  8199. */
  8200. add(input: ICameraInput<TCamera>): void;
  8201. /**
  8202. * Remove a specific input method from a camera
  8203. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8204. * @param inputToRemove camera input method
  8205. */
  8206. remove(inputToRemove: ICameraInput<TCamera>): void;
  8207. /**
  8208. * Remove a specific input type from a camera
  8209. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8210. * @param inputType the type of the input to remove
  8211. */
  8212. removeByType(inputType: string): void;
  8213. private _addCheckInputs;
  8214. /**
  8215. * Attach the input controls to the currently attached dom element to listen the events from.
  8216. * @param input Defines the input to attach
  8217. */
  8218. attachInput(input: ICameraInput<TCamera>): void;
  8219. /**
  8220. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8221. * @param element Defines the dom element to collect the events from
  8222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8223. */
  8224. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8225. /**
  8226. * Detach the current manager inputs controls from a specific dom element.
  8227. * @param element Defines the dom element to collect the events from
  8228. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8229. */
  8230. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8231. /**
  8232. * Rebuild the dynamic inputCheck function from the current list of
  8233. * defined inputs in the manager.
  8234. */
  8235. rebuildInputCheck(): void;
  8236. /**
  8237. * Remove all attached input methods from a camera
  8238. */
  8239. clear(): void;
  8240. /**
  8241. * Serialize the current input manager attached to a camera.
  8242. * This ensures than once parsed,
  8243. * the input associated to the camera will be identical to the current ones
  8244. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8245. */
  8246. serialize(serializedCamera: any): void;
  8247. /**
  8248. * Parses an input manager serialized JSON to restore the previous list of inputs
  8249. * and states associated to a camera.
  8250. * @param parsedCamera Defines the JSON to parse
  8251. */
  8252. parse(parsedCamera: any): void;
  8253. }
  8254. }
  8255. declare module "babylonjs/Events/keyboardEvents" {
  8256. /**
  8257. * Gather the list of keyboard event types as constants.
  8258. */
  8259. export class KeyboardEventTypes {
  8260. /**
  8261. * The keydown event is fired when a key becomes active (pressed).
  8262. */
  8263. static readonly KEYDOWN: number;
  8264. /**
  8265. * The keyup event is fired when a key has been released.
  8266. */
  8267. static readonly KEYUP: number;
  8268. }
  8269. /**
  8270. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8271. */
  8272. export class KeyboardInfo {
  8273. /**
  8274. * Defines the type of event (KeyboardEventTypes)
  8275. */
  8276. type: number;
  8277. /**
  8278. * Defines the related dom event
  8279. */
  8280. event: KeyboardEvent;
  8281. /**
  8282. * Instantiates a new keyboard info.
  8283. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8284. * @param type Defines the type of event (KeyboardEventTypes)
  8285. * @param event Defines the related dom event
  8286. */
  8287. constructor(
  8288. /**
  8289. * Defines the type of event (KeyboardEventTypes)
  8290. */
  8291. type: number,
  8292. /**
  8293. * Defines the related dom event
  8294. */
  8295. event: KeyboardEvent);
  8296. }
  8297. /**
  8298. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8299. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8300. */
  8301. export class KeyboardInfoPre extends KeyboardInfo {
  8302. /**
  8303. * Defines the type of event (KeyboardEventTypes)
  8304. */
  8305. type: number;
  8306. /**
  8307. * Defines the related dom event
  8308. */
  8309. event: KeyboardEvent;
  8310. /**
  8311. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8312. */
  8313. skipOnPointerObservable: boolean;
  8314. /**
  8315. * Instantiates a new keyboard pre info.
  8316. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8317. * @param type Defines the type of event (KeyboardEventTypes)
  8318. * @param event Defines the related dom event
  8319. */
  8320. constructor(
  8321. /**
  8322. * Defines the type of event (KeyboardEventTypes)
  8323. */
  8324. type: number,
  8325. /**
  8326. * Defines the related dom event
  8327. */
  8328. event: KeyboardEvent);
  8329. }
  8330. }
  8331. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8332. import { Nullable } from "babylonjs/types";
  8333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */
  8387. _onLostFocus(): void;
  8388. /**
  8389. * Get the friendly name associated with the input class.
  8390. * @returns the input friendly name
  8391. */
  8392. getSimpleName(): string;
  8393. }
  8394. }
  8395. declare module "babylonjs/Materials/multiMaterial" {
  8396. import { Nullable } from "babylonjs/types";
  8397. import { Scene } from "babylonjs/scene";
  8398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8399. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8401. import { Material } from "babylonjs/Materials/material";
  8402. /**
  8403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8404. * separate meshes. This can be use to improve performances.
  8405. * @see http://doc.babylonjs.com/how_to/multi_materials
  8406. */
  8407. export class MultiMaterial extends Material {
  8408. private _subMaterials;
  8409. /**
  8410. * Gets or Sets the list of Materials used within the multi material.
  8411. * They need to be ordered according to the submeshes order in the associated mesh
  8412. */
  8413. subMaterials: Nullable<Material>[];
  8414. /**
  8415. * Function used to align with Node.getChildren()
  8416. * @returns the list of Materials used within the multi material
  8417. */
  8418. getChildren(): Nullable<Material>[];
  8419. /**
  8420. * Instantiates a new Multi Material
  8421. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8422. * separate meshes. This can be use to improve performances.
  8423. * @see http://doc.babylonjs.com/how_to/multi_materials
  8424. * @param name Define the name in the scene
  8425. * @param scene Define the scene the material belongs to
  8426. */
  8427. constructor(name: string, scene: Scene);
  8428. private _hookArray;
  8429. /**
  8430. * Get one of the submaterial by its index in the submaterials array
  8431. * @param index The index to look the sub material at
  8432. * @returns The Material if the index has been defined
  8433. */
  8434. getSubMaterial(index: number): Nullable<Material>;
  8435. /**
  8436. * Get the list of active textures for the whole sub materials list.
  8437. * @returns All the textures that will be used during the rendering
  8438. */
  8439. getActiveTextures(): BaseTexture[];
  8440. /**
  8441. * Gets the current class name of the material e.g. "MultiMaterial"
  8442. * Mainly use in serialization.
  8443. * @returns the class name
  8444. */
  8445. getClassName(): string;
  8446. /**
  8447. * Checks if the material is ready to render the requested sub mesh
  8448. * @param mesh Define the mesh the submesh belongs to
  8449. * @param subMesh Define the sub mesh to look readyness for
  8450. * @param useInstances Define whether or not the material is used with instances
  8451. * @returns true if ready, otherwise false
  8452. */
  8453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8454. /**
  8455. * Clones the current material and its related sub materials
  8456. * @param name Define the name of the newly cloned material
  8457. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8458. * @returns the cloned material
  8459. */
  8460. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8461. /**
  8462. * Serializes the materials into a JSON representation.
  8463. * @returns the JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Dispose the material and release its associated resources
  8468. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  8469. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  8470. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  8471. */
  8472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8473. /**
  8474. * Creates a MultiMaterial from parsed MultiMaterial data.
  8475. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8476. * @param scene defines the hosting scene
  8477. * @returns a new MultiMaterial
  8478. */
  8479. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8480. }
  8481. }
  8482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8483. /**
  8484. * Class used to represent data loading progression
  8485. */
  8486. export class SceneLoaderFlags {
  8487. private static _ForceFullSceneLoadingForIncremental;
  8488. private static _ShowLoadingScreen;
  8489. private static _CleanBoneMatrixWeights;
  8490. private static _loggingLevel;
  8491. /**
  8492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8493. */
  8494. static ForceFullSceneLoadingForIncremental: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8497. */
  8498. static ShowLoadingScreen: boolean;
  8499. /**
  8500. * Defines the current logging level (while loading the scene)
  8501. * @ignorenaming
  8502. */
  8503. static loggingLevel: number;
  8504. /**
  8505. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8506. */
  8507. static CleanBoneMatrixWeights: boolean;
  8508. }
  8509. }
  8510. declare module "babylonjs/Meshes/transformNode" {
  8511. import { DeepImmutable } from "babylonjs/types";
  8512. import { Observable } from "babylonjs/Misc/observable";
  8513. import { Nullable } from "babylonjs/types";
  8514. import { Camera } from "babylonjs/Cameras/camera";
  8515. import { Scene } from "babylonjs/scene";
  8516. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8517. import { Node } from "babylonjs/node";
  8518. import { Bone } from "babylonjs/Bones/bone";
  8519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8520. /**
  8521. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  8522. * @see https://doc.babylonjs.com/how_to/transformnode
  8523. */
  8524. export class TransformNode extends Node {
  8525. /**
  8526. * Object will not rotate to face the camera
  8527. */
  8528. static BILLBOARDMODE_NONE: number;
  8529. /**
  8530. * Object will rotate to face the camera but only on the x axis
  8531. */
  8532. static BILLBOARDMODE_X: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the y axis
  8535. */
  8536. static BILLBOARDMODE_Y: number;
  8537. /**
  8538. * Object will rotate to face the camera but only on the z axis
  8539. */
  8540. static BILLBOARDMODE_Z: number;
  8541. /**
  8542. * Object will rotate to face the camera
  8543. */
  8544. static BILLBOARDMODE_ALL: number;
  8545. private _forward;
  8546. private _forwardInverted;
  8547. private _up;
  8548. private _right;
  8549. private _rightInverted;
  8550. private _position;
  8551. private _rotation;
  8552. private _rotationQuaternion;
  8553. protected _scaling: Vector3;
  8554. protected _isDirty: boolean;
  8555. private _transformToBoneReferal;
  8556. private _billboardMode;
  8557. /**
  8558. * Gets or sets the billboard mode. Default is 0.
  8559. *
  8560. * | Value | Type | Description |
  8561. * | --- | --- | --- |
  8562. * | 0 | BILLBOARDMODE_NONE | |
  8563. * | 1 | BILLBOARDMODE_X | |
  8564. * | 2 | BILLBOARDMODE_Y | |
  8565. * | 4 | BILLBOARDMODE_Z | |
  8566. * | 7 | BILLBOARDMODE_ALL | |
  8567. *
  8568. */
  8569. billboardMode: number;
  8570. private _preserveParentRotationForBillboard;
  8571. /**
  8572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8574. */
  8575. preserveParentRotationForBillboard: boolean;
  8576. /**
  8577. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  8578. */
  8579. scalingDeterminant: number;
  8580. private _infiniteDistance;
  8581. /**
  8582. * Gets or sets the distance of the object to max, often used by skybox
  8583. */
  8584. infiniteDistance: boolean;
  8585. /**
  8586. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8587. * By default the system will update normals to compensate
  8588. */
  8589. ignoreNonUniformScaling: boolean;
  8590. /**
  8591. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  8592. */
  8593. reIntegrateRotationIntoRotationQuaternion: boolean;
  8594. /** @hidden */
  8595. _poseMatrix: Nullable<Matrix>;
  8596. /** @hidden */
  8597. _localMatrix: Matrix;
  8598. private _usePivotMatrix;
  8599. private _absolutePosition;
  8600. private _pivotMatrix;
  8601. private _pivotMatrixInverse;
  8602. protected _postMultiplyPivotMatrix: boolean;
  8603. protected _isWorldMatrixFrozen: boolean;
  8604. /** @hidden */
  8605. _indexInSceneTransformNodesArray: number;
  8606. /**
  8607. * An event triggered after the world matrix is updated
  8608. */
  8609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8611. /**
  8612. * Gets a string identifying the name of the class
  8613. * @returns "TransformNode" string
  8614. */
  8615. getClassName(): string;
  8616. /**
  8617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8618. */
  8619. position: Vector3;
  8620. /**
  8621. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8623. */
  8624. rotation: Vector3;
  8625. /**
  8626. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  8627. */
  8628. scaling: Vector3;
  8629. /**
  8630. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  8631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8632. */
  8633. rotationQuaternion: Nullable<Quaternion>;
  8634. /**
  8635. * The forward direction of that transform in world space.
  8636. */
  8637. readonly forward: Vector3;
  8638. /**
  8639. * The up direction of that transform in world space.
  8640. */
  8641. readonly up: Vector3;
  8642. /**
  8643. * The right direction of that transform in world space.
  8644. */
  8645. readonly right: Vector3;
  8646. /**
  8647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8648. * @param matrix the matrix to copy the pose from
  8649. * @returns this TransformNode.
  8650. */
  8651. updatePoseMatrix(matrix: Matrix): TransformNode;
  8652. /**
  8653. * Returns the mesh Pose matrix.
  8654. * @returns the pose matrix
  8655. */
  8656. getPoseMatrix(): Matrix;
  8657. /** @hidden */
  8658. _isSynchronized(): boolean;
  8659. /** @hidden */
  8660. _initCache(): void;
  8661. /**
  8662. * Flag the transform node as dirty (Forcing it to update everything)
  8663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8664. * @returns this transform node
  8665. */
  8666. markAsDirty(property: string): TransformNode;
  8667. /**
  8668. * Returns the current mesh absolute position.
  8669. * Returns a Vector3.
  8670. */
  8671. readonly absolutePosition: Vector3;
  8672. /**
  8673. * Sets a new matrix to apply before all other transformation
  8674. * @param matrix defines the transform matrix
  8675. * @returns the current TransformNode
  8676. */
  8677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8678. /**
  8679. * Sets a new pivot matrix to the current node
  8680. * @param matrix defines the new pivot matrix to use
  8681. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  8682. * @returns the current TransformNode
  8683. */
  8684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8685. /**
  8686. * Returns the mesh pivot matrix.
  8687. * Default : Identity.
  8688. * @returns the matrix
  8689. */
  8690. getPivotMatrix(): Matrix;
  8691. /**
  8692. * Prevents the World matrix to be computed any longer.
  8693. * @returns the TransformNode.
  8694. */
  8695. freezeWorldMatrix(): TransformNode;
  8696. /**
  8697. * Allows back the World matrix computation.
  8698. * @returns the TransformNode.
  8699. */
  8700. unfreezeWorldMatrix(): this;
  8701. /**
  8702. * True if the World matrix has been frozen.
  8703. */
  8704. readonly isWorldMatrixFrozen: boolean;
  8705. /**
  8706. * Retuns the mesh absolute position in the World.
  8707. * @returns a Vector3.
  8708. */
  8709. getAbsolutePosition(): Vector3;
  8710. /**
  8711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8712. * @param absolutePosition the absolute position to set
  8713. * @returns the TransformNode.
  8714. */
  8715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8716. /**
  8717. * Sets the mesh position in its local space.
  8718. * @param vector3 the position to set in localspace
  8719. * @returns the TransformNode.
  8720. */
  8721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8722. /**
  8723. * Returns the mesh position in the local space from the current World matrix values.
  8724. * @returns a new Vector3.
  8725. */
  8726. getPositionExpressedInLocalSpace(): Vector3;
  8727. /**
  8728. * Translates the mesh along the passed Vector3 in its local space.
  8729. * @param vector3 the distance to translate in localspace
  8730. * @returns the TransformNode.
  8731. */
  8732. locallyTranslate(vector3: Vector3): TransformNode;
  8733. private static _lookAtVectorCache;
  8734. /**
  8735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8736. * @param targetPoint the position (must be in same space as current mesh) to look at
  8737. * @param yawCor optional yaw (y-axis) correction in radians
  8738. * @param pitchCor optional pitch (x-axis) correction in radians
  8739. * @param rollCor optional roll (z-axis) correction in radians
  8740. * @param space the choosen space of the target
  8741. * @returns the TransformNode.
  8742. */
  8743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8744. /**
  8745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. * This Vector3 is expressed in the World space.
  8747. * @param localAxis axis to rotate
  8748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8749. */
  8750. getDirection(localAxis: Vector3): Vector3;
  8751. /**
  8752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8753. * localAxis is expressed in the mesh local space.
  8754. * result is computed in the Wordl space from the mesh World matrix.
  8755. * @param localAxis axis to rotate
  8756. * @param result the resulting transformnode
  8757. * @returns this TransformNode.
  8758. */
  8759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8760. /**
  8761. * Sets this transform node rotation to the given local axis.
  8762. * @param localAxis the axis in local space
  8763. * @param yawCor optional yaw (y-axis) correction in radians
  8764. * @param pitchCor optional pitch (x-axis) correction in radians
  8765. * @param rollCor optional roll (z-axis) correction in radians
  8766. * @returns this TransformNode
  8767. */
  8768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8769. /**
  8770. * Sets a new pivot point to the current node
  8771. * @param point defines the new pivot point to use
  8772. * @param space defines if the point is in world or local space (local by default)
  8773. * @returns the current TransformNode
  8774. */
  8775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8776. /**
  8777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8778. * @returns the pivot point
  8779. */
  8780. getPivotPoint(): Vector3;
  8781. /**
  8782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8783. * @param result the vector3 to store the result
  8784. * @returns this TransformNode.
  8785. */
  8786. getPivotPointToRef(result: Vector3): TransformNode;
  8787. /**
  8788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8790. */
  8791. getAbsolutePivotPoint(): Vector3;
  8792. /**
  8793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8794. * @param result vector3 to store the result
  8795. * @returns this TransformNode.
  8796. */
  8797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8798. /**
  8799. * Defines the passed node as the parent of the current node.
  8800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8801. * @see https://doc.babylonjs.com/how_to/parenting
  8802. * @param node the node ot set as the parent
  8803. * @returns this TransformNode.
  8804. */
  8805. setParent(node: Nullable<Node>): TransformNode;
  8806. private _nonUniformScaling;
  8807. /**
  8808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8809. */
  8810. readonly nonUniformScaling: boolean;
  8811. /** @hidden */
  8812. _updateNonUniformScalingState(value: boolean): boolean;
  8813. /**
  8814. * Attach the current TransformNode to another TransformNode associated with a bone
  8815. * @param bone Bone affecting the TransformNode
  8816. * @param affectedTransformNode TransformNode associated with the bone
  8817. * @returns this object
  8818. */
  8819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8820. /**
  8821. * Detach the transform node if its associated with a bone
  8822. * @returns this object
  8823. */
  8824. detachFromBone(): TransformNode;
  8825. private static _rotationAxisCache;
  8826. /**
  8827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8830. * The passed axis is also normalized.
  8831. * @param axis the axis to rotate around
  8832. * @param amount the amount to rotate in radians
  8833. * @param space Space to rotate in (Default: local)
  8834. * @returns the TransformNode.
  8835. */
  8836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8837. /**
  8838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8840. * The passed axis is also normalized. .
  8841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8842. * @param point the point to rotate around
  8843. * @param axis the axis to rotate around
  8844. * @param amount the amount to rotate in radians
  8845. * @returns the TransformNode
  8846. */
  8847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8848. /**
  8849. * Translates the mesh along the axis vector for the passed distance in the given space.
  8850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8851. * @param axis the axis to translate in
  8852. * @param distance the distance to translate
  8853. * @param space Space to rotate in (Default: local)
  8854. * @returns the TransformNode.
  8855. */
  8856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8857. /**
  8858. * Adds a rotation step to the mesh current rotation.
  8859. * x, y, z are Euler angles expressed in radians.
  8860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8861. * This means this rotation is made in the mesh local space only.
  8862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8864. * ```javascript
  8865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8866. * ```
  8867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8868. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  8869. * @param x Rotation to add
  8870. * @param y Rotation to add
  8871. * @param z Rotation to add
  8872. * @returns the TransformNode.
  8873. */
  8874. addRotation(x: number, y: number, z: number): TransformNode;
  8875. /**
  8876. * @hidden
  8877. */
  8878. protected _getEffectiveParent(): Nullable<Node>;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. protected _afterComputeWorldMatrix(): void;
  8886. /**
  8887. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8888. * @param func callback function to add
  8889. *
  8890. * @returns the TransformNode.
  8891. */
  8892. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8893. /**
  8894. * Removes a registered callback function.
  8895. * @param func callback function to remove
  8896. * @returns the TransformNode.
  8897. */
  8898. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8899. /**
  8900. * Gets the position of the current mesh in camera space
  8901. * @param camera defines the camera to use
  8902. * @returns a position
  8903. */
  8904. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8905. /**
  8906. * Returns the distance from the mesh to the active camera
  8907. * @param camera defines the camera to use
  8908. * @returns the distance
  8909. */
  8910. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8911. /**
  8912. * Clone the current transform node
  8913. * @param name Name of the new clone
  8914. * @param newParent New parent for the clone
  8915. * @param doNotCloneChildren Do not clone children hierarchy
  8916. * @returns the new transform node
  8917. */
  8918. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8919. /**
  8920. * Serializes the objects information.
  8921. * @param currentSerializationObject defines the object to serialize in
  8922. * @returns the serialized object
  8923. */
  8924. serialize(currentSerializationObject?: any): any;
  8925. /**
  8926. * Returns a new TransformNode object parsed from the source provided.
  8927. * @param parsedTransformNode is the source.
  8928. * @param scene the scne the object belongs to
  8929. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8930. * @returns a new TransformNode object parsed from the source provided.
  8931. */
  8932. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8933. /**
  8934. * Get all child-transformNodes of this node
  8935. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  8936. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  8937. * @returns an array of TransformNode
  8938. */
  8939. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8940. /**
  8941. * Releases resources associated with this transform node.
  8942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8944. */
  8945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8946. /**
  8947. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8948. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8949. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8950. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8951. * @returns the current mesh
  8952. */
  8953. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8954. }
  8955. }
  8956. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8957. /**
  8958. * Class used to override all child animations of a given target
  8959. */
  8960. export class AnimationPropertiesOverride {
  8961. /**
  8962. * Gets or sets a value indicating if animation blending must be used
  8963. */
  8964. enableBlending: boolean;
  8965. /**
  8966. * Gets or sets the blending speed to use when enableBlending is true
  8967. */
  8968. blendingSpeed: number;
  8969. /**
  8970. * Gets or sets the default loop mode to use
  8971. */
  8972. loopMode: number;
  8973. }
  8974. }
  8975. declare module "babylonjs/Bones/bone" {
  8976. import { Skeleton } from "babylonjs/Bones/skeleton";
  8977. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8978. import { Nullable } from "babylonjs/types";
  8979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8981. import { Node } from "babylonjs/node";
  8982. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8983. /**
  8984. * Class used to store bone information
  8985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8986. */
  8987. export class Bone extends Node {
  8988. /**
  8989. * defines the bone name
  8990. */
  8991. name: string;
  8992. private static _tmpVecs;
  8993. private static _tmpQuat;
  8994. private static _tmpMats;
  8995. /**
  8996. * Gets the list of child bones
  8997. */
  8998. children: Bone[];
  8999. /** Gets the animations associated with this bone */
  9000. animations: import("babylonjs/Animations/animation").Animation[];
  9001. /**
  9002. * Gets or sets bone length
  9003. */
  9004. length: number;
  9005. /**
  9006. * @hidden Internal only
  9007. * Set this value to map this bone to a different index in the transform matrices
  9008. * Set this value to -1 to exclude the bone from the transform matrices
  9009. */
  9010. _index: Nullable<number>;
  9011. private _skeleton;
  9012. private _localMatrix;
  9013. private _restPose;
  9014. private _baseMatrix;
  9015. private _absoluteTransform;
  9016. private _invertedAbsoluteTransform;
  9017. private _parent;
  9018. private _scalingDeterminant;
  9019. private _worldTransform;
  9020. private _localScaling;
  9021. private _localRotation;
  9022. private _localPosition;
  9023. private _needToDecompose;
  9024. private _needToCompose;
  9025. /** @hidden */
  9026. _linkedTransformNode: Nullable<TransformNode>;
  9027. /** @hidden */
  9028. _waitingTransformNodeId: Nullable<string>;
  9029. /** @hidden */
  9030. /** @hidden */
  9031. _matrix: Matrix;
  9032. /**
  9033. * Create a new bone
  9034. * @param name defines the bone name
  9035. * @param skeleton defines the parent skeleton
  9036. * @param parentBone defines the parent (can be null if the bone is the root)
  9037. * @param localMatrix defines the local matrix
  9038. * @param restPose defines the rest pose matrix
  9039. * @param baseMatrix defines the base matrix
  9040. * @param index defines index of the bone in the hiearchy
  9041. */
  9042. constructor(
  9043. /**
  9044. * defines the bone name
  9045. */
  9046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9047. /**
  9048. * Gets the current object class name.
  9049. * @return the class name
  9050. */
  9051. getClassName(): string;
  9052. /**
  9053. * Gets the parent skeleton
  9054. * @returns a skeleton
  9055. */
  9056. getSkeleton(): Skeleton;
  9057. /**
  9058. * Gets parent bone
  9059. * @returns a bone or null if the bone is the root of the bone hierarchy
  9060. */
  9061. getParent(): Nullable<Bone>;
  9062. /**
  9063. * Returns an array containing the root bones
  9064. * @returns an array containing the root bones
  9065. */
  9066. getChildren(): Array<Bone>;
  9067. /**
  9068. * Sets the parent bone
  9069. * @param parent defines the parent (can be null if the bone is the root)
  9070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9071. */
  9072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9073. /**
  9074. * Gets the local matrix
  9075. * @returns a matrix
  9076. */
  9077. getLocalMatrix(): Matrix;
  9078. /**
  9079. * Gets the base matrix (initial matrix which remains unchanged)
  9080. * @returns a matrix
  9081. */
  9082. getBaseMatrix(): Matrix;
  9083. /**
  9084. * Gets the rest pose matrix
  9085. * @returns a matrix
  9086. */
  9087. getRestPose(): Matrix;
  9088. /**
  9089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9090. */
  9091. getWorldMatrix(): Matrix;
  9092. /**
  9093. * Sets the local matrix to rest pose matrix
  9094. */
  9095. returnToRest(): void;
  9096. /**
  9097. * Gets the inverse of the absolute transform matrix.
  9098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9099. * @returns a matrix
  9100. */
  9101. getInvertedAbsoluteTransform(): Matrix;
  9102. /**
  9103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9104. * @returns a matrix
  9105. */
  9106. getAbsoluteTransform(): Matrix;
  9107. /**
  9108. * Links with the given transform node.
  9109. * The local matrix of this bone is copied from the transform node every frame.
  9110. * @param transformNode defines the transform node to link to
  9111. */
  9112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9113. /** Gets or sets current position (in local space) */
  9114. position: Vector3;
  9115. /** Gets or sets current rotation (in local space) */
  9116. rotation: Vector3;
  9117. /** Gets or sets current rotation quaternion (in local space) */
  9118. rotationQuaternion: Quaternion;
  9119. /** Gets or sets current scaling (in local space) */
  9120. scaling: Vector3;
  9121. /**
  9122. * Gets the animation properties override
  9123. */
  9124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9125. private _decompose;
  9126. private _compose;
  9127. /**
  9128. * Update the base and local matrices
  9129. * @param matrix defines the new base or local matrix
  9130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9131. * @param updateLocalMatrix defines if the local matrix should be updated
  9132. */
  9133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9134. /** @hidden */
  9135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9136. /**
  9137. * Flag the bone as dirty (Forcing it to update everything)
  9138. */
  9139. markAsDirty(): void;
  9140. /** @hidden */
  9141. _markAsDirtyAndCompose(): void;
  9142. private _markAsDirtyAndDecompose;
  9143. /**
  9144. * Translate the bone in local or world space
  9145. * @param vec The amount to translate the bone
  9146. * @param space The space that the translation is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. */
  9149. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9150. /**
  9151. * Set the postion of the bone in local or world space
  9152. * @param position The position to set the bone
  9153. * @param space The space that the position is in
  9154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9155. */
  9156. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9157. /**
  9158. * Set the absolute position of the bone (world space)
  9159. * @param position The position to set the bone
  9160. * @param mesh The mesh that this bone is attached to
  9161. */
  9162. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9163. /**
  9164. * Scale the bone on the x, y and z axes (in local space)
  9165. * @param x The amount to scale the bone on the x axis
  9166. * @param y The amount to scale the bone on the y axis
  9167. * @param z The amount to scale the bone on the z axis
  9168. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9169. */
  9170. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9171. /**
  9172. * Set the bone scaling in local space
  9173. * @param scale defines the scaling vector
  9174. */
  9175. setScale(scale: Vector3): void;
  9176. /**
  9177. * Gets the current scaling in local space
  9178. * @returns the current scaling vector
  9179. */
  9180. getScale(): Vector3;
  9181. /**
  9182. * Gets the current scaling in local space and stores it in a target vector
  9183. * @param result defines the target vector
  9184. */
  9185. getScaleToRef(result: Vector3): void;
  9186. /**
  9187. * Set the yaw, pitch, and roll of the bone in local or world space
  9188. * @param yaw The rotation of the bone on the y axis
  9189. * @param pitch The rotation of the bone on the x axis
  9190. * @param roll The rotation of the bone on the z axis
  9191. * @param space The space that the axes of rotation are in
  9192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9193. */
  9194. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9195. /**
  9196. * Add a rotation to the bone on an axis in local or world space
  9197. * @param axis The axis to rotate the bone on
  9198. * @param amount The amount to rotate the bone
  9199. * @param space The space that the axis is in
  9200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9201. */
  9202. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9203. /**
  9204. * Set the rotation of the bone to a particular axis angle in local or world space
  9205. * @param axis The axis to rotate the bone on
  9206. * @param angle The angle that the bone should be rotated to
  9207. * @param space The space that the axis is in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. */
  9210. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9211. /**
  9212. * Set the euler rotation of the bone in local of world space
  9213. * @param rotation The euler rotation that the bone should be set to
  9214. * @param space The space that the rotation is in
  9215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9216. */
  9217. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9218. /**
  9219. * Set the quaternion rotation of the bone in local of world space
  9220. * @param quat The quaternion rotation that the bone should be set to
  9221. * @param space The space that the rotation is in
  9222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9223. */
  9224. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9225. /**
  9226. * Set the rotation matrix of the bone in local of world space
  9227. * @param rotMat The rotation matrix that the bone should be set to
  9228. * @param space The space that the rotation is in
  9229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9230. */
  9231. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9232. private _rotateWithMatrix;
  9233. private _getNegativeRotationToRef;
  9234. /**
  9235. * Get the position of the bone in local or world space
  9236. * @param space The space that the returned position is in
  9237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9238. * @returns The position of the bone
  9239. */
  9240. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Copy the position of the bone to a vector3 in local or world space
  9243. * @param space The space that the returned position is in
  9244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9245. * @param result The vector3 to copy the position to
  9246. */
  9247. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9248. /**
  9249. * Get the absolute position of the bone (world space)
  9250. * @param mesh The mesh that this bone is attached to
  9251. * @returns The absolute position of the bone
  9252. */
  9253. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9254. /**
  9255. * Copy the absolute position of the bone (world space) to the result param
  9256. * @param mesh The mesh that this bone is attached to
  9257. * @param result The vector3 to copy the absolute position to
  9258. */
  9259. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9260. /**
  9261. * Compute the absolute transforms of this bone and its children
  9262. */
  9263. computeAbsoluteTransforms(): void;
  9264. /**
  9265. * Get the world direction from an axis that is in the local space of the bone
  9266. * @param localAxis The local direction that is used to compute the world direction
  9267. * @param mesh The mesh that this bone is attached to
  9268. * @returns The world direction
  9269. */
  9270. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9271. /**
  9272. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9273. * @param localAxis The local direction that is used to compute the world direction
  9274. * @param mesh The mesh that this bone is attached to
  9275. * @param result The vector3 that the world direction will be copied to
  9276. */
  9277. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9278. /**
  9279. * Get the euler rotation of the bone in local or world space
  9280. * @param space The space that the rotation should be in
  9281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9282. * @returns The euler rotation
  9283. */
  9284. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9285. /**
  9286. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9287. * @param space The space that the rotation should be in
  9288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9289. * @param result The vector3 that the rotation should be copied to
  9290. */
  9291. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9292. /**
  9293. * Get the quaternion rotation of the bone in either local or world space
  9294. * @param space The space that the rotation should be in
  9295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9296. * @returns The quaternion rotation
  9297. */
  9298. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9299. /**
  9300. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9301. * @param space The space that the rotation should be in
  9302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9303. * @param result The quaternion that the rotation should be copied to
  9304. */
  9305. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9306. /**
  9307. * Get the rotation matrix of the bone in local or world space
  9308. * @param space The space that the rotation should be in
  9309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9310. * @returns The rotation matrix
  9311. */
  9312. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9313. /**
  9314. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9315. * @param space The space that the rotation should be in
  9316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9317. * @param result The quaternion that the rotation should be copied to
  9318. */
  9319. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9320. /**
  9321. * Get the world position of a point that is in the local space of the bone
  9322. * @param position The local position
  9323. * @param mesh The mesh that this bone is attached to
  9324. * @returns The world position
  9325. */
  9326. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9327. /**
  9328. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9329. * @param position The local position
  9330. * @param mesh The mesh that this bone is attached to
  9331. * @param result The vector3 that the world position should be copied to
  9332. */
  9333. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9334. /**
  9335. * Get the local position of a point that is in world space
  9336. * @param position The world position
  9337. * @param mesh The mesh that this bone is attached to
  9338. * @returns The local position
  9339. */
  9340. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9341. /**
  9342. * Get the local position of a point that is in world space and copy it to the result param
  9343. * @param position The world position
  9344. * @param mesh The mesh that this bone is attached to
  9345. * @param result The vector3 that the local position should be copied to
  9346. */
  9347. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9348. }
  9349. }
  9350. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9351. import { Nullable } from "babylonjs/types";
  9352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9353. import { Scene } from "babylonjs/scene";
  9354. module "babylonjs/Engines/engine" {
  9355. interface Engine {
  9356. /**
  9357. * Creates a raw texture
  9358. * @param data defines the data to store in the texture
  9359. * @param width defines the width of the texture
  9360. * @param height defines the height of the texture
  9361. * @param format defines the format of the data
  9362. * @param generateMipMaps defines if the engine should generate the mip levels
  9363. * @param invertY defines if data must be stored with Y axis inverted
  9364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9365. * @param compression defines the compression used (null by default)
  9366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9367. * @returns the raw texture inside an InternalTexture
  9368. */
  9369. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9370. /**
  9371. * Update a raw texture
  9372. * @param texture defines the texture to update
  9373. * @param data defines the data to store in the texture
  9374. * @param format defines the format of the data
  9375. * @param invertY defines if data must be stored with Y axis inverted
  9376. */
  9377. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9378. /**
  9379. * Update a raw texture
  9380. * @param texture defines the texture to update
  9381. * @param data defines the data to store in the texture
  9382. * @param format defines the format of the data
  9383. * @param invertY defines if data must be stored with Y axis inverted
  9384. * @param compression defines the compression used (null by default)
  9385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9386. */
  9387. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9388. /**
  9389. * Creates a new raw cube texture
  9390. * @param data defines the array of data to use to create each face
  9391. * @param size defines the size of the textures
  9392. * @param format defines the format of the data
  9393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9394. * @param generateMipMaps defines if the engine should generate the mip levels
  9395. * @param invertY defines if data must be stored with Y axis inverted
  9396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9397. * @param compression defines the compression used (null by default)
  9398. * @returns the cube texture as an InternalTexture
  9399. */
  9400. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9401. /**
  9402. * Update a raw cube texture
  9403. * @param texture defines the texture to udpdate
  9404. * @param data defines the data to store
  9405. * @param format defines the data format
  9406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9407. * @param invertY defines if data must be stored with Y axis inverted
  9408. */
  9409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9410. /**
  9411. * Update a raw cube texture
  9412. * @param texture defines the texture to udpdate
  9413. * @param data defines the data to store
  9414. * @param format defines the data format
  9415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9416. * @param invertY defines if data must be stored with Y axis inverted
  9417. * @param compression defines the compression used (null by default)
  9418. */
  9419. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9420. /**
  9421. * Update a raw cube texture
  9422. * @param texture defines the texture to udpdate
  9423. * @param data defines the data to store
  9424. * @param format defines the data format
  9425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9426. * @param invertY defines if data must be stored with Y axis inverted
  9427. * @param compression defines the compression used (null by default)
  9428. * @param level defines which level of the texture to update
  9429. */
  9430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9431. /**
  9432. * Creates a new raw cube texture from a specified url
  9433. * @param url defines the url where the data is located
  9434. * @param scene defines the current scene
  9435. * @param size defines the size of the textures
  9436. * @param format defines the format of the data
  9437. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9438. * @param noMipmap defines if the engine should avoid generating the mip levels
  9439. * @param callback defines a callback used to extract texture data from loaded data
  9440. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9441. * @param onLoad defines a callback called when texture is loaded
  9442. * @param onError defines a callback called if there is an error
  9443. * @returns the cube texture as an InternalTexture
  9444. */
  9445. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  9446. /**
  9447. * Creates a new raw cube texture from a specified url
  9448. * @param url defines the url where the data is located
  9449. * @param scene defines the current scene
  9450. * @param size defines the size of the textures
  9451. * @param format defines the format of the data
  9452. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9453. * @param noMipmap defines if the engine should avoid generating the mip levels
  9454. * @param callback defines a callback used to extract texture data from loaded data
  9455. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9456. * @param onLoad defines a callback called when texture is loaded
  9457. * @param onError defines a callback called if there is an error
  9458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9459. * @param invertY defines if data must be stored with Y axis inverted
  9460. * @returns the cube texture as an InternalTexture
  9461. */
  9462. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  9463. /**
  9464. * Creates a new raw 3D texture
  9465. * @param data defines the data used to create the texture
  9466. * @param width defines the width of the texture
  9467. * @param height defines the height of the texture
  9468. * @param depth defines the depth of the texture
  9469. * @param format defines the format of the texture
  9470. * @param generateMipMaps defines if the engine must generate mip levels
  9471. * @param invertY defines if data must be stored with Y axis inverted
  9472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9473. * @param compression defines the compressed used (can be null)
  9474. * @param textureType defines the compressed used (can be null)
  9475. * @returns a new raw 3D texture (stored in an InternalTexture)
  9476. */
  9477. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9478. /**
  9479. * Update a raw 3D texture
  9480. * @param texture defines the texture to update
  9481. * @param data defines the data to store
  9482. * @param format defines the data format
  9483. * @param invertY defines if data must be stored with Y axis inverted
  9484. */
  9485. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9486. /**
  9487. * Update a raw 3D texture
  9488. * @param texture defines the texture to update
  9489. * @param data defines the data to store
  9490. * @param format defines the data format
  9491. * @param invertY defines if data must be stored with Y axis inverted
  9492. * @param compression defines the used compression (can be null)
  9493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9494. */
  9495. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9496. }
  9497. }
  9498. }
  9499. declare module "babylonjs/Materials/Textures/rawTexture" {
  9500. import { Scene } from "babylonjs/scene";
  9501. import { Texture } from "babylonjs/Materials/Textures/texture";
  9502. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9503. /**
  9504. * Raw texture can help creating a texture directly from an array of data.
  9505. * This can be super useful if you either get the data from an uncompressed source or
  9506. * if you wish to create your texture pixel by pixel.
  9507. */
  9508. export class RawTexture extends Texture {
  9509. /**
  9510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9511. */
  9512. format: number;
  9513. private _engine;
  9514. /**
  9515. * Instantiates a new RawTexture.
  9516. * Raw texture can help creating a texture directly from an array of data.
  9517. * This can be super useful if you either get the data from an uncompressed source or
  9518. * if you wish to create your texture pixel by pixel.
  9519. * @param data define the array of data to use to create the texture
  9520. * @param width define the width of the texture
  9521. * @param height define the height of the texture
  9522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9523. * @param scene define the scene the texture belongs to
  9524. * @param generateMipMaps define whether mip maps should be generated or not
  9525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9528. */
  9529. constructor(data: ArrayBufferView, width: number, height: number,
  9530. /**
  9531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9532. */
  9533. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9534. /**
  9535. * Updates the texture underlying data.
  9536. * @param data Define the new data of the texture
  9537. */
  9538. update(data: ArrayBufferView): void;
  9539. /**
  9540. * Creates a luminance texture from some data.
  9541. * @param data Define the texture data
  9542. * @param width Define the width of the texture
  9543. * @param height Define the height of the texture
  9544. * @param scene Define the scene the texture belongs to
  9545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9548. * @returns the luminance texture
  9549. */
  9550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9551. /**
  9552. * Creates a luminance alpha texture from some data.
  9553. * @param data Define the texture data
  9554. * @param width Define the width of the texture
  9555. * @param height Define the height of the texture
  9556. * @param scene Define the scene the texture belongs to
  9557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9560. * @returns the luminance alpha texture
  9561. */
  9562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9563. /**
  9564. * Creates an alpha texture from some data.
  9565. * @param data Define the texture data
  9566. * @param width Define the width of the texture
  9567. * @param height Define the height of the texture
  9568. * @param scene Define the scene the texture belongs to
  9569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9572. * @returns the alpha texture
  9573. */
  9574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9575. /**
  9576. * Creates a RGB texture from some data.
  9577. * @param data Define the texture data
  9578. * @param width Define the width of the texture
  9579. * @param height Define the height of the texture
  9580. * @param scene Define the scene the texture belongs to
  9581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9585. * @returns the RGB alpha texture
  9586. */
  9587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9588. /**
  9589. * Creates a RGBA texture from some data.
  9590. * @param data Define the texture data
  9591. * @param width Define the width of the texture
  9592. * @param height Define the height of the texture
  9593. * @param scene Define the scene the texture belongs to
  9594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9598. * @returns the RGBA texture
  9599. */
  9600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9601. /**
  9602. * Creates a R texture from some data.
  9603. * @param data Define the texture data
  9604. * @param width Define the width of the texture
  9605. * @param height Define the height of the texture
  9606. * @param scene Define the scene the texture belongs to
  9607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9611. * @returns the R texture
  9612. */
  9613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9614. }
  9615. }
  9616. declare module "babylonjs/Animations/runtimeAnimation" {
  9617. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9618. import { Animatable } from "babylonjs/Animations/animatable";
  9619. import { Scene } from "babylonjs/scene";
  9620. /**
  9621. * Defines a runtime animation
  9622. */
  9623. export class RuntimeAnimation {
  9624. private _events;
  9625. /**
  9626. * The current frame of the runtime animation
  9627. */
  9628. private _currentFrame;
  9629. /**
  9630. * The animation used by the runtime animation
  9631. */
  9632. private _animation;
  9633. /**
  9634. * The target of the runtime animation
  9635. */
  9636. private _target;
  9637. /**
  9638. * The initiating animatable
  9639. */
  9640. private _host;
  9641. /**
  9642. * The original value of the runtime animation
  9643. */
  9644. private _originalValue;
  9645. /**
  9646. * The original blend value of the runtime animation
  9647. */
  9648. private _originalBlendValue;
  9649. /**
  9650. * The offsets cache of the runtime animation
  9651. */
  9652. private _offsetsCache;
  9653. /**
  9654. * The high limits cache of the runtime animation
  9655. */
  9656. private _highLimitsCache;
  9657. /**
  9658. * Specifies if the runtime animation has been stopped
  9659. */
  9660. private _stopped;
  9661. /**
  9662. * The blending factor of the runtime animation
  9663. */
  9664. private _blendingFactor;
  9665. /**
  9666. * The BabylonJS scene
  9667. */
  9668. private _scene;
  9669. /**
  9670. * The current value of the runtime animation
  9671. */
  9672. private _currentValue;
  9673. /** @hidden */
  9674. _animationState: _IAnimationState;
  9675. /**
  9676. * The active target of the runtime animation
  9677. */
  9678. private _activeTargets;
  9679. private _currentActiveTarget;
  9680. private _directTarget;
  9681. /**
  9682. * The target path of the runtime animation
  9683. */
  9684. private _targetPath;
  9685. /**
  9686. * The weight of the runtime animation
  9687. */
  9688. private _weight;
  9689. /**
  9690. * The ratio offset of the runtime animation
  9691. */
  9692. private _ratioOffset;
  9693. /**
  9694. * The previous delay of the runtime animation
  9695. */
  9696. private _previousDelay;
  9697. /**
  9698. * The previous ratio of the runtime animation
  9699. */
  9700. private _previousRatio;
  9701. private _enableBlending;
  9702. private _keys;
  9703. private _minFrame;
  9704. private _maxFrame;
  9705. private _minValue;
  9706. private _maxValue;
  9707. private _targetIsArray;
  9708. /**
  9709. * Gets the current frame of the runtime animation
  9710. */
  9711. readonly currentFrame: number;
  9712. /**
  9713. * Gets the weight of the runtime animation
  9714. */
  9715. readonly weight: number;
  9716. /**
  9717. * Gets the current value of the runtime animation
  9718. */
  9719. readonly currentValue: any;
  9720. /**
  9721. * Gets the target path of the runtime animation
  9722. */
  9723. readonly targetPath: string;
  9724. /**
  9725. * Gets the actual target of the runtime animation
  9726. */
  9727. readonly target: any;
  9728. /** @hidden */
  9729. _onLoop: () => void;
  9730. /**
  9731. * Create a new RuntimeAnimation object
  9732. * @param target defines the target of the animation
  9733. * @param animation defines the source animation object
  9734. * @param scene defines the hosting scene
  9735. * @param host defines the initiating Animatable
  9736. */
  9737. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9738. private _preparePath;
  9739. /**
  9740. * Gets the animation from the runtime animation
  9741. */
  9742. readonly animation: Animation;
  9743. /**
  9744. * Resets the runtime animation to the beginning
  9745. * @param restoreOriginal defines whether to restore the target property to the original value
  9746. */
  9747. reset(restoreOriginal?: boolean): void;
  9748. /**
  9749. * Specifies if the runtime animation is stopped
  9750. * @returns Boolean specifying if the runtime animation is stopped
  9751. */
  9752. isStopped(): boolean;
  9753. /**
  9754. * Disposes of the runtime animation
  9755. */
  9756. dispose(): void;
  9757. /**
  9758. * Apply the interpolated value to the target
  9759. * @param currentValue defines the value computed by the animation
  9760. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9761. */
  9762. setValue(currentValue: any, weight: number): void;
  9763. private _getOriginalValues;
  9764. private _setValue;
  9765. /**
  9766. * Gets the loop pmode of the runtime animation
  9767. * @returns Loop Mode
  9768. */
  9769. private _getCorrectLoopMode;
  9770. /**
  9771. * Move the current animation to a given frame
  9772. * @param frame defines the frame to move to
  9773. */
  9774. goToFrame(frame: number): void;
  9775. /**
  9776. * @hidden Internal use only
  9777. */
  9778. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9779. /**
  9780. * Execute the current animation
  9781. * @param delay defines the delay to add to the current frame
  9782. * @param from defines the lower bound of the animation range
  9783. * @param to defines the upper bound of the animation range
  9784. * @param loop defines if the current animation must loop
  9785. * @param speedRatio defines the current speed ratio
  9786. * @param weight defines the weight of the animation (default is -1 so no weight)
  9787. * @param onLoop optional callback called when animation loops
  9788. * @returns a boolean indicating if the animation is running
  9789. */
  9790. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9791. }
  9792. }
  9793. declare module "babylonjs/Animations/animatable" {
  9794. import { Animation } from "babylonjs/Animations/animation";
  9795. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9796. import { Nullable } from "babylonjs/types";
  9797. import { Observable } from "babylonjs/Misc/observable";
  9798. import { Scene } from "babylonjs/scene";
  9799. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9800. import { Node } from "babylonjs/node";
  9801. /**
  9802. * Class used to store an actual running animation
  9803. */
  9804. export class Animatable {
  9805. /** defines the target object */
  9806. target: any;
  9807. /** defines the starting frame number (default is 0) */
  9808. fromFrame: number;
  9809. /** defines the ending frame number (default is 100) */
  9810. toFrame: number;
  9811. /** defines if the animation must loop (default is false) */
  9812. loopAnimation: boolean;
  9813. /** defines a callback to call when animation ends if it is not looping */
  9814. onAnimationEnd?: (() => void) | null | undefined;
  9815. /** defines a callback to call when animation loops */
  9816. onAnimationLoop?: (() => void) | null | undefined;
  9817. private _localDelayOffset;
  9818. private _pausedDelay;
  9819. private _runtimeAnimations;
  9820. private _paused;
  9821. private _scene;
  9822. private _speedRatio;
  9823. private _weight;
  9824. private _syncRoot;
  9825. /**
  9826. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9827. * This will only apply for non looping animation (default is true)
  9828. */
  9829. disposeOnEnd: boolean;
  9830. /**
  9831. * Gets a boolean indicating if the animation has started
  9832. */
  9833. animationStarted: boolean;
  9834. /**
  9835. * Observer raised when the animation ends
  9836. */
  9837. onAnimationEndObservable: Observable<Animatable>;
  9838. /**
  9839. * Observer raised when the animation loops
  9840. */
  9841. onAnimationLoopObservable: Observable<Animatable>;
  9842. /**
  9843. * Gets the root Animatable used to synchronize and normalize animations
  9844. */
  9845. readonly syncRoot: Nullable<Animatable>;
  9846. /**
  9847. * Gets the current frame of the first RuntimeAnimation
  9848. * Used to synchronize Animatables
  9849. */
  9850. readonly masterFrame: number;
  9851. /**
  9852. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9853. */
  9854. weight: number;
  9855. /**
  9856. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9857. */
  9858. speedRatio: number;
  9859. /**
  9860. * Creates a new Animatable
  9861. * @param scene defines the hosting scene
  9862. * @param target defines the target object
  9863. * @param fromFrame defines the starting frame number (default is 0)
  9864. * @param toFrame defines the ending frame number (default is 100)
  9865. * @param loopAnimation defines if the animation must loop (default is false)
  9866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9868. * @param animations defines a group of animation to add to the new Animatable
  9869. * @param onAnimationLoop defines a callback to call when animation loops
  9870. */
  9871. constructor(scene: Scene,
  9872. /** defines the target object */
  9873. target: any,
  9874. /** defines the starting frame number (default is 0) */
  9875. fromFrame?: number,
  9876. /** defines the ending frame number (default is 100) */
  9877. toFrame?: number,
  9878. /** defines if the animation must loop (default is false) */
  9879. loopAnimation?: boolean, speedRatio?: number,
  9880. /** defines a callback to call when animation ends if it is not looping */
  9881. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9882. /** defines a callback to call when animation loops */
  9883. onAnimationLoop?: (() => void) | null | undefined);
  9884. /**
  9885. * Synchronize and normalize current Animatable with a source Animatable
  9886. * This is useful when using animation weights and when animations are not of the same length
  9887. * @param root defines the root Animatable to synchronize with
  9888. * @returns the current Animatable
  9889. */
  9890. syncWith(root: Animatable): Animatable;
  9891. /**
  9892. * Gets the list of runtime animations
  9893. * @returns an array of RuntimeAnimation
  9894. */
  9895. getAnimations(): RuntimeAnimation[];
  9896. /**
  9897. * Adds more animations to the current animatable
  9898. * @param target defines the target of the animations
  9899. * @param animations defines the new animations to add
  9900. */
  9901. appendAnimations(target: any, animations: Animation[]): void;
  9902. /**
  9903. * Gets the source animation for a specific property
  9904. * @param property defines the propertyu to look for
  9905. * @returns null or the source animation for the given property
  9906. */
  9907. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9908. /**
  9909. * Gets the runtime animation for a specific property
  9910. * @param property defines the propertyu to look for
  9911. * @returns null or the runtime animation for the given property
  9912. */
  9913. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9914. /**
  9915. * Resets the animatable to its original state
  9916. */
  9917. reset(): void;
  9918. /**
  9919. * Allows the animatable to blend with current running animations
  9920. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9921. * @param blendingSpeed defines the blending speed to use
  9922. */
  9923. enableBlending(blendingSpeed: number): void;
  9924. /**
  9925. * Disable animation blending
  9926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9927. */
  9928. disableBlending(): void;
  9929. /**
  9930. * Jump directly to a given frame
  9931. * @param frame defines the frame to jump to
  9932. */
  9933. goToFrame(frame: number): void;
  9934. /**
  9935. * Pause the animation
  9936. */
  9937. pause(): void;
  9938. /**
  9939. * Restart the animation
  9940. */
  9941. restart(): void;
  9942. private _raiseOnAnimationEnd;
  9943. /**
  9944. * Stop and delete the current animation
  9945. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9946. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  9947. */
  9948. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9949. /**
  9950. * Wait asynchronously for the animation to end
  9951. * @returns a promise which will be fullfilled when the animation ends
  9952. */
  9953. waitAsync(): Promise<Animatable>;
  9954. /** @hidden */
  9955. _animate(delay: number): boolean;
  9956. }
  9957. module "babylonjs/scene" {
  9958. interface Scene {
  9959. /** @hidden */
  9960. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9961. /** @hidden */
  9962. _processLateAnimationBindingsForMatrices(holder: {
  9963. totalWeight: number;
  9964. animations: RuntimeAnimation[];
  9965. originalValue: Matrix;
  9966. }): any;
  9967. /** @hidden */
  9968. _processLateAnimationBindingsForQuaternions(holder: {
  9969. totalWeight: number;
  9970. animations: RuntimeAnimation[];
  9971. originalValue: Quaternion;
  9972. }, refQuaternion: Quaternion): Quaternion;
  9973. /** @hidden */
  9974. _processLateAnimationBindings(): void;
  9975. /**
  9976. * Will start the animation sequence of a given target
  9977. * @param target defines the target
  9978. * @param from defines from which frame should animation start
  9979. * @param to defines until which frame should animation run.
  9980. * @param weight defines the weight to apply to the animation (1.0 by default)
  9981. * @param loop defines if the animation loops
  9982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9983. * @param onAnimationEnd defines the function to be executed when the animation ends
  9984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9986. * @param onAnimationLoop defines the callback to call when an animation loops
  9987. * @returns the animatable object created for this animation
  9988. */
  9989. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9990. /**
  9991. * Will start the animation sequence of a given target
  9992. * @param target defines the target
  9993. * @param from defines from which frame should animation start
  9994. * @param to defines until which frame should animation run.
  9995. * @param loop defines if the animation loops
  9996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9997. * @param onAnimationEnd defines the function to be executed when the animation ends
  9998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9999. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10000. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  10001. * @param onAnimationLoop defines the callback to call when an animation loops
  10002. * @returns the animatable object created for this animation
  10003. */
  10004. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10005. /**
  10006. * Will start the animation sequence of a given target and its hierarchy
  10007. * @param target defines the target
  10008. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  10009. * @param from defines from which frame should animation start
  10010. * @param to defines until which frame should animation run.
  10011. * @param loop defines if the animation loops
  10012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10013. * @param onAnimationEnd defines the function to be executed when the animation ends
  10014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10016. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10017. * @param onAnimationLoop defines the callback to call when an animation loops
  10018. * @returns the list of created animatables
  10019. */
  10020. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  10021. /**
  10022. * Begin a new animation on a given node
  10023. * @param target defines the target where the animation will take place
  10024. * @param animations defines the list of animations to start
  10025. * @param from defines the initial value
  10026. * @param to defines the final value
  10027. * @param loop defines if you want animation to loop (off by default)
  10028. * @param speedRatio defines the speed ratio to apply to all animations
  10029. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10030. * @param onAnimationLoop defines the callback to call when an animation loops
  10031. * @returns the list of created animatables
  10032. */
  10033. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10034. /**
  10035. * Begin a new animation on a given node and its hierarchy
  10036. * @param target defines the root node where the animation will take place
  10037. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  10038. * @param animations defines the list of animations to start
  10039. * @param from defines the initial value
  10040. * @param to defines the final value
  10041. * @param loop defines if you want animation to loop (off by default)
  10042. * @param speedRatio defines the speed ratio to apply to all animations
  10043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10044. * @param onAnimationLoop defines the callback to call when an animation loops
  10045. * @returns the list of animatables created for all nodes
  10046. */
  10047. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10048. /**
  10049. * Gets the animatable associated with a specific target
  10050. * @param target defines the target of the animatable
  10051. * @returns the required animatable if found
  10052. */
  10053. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10054. /**
  10055. * Gets all animatables associated with a given target
  10056. * @param target defines the target to look animatables for
  10057. * @returns an array of Animatables
  10058. */
  10059. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10060. /**
  10061. * Stops and removes all animations that have been applied to the scene
  10062. */
  10063. stopAllAnimations(): void;
  10064. }
  10065. }
  10066. module "babylonjs/Bones/bone" {
  10067. interface Bone {
  10068. /**
  10069. * Copy an animation range from another bone
  10070. * @param source defines the source bone
  10071. * @param rangeName defines the range name to copy
  10072. * @param frameOffset defines the frame offset
  10073. * @param rescaleAsRequired defines if rescaling must be applied if required
  10074. * @param skelDimensionsRatio defines the scaling ratio
  10075. * @returns true if operation was successful
  10076. */
  10077. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10078. }
  10079. }
  10080. }
  10081. declare module "babylonjs/Bones/skeleton" {
  10082. import { Bone } from "babylonjs/Bones/bone";
  10083. import { IAnimatable } from "babylonjs/Misc/tools";
  10084. import { Observable } from "babylonjs/Misc/observable";
  10085. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10086. import { Scene } from "babylonjs/scene";
  10087. import { Nullable } from "babylonjs/types";
  10088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10090. import { Animatable } from "babylonjs/Animations/animatable";
  10091. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10092. import { Animation } from "babylonjs/Animations/animation";
  10093. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10094. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10095. /**
  10096. * Class used to handle skinning animations
  10097. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10098. */
  10099. export class Skeleton implements IAnimatable {
  10100. /** defines the skeleton name */
  10101. name: string;
  10102. /** defines the skeleton Id */
  10103. id: string;
  10104. /**
  10105. * Defines the list of child bones
  10106. */
  10107. bones: Bone[];
  10108. /**
  10109. * Defines an estimate of the dimension of the skeleton at rest
  10110. */
  10111. dimensionsAtRest: Vector3;
  10112. /**
  10113. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10114. */
  10115. needInitialSkinMatrix: boolean;
  10116. /**
  10117. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10118. */
  10119. overrideMesh: Nullable<AbstractMesh>;
  10120. /**
  10121. * Gets the list of animations attached to this skeleton
  10122. */
  10123. animations: Array<Animation>;
  10124. private _scene;
  10125. private _isDirty;
  10126. private _transformMatrices;
  10127. private _transformMatrixTexture;
  10128. private _meshesWithPoseMatrix;
  10129. private _animatables;
  10130. private _identity;
  10131. private _synchronizedWithMesh;
  10132. private _ranges;
  10133. private _lastAbsoluteTransformsUpdateId;
  10134. private _canUseTextureForBones;
  10135. private _uniqueId;
  10136. /** @hidden */
  10137. _numBonesWithLinkedTransformNode: number;
  10138. /** @hidden */
  10139. _hasWaitingData: Nullable<boolean>;
  10140. /**
  10141. * Specifies if the skeleton should be serialized
  10142. */
  10143. doNotSerialize: boolean;
  10144. private _useTextureToStoreBoneMatrices;
  10145. /**
  10146. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10147. * Please note that this option is not available if the hardware does not support it
  10148. */
  10149. useTextureToStoreBoneMatrices: boolean;
  10150. private _animationPropertiesOverride;
  10151. /**
  10152. * Gets or sets the animation properties override
  10153. */
  10154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10155. /**
  10156. * List of inspectable custom properties (used by the Inspector)
  10157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10158. */
  10159. inspectableCustomProperties: IInspectable[];
  10160. /**
  10161. * An observable triggered before computing the skeleton's matrices
  10162. */
  10163. onBeforeComputeObservable: Observable<Skeleton>;
  10164. /**
  10165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10166. */
  10167. readonly isUsingTextureForMatrices: boolean;
  10168. /**
  10169. * Gets the unique ID of this skeleton
  10170. */
  10171. readonly uniqueId: number;
  10172. /**
  10173. * Creates a new skeleton
  10174. * @param name defines the skeleton name
  10175. * @param id defines the skeleton Id
  10176. * @param scene defines the hosting scene
  10177. */
  10178. constructor(
  10179. /** defines the skeleton name */
  10180. name: string,
  10181. /** defines the skeleton Id */
  10182. id: string, scene: Scene);
  10183. /**
  10184. * Gets the current object class name.
  10185. * @return the class name
  10186. */
  10187. getClassName(): string;
  10188. /**
  10189. * Returns an array containing the root bones
  10190. * @returns an array containing the root bones
  10191. */
  10192. getChildren(): Array<Bone>;
  10193. /**
  10194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10196. * @returns a Float32Array containing matrices data
  10197. */
  10198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10199. /**
  10200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10202. * @returns a raw texture containing the data
  10203. */
  10204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10205. /**
  10206. * Gets the current hosting scene
  10207. * @returns a scene object
  10208. */
  10209. getScene(): Scene;
  10210. /**
  10211. * Gets a string representing the current skeleton data
  10212. * @param fullDetails defines a boolean indicating if we want a verbose version
  10213. * @returns a string representing the current skeleton data
  10214. */
  10215. toString(fullDetails?: boolean): string;
  10216. /**
  10217. * Get bone's index searching by name
  10218. * @param name defines bone's name to search for
  10219. * @return the indice of the bone. Returns -1 if not found
  10220. */
  10221. getBoneIndexByName(name: string): number;
  10222. /**
  10223. * Creater a new animation range
  10224. * @param name defines the name of the range
  10225. * @param from defines the start key
  10226. * @param to defines the end key
  10227. */
  10228. createAnimationRange(name: string, from: number, to: number): void;
  10229. /**
  10230. * Delete a specific animation range
  10231. * @param name defines the name of the range
  10232. * @param deleteFrames defines if frames must be removed as well
  10233. */
  10234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10235. /**
  10236. * Gets a specific animation range
  10237. * @param name defines the name of the range to look for
  10238. * @returns the requested animation range or null if not found
  10239. */
  10240. getAnimationRange(name: string): Nullable<AnimationRange>;
  10241. /**
  10242. * Gets the list of all animation ranges defined on this skeleton
  10243. * @returns an array
  10244. */
  10245. getAnimationRanges(): Nullable<AnimationRange>[];
  10246. /**
  10247. * Copy animation range from a source skeleton.
  10248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10249. * @param source defines the source skeleton
  10250. * @param name defines the name of the range to copy
  10251. * @param rescaleAsRequired defines if rescaling must be applied if required
  10252. * @returns true if operation was successful
  10253. */
  10254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10255. /**
  10256. * Forces the skeleton to go to rest pose
  10257. */
  10258. returnToRest(): void;
  10259. private _getHighestAnimationFrame;
  10260. /**
  10261. * Begin a specific animation range
  10262. * @param name defines the name of the range to start
  10263. * @param loop defines if looping must be turned on (false by default)
  10264. * @param speedRatio defines the speed ratio to apply (1 by default)
  10265. * @param onAnimationEnd defines a callback which will be called when animation will end
  10266. * @returns a new animatable
  10267. */
  10268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10269. /** @hidden */
  10270. _markAsDirty(): void;
  10271. /** @hidden */
  10272. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10273. /** @hidden */
  10274. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10275. private _computeTransformMatrices;
  10276. /**
  10277. * Build all resources required to render a skeleton
  10278. */
  10279. prepare(): void;
  10280. /**
  10281. * Gets the list of animatables currently running for this skeleton
  10282. * @returns an array of animatables
  10283. */
  10284. getAnimatables(): IAnimatable[];
  10285. /**
  10286. * Clone the current skeleton
  10287. * @param name defines the name of the new skeleton
  10288. * @param id defines the id of the new skeleton
  10289. * @returns the new skeleton
  10290. */
  10291. clone(name: string, id: string): Skeleton;
  10292. /**
  10293. * Enable animation blending for this skeleton
  10294. * @param blendingSpeed defines the blending speed to apply
  10295. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10296. */
  10297. enableBlending(blendingSpeed?: number): void;
  10298. /**
  10299. * Releases all resources associated with the current skeleton
  10300. */
  10301. dispose(): void;
  10302. /**
  10303. * Serialize the skeleton in a JSON object
  10304. * @returns a JSON object
  10305. */
  10306. serialize(): any;
  10307. /**
  10308. * Creates a new skeleton from serialized data
  10309. * @param parsedSkeleton defines the serialized data
  10310. * @param scene defines the hosting scene
  10311. * @returns a new skeleton
  10312. */
  10313. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10314. /**
  10315. * Compute all node absolute transforms
  10316. * @param forceUpdate defines if computation must be done even if cache is up to date
  10317. */
  10318. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10319. /**
  10320. * Gets the root pose matrix
  10321. * @returns a matrix
  10322. */
  10323. getPoseMatrix(): Nullable<Matrix>;
  10324. /**
  10325. * Sorts bones per internal index
  10326. */
  10327. sortBones(): void;
  10328. private _sortBones;
  10329. }
  10330. }
  10331. declare module "babylonjs/Morph/morphTarget" {
  10332. import { IAnimatable } from "babylonjs/Misc/tools";
  10333. import { Observable } from "babylonjs/Misc/observable";
  10334. import { Nullable, FloatArray } from "babylonjs/types";
  10335. import { Scene } from "babylonjs/scene";
  10336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10337. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10338. /**
  10339. * Defines a target to use with MorphTargetManager
  10340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10341. */
  10342. export class MorphTarget implements IAnimatable {
  10343. /** defines the name of the target */
  10344. name: string;
  10345. /**
  10346. * Gets or sets the list of animations
  10347. */
  10348. animations: import("babylonjs/Animations/animation").Animation[];
  10349. private _scene;
  10350. private _positions;
  10351. private _normals;
  10352. private _tangents;
  10353. private _uvs;
  10354. private _influence;
  10355. /**
  10356. * Observable raised when the influence changes
  10357. */
  10358. onInfluenceChanged: Observable<boolean>;
  10359. /** @hidden */
  10360. _onDataLayoutChanged: Observable<void>;
  10361. /**
  10362. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10363. */
  10364. influence: number;
  10365. /**
  10366. * Gets or sets the id of the morph Target
  10367. */
  10368. id: string;
  10369. private _animationPropertiesOverride;
  10370. /**
  10371. * Gets or sets the animation properties override
  10372. */
  10373. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10374. /**
  10375. * Creates a new MorphTarget
  10376. * @param name defines the name of the target
  10377. * @param influence defines the influence to use
  10378. * @param scene defines the scene the morphtarget belongs to
  10379. */
  10380. constructor(
  10381. /** defines the name of the target */
  10382. name: string, influence?: number, scene?: Nullable<Scene>);
  10383. /**
  10384. * Gets a boolean defining if the target contains position data
  10385. */
  10386. readonly hasPositions: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains normal data
  10389. */
  10390. readonly hasNormals: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains tangent data
  10393. */
  10394. readonly hasTangents: boolean;
  10395. /**
  10396. * Gets a boolean defining if the target contains texture coordinates data
  10397. */
  10398. readonly hasUVs: boolean;
  10399. /**
  10400. * Affects position data to this target
  10401. * @param data defines the position data to use
  10402. */
  10403. setPositions(data: Nullable<FloatArray>): void;
  10404. /**
  10405. * Gets the position data stored in this target
  10406. * @returns a FloatArray containing the position data (or null if not present)
  10407. */
  10408. getPositions(): Nullable<FloatArray>;
  10409. /**
  10410. * Affects normal data to this target
  10411. * @param data defines the normal data to use
  10412. */
  10413. setNormals(data: Nullable<FloatArray>): void;
  10414. /**
  10415. * Gets the normal data stored in this target
  10416. * @returns a FloatArray containing the normal data (or null if not present)
  10417. */
  10418. getNormals(): Nullable<FloatArray>;
  10419. /**
  10420. * Affects tangent data to this target
  10421. * @param data defines the tangent data to use
  10422. */
  10423. setTangents(data: Nullable<FloatArray>): void;
  10424. /**
  10425. * Gets the tangent data stored in this target
  10426. * @returns a FloatArray containing the tangent data (or null if not present)
  10427. */
  10428. getTangents(): Nullable<FloatArray>;
  10429. /**
  10430. * Affects texture coordinates data to this target
  10431. * @param data defines the texture coordinates data to use
  10432. */
  10433. setUVs(data: Nullable<FloatArray>): void;
  10434. /**
  10435. * Gets the texture coordinates data stored in this target
  10436. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10437. */
  10438. getUVs(): Nullable<FloatArray>;
  10439. /**
  10440. * Serializes the current target into a Serialization object
  10441. * @returns the serialized object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Returns the string "MorphTarget"
  10446. * @returns "MorphTarget"
  10447. */
  10448. getClassName(): string;
  10449. /**
  10450. * Creates a new target from serialized data
  10451. * @param serializationObject defines the serialized data to use
  10452. * @returns a new MorphTarget
  10453. */
  10454. static Parse(serializationObject: any): MorphTarget;
  10455. /**
  10456. * Creates a MorphTarget from mesh data
  10457. * @param mesh defines the source mesh
  10458. * @param name defines the name to use for the new target
  10459. * @param influence defines the influence to attach to the target
  10460. * @returns a new MorphTarget
  10461. */
  10462. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10463. }
  10464. }
  10465. declare module "babylonjs/Morph/morphTargetManager" {
  10466. import { Nullable } from "babylonjs/types";
  10467. import { Scene } from "babylonjs/scene";
  10468. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10469. /**
  10470. * This class is used to deform meshes using morphing between different targets
  10471. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10472. */
  10473. export class MorphTargetManager {
  10474. private _targets;
  10475. private _targetInfluenceChangedObservers;
  10476. private _targetDataLayoutChangedObservers;
  10477. private _activeTargets;
  10478. private _scene;
  10479. private _influences;
  10480. private _supportsNormals;
  10481. private _supportsTangents;
  10482. private _supportsUVs;
  10483. private _vertexCount;
  10484. private _uniqueId;
  10485. private _tempInfluences;
  10486. /**
  10487. * Gets or sets a boolean indicating if normals must be morphed
  10488. */
  10489. enableNormalMorphing: boolean;
  10490. /**
  10491. * Gets or sets a boolean indicating if tangents must be morphed
  10492. */
  10493. enableTangentMorphing: boolean;
  10494. /**
  10495. * Gets or sets a boolean indicating if UV must be morphed
  10496. */
  10497. enableUVMorphing: boolean;
  10498. /**
  10499. * Creates a new MorphTargetManager
  10500. * @param scene defines the current scene
  10501. */
  10502. constructor(scene?: Nullable<Scene>);
  10503. /**
  10504. * Gets the unique ID of this manager
  10505. */
  10506. readonly uniqueId: number;
  10507. /**
  10508. * Gets the number of vertices handled by this manager
  10509. */
  10510. readonly vertexCount: number;
  10511. /**
  10512. * Gets a boolean indicating if this manager supports morphing of normals
  10513. */
  10514. readonly supportsNormals: boolean;
  10515. /**
  10516. * Gets a boolean indicating if this manager supports morphing of tangents
  10517. */
  10518. readonly supportsTangents: boolean;
  10519. /**
  10520. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10521. */
  10522. readonly supportsUVs: boolean;
  10523. /**
  10524. * Gets the number of targets stored in this manager
  10525. */
  10526. readonly numTargets: number;
  10527. /**
  10528. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10529. */
  10530. readonly numInfluencers: number;
  10531. /**
  10532. * Gets the list of influences (one per target)
  10533. */
  10534. readonly influences: Float32Array;
  10535. /**
  10536. * Gets the active target at specified index. An active target is a target with an influence > 0
  10537. * @param index defines the index to check
  10538. * @returns the requested target
  10539. */
  10540. getActiveTarget(index: number): MorphTarget;
  10541. /**
  10542. * Gets the target at specified index
  10543. * @param index defines the index to check
  10544. * @returns the requested target
  10545. */
  10546. getTarget(index: number): MorphTarget;
  10547. /**
  10548. * Add a new target to this manager
  10549. * @param target defines the target to add
  10550. */
  10551. addTarget(target: MorphTarget): void;
  10552. /**
  10553. * Removes a target from the manager
  10554. * @param target defines the target to remove
  10555. */
  10556. removeTarget(target: MorphTarget): void;
  10557. /**
  10558. * Serializes the current manager into a Serialization object
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. private _syncActiveTargets;
  10563. /**
  10564. * Syncrhonize the targets with all the meshes using this morph target manager
  10565. */
  10566. synchronize(): void;
  10567. /**
  10568. * Creates a new MorphTargetManager from serialized data
  10569. * @param serializationObject defines the serialized data
  10570. * @param scene defines the hosting scene
  10571. * @returns the new MorphTargetManager
  10572. */
  10573. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10574. }
  10575. }
  10576. declare module "babylonjs/sceneComponent" {
  10577. import { Scene } from "babylonjs/scene";
  10578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10580. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10581. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10582. import { Nullable } from "babylonjs/types";
  10583. import { Camera } from "babylonjs/Cameras/camera";
  10584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10586. import { AbstractScene } from "babylonjs/abstractScene";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_DEPTHRENDERER: string;
  10601. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10602. static readonly NAME_SPRITE: string;
  10603. static readonly NAME_OUTLINERENDERER: string;
  10604. static readonly NAME_PROCEDURALTEXTURE: string;
  10605. static readonly NAME_SHADOWGENERATOR: string;
  10606. static readonly NAME_OCTREE: string;
  10607. static readonly NAME_PHYSICSENGINE: string;
  10608. static readonly NAME_AUDIO: string;
  10609. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10610. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10611. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10612. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10614. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10615. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10616. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10617. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10618. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10619. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10620. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10622. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10623. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10624. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10628. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10629. static readonly STEP_AFTERRENDER_AUDIO: number;
  10630. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10631. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10632. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10633. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10634. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_POINTERMOVE_SPRITE: number;
  10636. static readonly STEP_POINTERDOWN_SPRITE: number;
  10637. static readonly STEP_POINTERUP_SPRITE: number;
  10638. }
  10639. /**
  10640. * This represents a scene component.
  10641. *
  10642. * This is used to decouple the dependency the scene is having on the different workloads like
  10643. * layers, post processes...
  10644. */
  10645. export interface ISceneComponent {
  10646. /**
  10647. * The name of the component. Each component must have a unique name.
  10648. */
  10649. name: string;
  10650. /**
  10651. * The scene the component belongs to.
  10652. */
  10653. scene: Scene;
  10654. /**
  10655. * Register the component to one instance of a scene.
  10656. */
  10657. register(): void;
  10658. /**
  10659. * Rebuilds the elements related to this component in case of
  10660. * context lost for instance.
  10661. */
  10662. rebuild(): void;
  10663. /**
  10664. * Disposes the component and the associated ressources.
  10665. */
  10666. dispose(): void;
  10667. }
  10668. /**
  10669. * This represents a SERIALIZABLE scene component.
  10670. *
  10671. * This extends Scene Component to add Serialization methods on top.
  10672. */
  10673. export interface ISceneSerializableComponent extends ISceneComponent {
  10674. /**
  10675. * Adds all the elements from the container to the scene
  10676. * @param container the container holding the elements
  10677. */
  10678. addFromContainer(container: AbstractScene): void;
  10679. /**
  10680. * Removes all the elements in the container from the scene
  10681. * @param container contains the elements to remove
  10682. * @param dispose if the removed element should be disposed (default: false)
  10683. */
  10684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10685. /**
  10686. * Serializes the component data to the specified json object
  10687. * @param serializationObject The object to serialize to
  10688. */
  10689. serialize(serializationObject: any): void;
  10690. }
  10691. /**
  10692. * Strong typing of a Mesh related stage step action
  10693. */
  10694. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10695. /**
  10696. * Strong typing of a Evaluate Sub Mesh related stage step action
  10697. */
  10698. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10699. /**
  10700. * Strong typing of a Active Mesh related stage step action
  10701. */
  10702. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10703. /**
  10704. * Strong typing of a Camera related stage step action
  10705. */
  10706. export type CameraStageAction = (camera: Camera) => void;
  10707. /**
  10708. * Strong typing of a Camera Frame buffer related stage step action
  10709. */
  10710. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10711. /**
  10712. * Strong typing of a Render Target related stage step action
  10713. */
  10714. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10715. /**
  10716. * Strong typing of a RenderingGroup related stage step action
  10717. */
  10718. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10719. /**
  10720. * Strong typing of a Mesh Render related stage step action
  10721. */
  10722. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10723. /**
  10724. * Strong typing of a simple stage step action
  10725. */
  10726. export type SimpleStageAction = () => void;
  10727. /**
  10728. * Strong typing of a render target action.
  10729. */
  10730. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10731. /**
  10732. * Strong typing of a pointer move action.
  10733. */
  10734. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10735. /**
  10736. * Strong typing of a pointer up/down action.
  10737. */
  10738. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10739. /**
  10740. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10741. * @hidden
  10742. */
  10743. export class Stage<T extends Function> extends Array<{
  10744. index: number;
  10745. component: ISceneComponent;
  10746. action: T;
  10747. }> {
  10748. /**
  10749. * Hide ctor from the rest of the world.
  10750. * @param items The items to add.
  10751. */
  10752. private constructor();
  10753. /**
  10754. * Creates a new Stage.
  10755. * @returns A new instance of a Stage
  10756. */
  10757. static Create<T extends Function>(): Stage<T>;
  10758. /**
  10759. * Registers a step in an ordered way in the targeted stage.
  10760. * @param index Defines the position to register the step in
  10761. * @param component Defines the component attached to the step
  10762. * @param action Defines the action to launch during the step
  10763. */
  10764. registerStep(index: number, component: ISceneComponent, action: T): void;
  10765. /**
  10766. * Clears all the steps from the stage.
  10767. */
  10768. clear(): void;
  10769. }
  10770. }
  10771. declare module "babylonjs/Meshes/meshLODLevel" {
  10772. import { Mesh } from "babylonjs/Meshes/mesh";
  10773. import { Nullable } from "babylonjs/types";
  10774. /**
  10775. * Class used to represent a specific level of detail of a mesh
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10777. */
  10778. export class MeshLODLevel {
  10779. /** Defines the distance where this level should star being displayed */
  10780. distance: number;
  10781. /** Defines the mesh to use to render this level */
  10782. mesh: Nullable<Mesh>;
  10783. /**
  10784. * Creates a new LOD level
  10785. * @param distance defines the distance where this level should star being displayed
  10786. * @param mesh defines the mesh to use to render this level
  10787. */
  10788. constructor(
  10789. /** Defines the distance where this level should star being displayed */
  10790. distance: number,
  10791. /** Defines the mesh to use to render this level */
  10792. mesh: Nullable<Mesh>);
  10793. }
  10794. }
  10795. declare module "babylonjs/Lights/shadowLight" {
  10796. import { Camera } from "babylonjs/Cameras/camera";
  10797. import { Scene } from "babylonjs/scene";
  10798. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10800. import { Light } from "babylonjs/Lights/light";
  10801. /**
  10802. * Interface describing all the common properties and methods a shadow light needs to implement.
  10803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10804. * as well as binding the different shadow properties to the effects.
  10805. */
  10806. export interface IShadowLight extends Light {
  10807. /**
  10808. * The light id in the scene (used in scene.findLighById for instance)
  10809. */
  10810. id: string;
  10811. /**
  10812. * The position the shdow will be casted from.
  10813. */
  10814. position: Vector3;
  10815. /**
  10816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10817. */
  10818. direction: Vector3;
  10819. /**
  10820. * The transformed position. Position of the light in world space taking parenting in account.
  10821. */
  10822. transformedPosition: Vector3;
  10823. /**
  10824. * The transformed direction. Direction of the light in world space taking parenting in account.
  10825. */
  10826. transformedDirection: Vector3;
  10827. /**
  10828. * The friendly name of the light in the scene.
  10829. */
  10830. name: string;
  10831. /**
  10832. * Defines the shadow projection clipping minimum z value.
  10833. */
  10834. shadowMinZ: number;
  10835. /**
  10836. * Defines the shadow projection clipping maximum z value.
  10837. */
  10838. shadowMaxZ: number;
  10839. /**
  10840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10842. */
  10843. computeTransformedInformation(): boolean;
  10844. /**
  10845. * Gets the scene the light belongs to.
  10846. * @returns The scene
  10847. */
  10848. getScene(): Scene;
  10849. /**
  10850. * Callback defining a custom Projection Matrix Builder.
  10851. * This can be used to override the default projection matrix computation.
  10852. */
  10853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10854. /**
  10855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10856. * @param matrix The materix to updated with the projection information
  10857. * @param viewMatrix The transform matrix of the light
  10858. * @param renderList The list of mesh to render in the map
  10859. * @returns The current light
  10860. */
  10861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10862. /**
  10863. * Gets the current depth scale used in ESM.
  10864. * @returns The scale
  10865. */
  10866. getDepthScale(): number;
  10867. /**
  10868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10869. * @returns true if a cube texture needs to be use
  10870. */
  10871. needCube(): boolean;
  10872. /**
  10873. * Detects if the projection matrix requires to be recomputed this frame.
  10874. * @returns true if it requires to be recomputed otherwise, false.
  10875. */
  10876. needProjectionMatrixCompute(): boolean;
  10877. /**
  10878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10879. */
  10880. forceProjectionMatrixCompute(): void;
  10881. /**
  10882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10885. */
  10886. getShadowDirection(faceIndex?: number): Vector3;
  10887. /**
  10888. * Gets the minZ used for shadow according to both the scene and the light.
  10889. * @param activeCamera The camera we are returning the min for
  10890. * @returns the depth min z
  10891. */
  10892. getDepthMinZ(activeCamera: Camera): number;
  10893. /**
  10894. * Gets the maxZ used for shadow according to both the scene and the light.
  10895. * @param activeCamera The camera we are returning the max for
  10896. * @returns the depth max z
  10897. */
  10898. getDepthMaxZ(activeCamera: Camera): number;
  10899. }
  10900. /**
  10901. * Base implementation IShadowLight
  10902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10903. */
  10904. export abstract class ShadowLight extends Light implements IShadowLight {
  10905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10906. protected _position: Vector3;
  10907. protected _setPosition(value: Vector3): void;
  10908. /**
  10909. * Sets the position the shadow will be casted from. Also use as the light position for both
  10910. * point and spot lights.
  10911. */
  10912. /**
  10913. * Sets the position the shadow will be casted from. Also use as the light position for both
  10914. * point and spot lights.
  10915. */
  10916. position: Vector3;
  10917. protected _direction: Vector3;
  10918. protected _setDirection(value: Vector3): void;
  10919. /**
  10920. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10921. * Also use as the light direction on spot and directional lights.
  10922. */
  10923. /**
  10924. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10925. * Also use as the light direction on spot and directional lights.
  10926. */
  10927. direction: Vector3;
  10928. private _shadowMinZ;
  10929. /**
  10930. * Gets the shadow projection clipping minimum z value.
  10931. */
  10932. /**
  10933. * Sets the shadow projection clipping minimum z value.
  10934. */
  10935. shadowMinZ: number;
  10936. private _shadowMaxZ;
  10937. /**
  10938. * Sets the shadow projection clipping maximum z value.
  10939. */
  10940. /**
  10941. * Gets the shadow projection clipping maximum z value.
  10942. */
  10943. shadowMaxZ: number;
  10944. /**
  10945. * Callback defining a custom Projection Matrix Builder.
  10946. * This can be used to override the default projection matrix computation.
  10947. */
  10948. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10949. /**
  10950. * The transformed position. Position of the light in world space taking parenting in account.
  10951. */
  10952. transformedPosition: Vector3;
  10953. /**
  10954. * The transformed direction. Direction of the light in world space taking parenting in account.
  10955. */
  10956. transformedDirection: Vector3;
  10957. private _needProjectionMatrixCompute;
  10958. /**
  10959. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10960. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10961. */
  10962. computeTransformedInformation(): boolean;
  10963. /**
  10964. * Return the depth scale used for the shadow map.
  10965. * @returns the depth scale.
  10966. */
  10967. getDepthScale(): number;
  10968. /**
  10969. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10972. */
  10973. getShadowDirection(faceIndex?: number): Vector3;
  10974. /**
  10975. * Returns the ShadowLight absolute position in the World.
  10976. * @returns the position vector in world space
  10977. */
  10978. getAbsolutePosition(): Vector3;
  10979. /**
  10980. * Sets the ShadowLight direction toward the passed target.
  10981. * @param target The point to target in local space
  10982. * @returns the updated ShadowLight direction
  10983. */
  10984. setDirectionToTarget(target: Vector3): Vector3;
  10985. /**
  10986. * Returns the light rotation in euler definition.
  10987. * @returns the x y z rotation in local space.
  10988. */
  10989. getRotation(): Vector3;
  10990. /**
  10991. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10992. * @returns true if a cube texture needs to be use
  10993. */
  10994. needCube(): boolean;
  10995. /**
  10996. * Detects if the projection matrix requires to be recomputed this frame.
  10997. * @returns true if it requires to be recomputed otherwise, false.
  10998. */
  10999. needProjectionMatrixCompute(): boolean;
  11000. /**
  11001. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11002. */
  11003. forceProjectionMatrixCompute(): void;
  11004. /** @hidden */
  11005. _initCache(): void;
  11006. /** @hidden */
  11007. _isSynchronized(): boolean;
  11008. /**
  11009. * Computes the world matrix of the node
  11010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11011. * @returns the world matrix
  11012. */
  11013. computeWorldMatrix(force?: boolean): Matrix;
  11014. /**
  11015. * Gets the minZ used for shadow according to both the scene and the light.
  11016. * @param activeCamera The camera we are returning the min for
  11017. * @returns the depth min z
  11018. */
  11019. getDepthMinZ(activeCamera: Camera): number;
  11020. /**
  11021. * Gets the maxZ used for shadow according to both the scene and the light.
  11022. * @param activeCamera The camera we are returning the max for
  11023. * @returns the depth max z
  11024. */
  11025. getDepthMaxZ(activeCamera: Camera): number;
  11026. /**
  11027. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11028. * @param matrix The materix to updated with the projection information
  11029. * @param viewMatrix The transform matrix of the light
  11030. * @param renderList The list of mesh to render in the map
  11031. * @returns The current light
  11032. */
  11033. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11034. }
  11035. }
  11036. declare module "babylonjs/Materials/materialHelper" {
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Engine } from "babylonjs/Engines/engine";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Light } from "babylonjs/Lights/light";
  11042. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11043. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11046. /**
  11047. * "Static Class" containing the most commonly used helper while dealing with material for
  11048. * rendering purpose.
  11049. *
  11050. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11051. *
  11052. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11053. */
  11054. export class MaterialHelper {
  11055. /**
  11056. * Bind the current view position to an effect.
  11057. * @param effect The effect to be bound
  11058. * @param scene The scene the eyes position is used from
  11059. */
  11060. static BindEyePosition(effect: Effect, scene: Scene): void;
  11061. /**
  11062. * Helps preparing the defines values about the UVs in used in the effect.
  11063. * UVs are shared as much as we can accross channels in the shaders.
  11064. * @param texture The texture we are preparing the UVs for
  11065. * @param defines The defines to update
  11066. * @param key The channel key "diffuse", "specular"... used in the shader
  11067. */
  11068. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11069. /**
  11070. * Binds a texture matrix value to its corrsponding uniform
  11071. * @param texture The texture to bind the matrix for
  11072. * @param uniformBuffer The uniform buffer receivin the data
  11073. * @param key The channel key "diffuse", "specular"... used in the shader
  11074. */
  11075. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11076. /**
  11077. * Gets the current status of the fog (should it be enabled?)
  11078. * @param mesh defines the mesh to evaluate for fog support
  11079. * @param scene defines the hosting scene
  11080. * @returns true if fog must be enabled
  11081. */
  11082. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11083. /**
  11084. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11085. * @param mesh defines the current mesh
  11086. * @param scene defines the current scene
  11087. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11088. * @param pointsCloud defines if point cloud rendering has to be turned on
  11089. * @param fogEnabled defines if fog has to be turned on
  11090. * @param alphaTest defines if alpha testing has to be turned on
  11091. * @param defines defines the current list of defines
  11092. */
  11093. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11094. /**
  11095. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11096. * @param scene defines the current scene
  11097. * @param engine defines the current engine
  11098. * @param defines specifies the list of active defines
  11099. * @param useInstances defines if instances have to be turned on
  11100. * @param useClipPlane defines if clip plane have to be turned on
  11101. */
  11102. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11103. /**
  11104. * Prepares the defines for bones
  11105. * @param mesh The mesh containing the geometry data we will draw
  11106. * @param defines The defines to update
  11107. */
  11108. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11109. /**
  11110. * Prepares the defines for morph targets
  11111. * @param mesh The mesh containing the geometry data we will draw
  11112. * @param defines The defines to update
  11113. */
  11114. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11115. /**
  11116. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11117. * @param mesh The mesh containing the geometry data we will draw
  11118. * @param defines The defines to update
  11119. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11120. * @param useBones Precise whether bones should be used or not (override mesh info)
  11121. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11122. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11123. * @returns false if defines are considered not dirty and have not been checked
  11124. */
  11125. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11126. /**
  11127. * Prepares the defines related to multiview
  11128. * @param scene The scene we are intending to draw
  11129. * @param defines The defines to update
  11130. */
  11131. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11132. /**
  11133. * Prepares the defines related to the light information passed in parameter
  11134. * @param scene The scene we are intending to draw
  11135. * @param mesh The mesh the effect is compiling for
  11136. * @param light The light the effect is compiling for
  11137. * @param lightIndex The index of the light
  11138. * @param defines The defines to update
  11139. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11140. * @param state Defines the current state regarding what is needed (normals, etc...)
  11141. */
  11142. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11143. needNormals: boolean;
  11144. needRebuild: boolean;
  11145. shadowEnabled: boolean;
  11146. specularEnabled: boolean;
  11147. lightmapMode: boolean;
  11148. }): void;
  11149. /**
  11150. * Prepares the defines related to the light information passed in parameter
  11151. * @param scene The scene we are intending to draw
  11152. * @param mesh The mesh the effect is compiling for
  11153. * @param defines The defines to update
  11154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11155. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11156. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11157. * @returns true if normals will be required for the rest of the effect
  11158. */
  11159. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11160. /**
  11161. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11162. * @param lightIndex defines the light index
  11163. * @param uniformsList The uniform list
  11164. * @param samplersList The sampler list
  11165. * @param projectedLightTexture defines if projected texture must be used
  11166. * @param uniformBuffersList defines an optional list of uniform buffers
  11167. */
  11168. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11169. /**
  11170. * Prepares the uniforms and samplers list to be used in the effect
  11171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11172. * @param samplersList The sampler list
  11173. * @param defines The defines helping in the list generation
  11174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11175. */
  11176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11177. /**
  11178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11179. * @param defines The defines to update while falling back
  11180. * @param fallbacks The authorized effect fallbacks
  11181. * @param maxSimultaneousLights The maximum number of lights allowed
  11182. * @param rank the current rank of the Effect
  11183. * @returns The newly affected rank
  11184. */
  11185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11186. private static _TmpMorphInfluencers;
  11187. /**
  11188. * Prepares the list of attributes required for morph targets according to the effect defines.
  11189. * @param attribs The current list of supported attribs
  11190. * @param mesh The mesh to prepare the morph targets attributes for
  11191. * @param influencers The number of influencers
  11192. */
  11193. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11194. /**
  11195. * Prepares the list of attributes required for morph targets according to the effect defines.
  11196. * @param attribs The current list of supported attribs
  11197. * @param mesh The mesh to prepare the morph targets attributes for
  11198. * @param defines The current Defines of the effect
  11199. */
  11200. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11201. /**
  11202. * Prepares the list of attributes required for bones according to the effect defines.
  11203. * @param attribs The current list of supported attribs
  11204. * @param mesh The mesh to prepare the bones attributes for
  11205. * @param defines The current Defines of the effect
  11206. * @param fallbacks The current efffect fallback strategy
  11207. */
  11208. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11209. /**
  11210. * Check and prepare the list of attributes required for instances according to the effect defines.
  11211. * @param attribs The current list of supported attribs
  11212. * @param defines The current MaterialDefines of the effect
  11213. */
  11214. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11215. /**
  11216. * Add the list of attributes required for instances to the attribs array.
  11217. * @param attribs The current list of supported attribs
  11218. */
  11219. static PushAttributesForInstances(attribs: string[]): void;
  11220. /**
  11221. * Binds the light shadow information to the effect for the given mesh.
  11222. * @param light The light containing the generator
  11223. * @param scene The scene the lights belongs to
  11224. * @param mesh The mesh we are binding the information to render
  11225. * @param lightIndex The light index in the effect used to render the mesh
  11226. * @param effect The effect we are binding the data to
  11227. */
  11228. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11229. /**
  11230. * Binds the light information to the effect.
  11231. * @param light The light containing the generator
  11232. * @param effect The effect we are binding the data to
  11233. * @param lightIndex The light index in the effect used to render
  11234. */
  11235. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11236. /**
  11237. * Binds the lights information from the scene to the effect for the given mesh.
  11238. * @param light Light to bind
  11239. * @param lightIndex Light index
  11240. * @param scene The scene where the light belongs to
  11241. * @param mesh The mesh we are binding the information to render
  11242. * @param effect The effect we are binding the data to
  11243. * @param useSpecular Defines if specular is supported
  11244. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11245. */
  11246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11247. /**
  11248. * Binds the lights information from the scene to the effect for the given mesh.
  11249. * @param scene The scene the lights belongs to
  11250. * @param mesh The mesh we are binding the information to render
  11251. * @param effect The effect we are binding the data to
  11252. * @param defines The generated defines for the effect
  11253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11255. */
  11256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11257. private static _tempFogColor;
  11258. /**
  11259. * Binds the fog information from the scene to the effect for the given mesh.
  11260. * @param scene The scene the lights belongs to
  11261. * @param mesh The mesh we are binding the information to render
  11262. * @param effect The effect we are binding the data to
  11263. * @param linearSpace Defines if the fog effect is applied in linear space
  11264. */
  11265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11266. /**
  11267. * Binds the bones information from the mesh to the effect.
  11268. * @param mesh The mesh we are binding the information to render
  11269. * @param effect The effect we are binding the data to
  11270. */
  11271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11272. /**
  11273. * Binds the morph targets information from the mesh to the effect.
  11274. * @param abstractMesh The mesh we are binding the information to render
  11275. * @param effect The effect we are binding the data to
  11276. */
  11277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11278. /**
  11279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11280. * @param defines The generated defines used in the effect
  11281. * @param effect The effect we are binding the data to
  11282. * @param scene The scene we are willing to render with logarithmic scale for
  11283. */
  11284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11285. /**
  11286. * Binds the clip plane information from the scene to the effect.
  11287. * @param scene The scene the clip plane information are extracted from
  11288. * @param effect The effect we are binding the data to
  11289. */
  11290. static BindClipPlane(effect: Effect, scene: Scene): void;
  11291. }
  11292. }
  11293. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11294. /** @hidden */
  11295. export var shadowMapPixelShader: {
  11296. name: string;
  11297. shader: string;
  11298. };
  11299. }
  11300. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11301. /** @hidden */
  11302. export var bonesDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11308. /** @hidden */
  11309. export var morphTargetsVertexGlobalDeclaration: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11315. /** @hidden */
  11316. export var morphTargetsVertexDeclaration: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11322. /** @hidden */
  11323. export var instancesDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11329. /** @hidden */
  11330. export var helperFunctions: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11336. /** @hidden */
  11337. export var morphTargetsVertex: {
  11338. name: string;
  11339. shader: string;
  11340. };
  11341. }
  11342. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11343. /** @hidden */
  11344. export var instancesVertex: {
  11345. name: string;
  11346. shader: string;
  11347. };
  11348. }
  11349. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11350. /** @hidden */
  11351. export var bonesVertex: {
  11352. name: string;
  11353. shader: string;
  11354. };
  11355. }
  11356. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11357. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11363. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11364. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11365. /** @hidden */
  11366. export var shadowMapVertexShader: {
  11367. name: string;
  11368. shader: string;
  11369. };
  11370. }
  11371. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11372. /** @hidden */
  11373. export var depthBoxBlurPixelShader: {
  11374. name: string;
  11375. shader: string;
  11376. };
  11377. }
  11378. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Scene } from "babylonjs/scene";
  11381. import { Matrix } from "babylonjs/Maths/math";
  11382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11386. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11387. import { Effect } from "babylonjs/Materials/effect";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import "babylonjs/Shaders/shadowMap.fragment";
  11390. import "babylonjs/Shaders/shadowMap.vertex";
  11391. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11392. import { Observable } from "babylonjs/Misc/observable";
  11393. /**
  11394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11395. */
  11396. export interface ICustomShaderOptions {
  11397. /**
  11398. * Gets or sets the custom shader name to use
  11399. */
  11400. shaderName: string;
  11401. /**
  11402. * The list of attribute names used in the shader
  11403. */
  11404. attributes?: string[];
  11405. /**
  11406. * The list of unifrom names used in the shader
  11407. */
  11408. uniforms?: string[];
  11409. /**
  11410. * The list of sampler names used in the shader
  11411. */
  11412. samplers?: string[];
  11413. /**
  11414. * The list of defines used in the shader
  11415. */
  11416. defines?: string[];
  11417. }
  11418. /**
  11419. * Interface to implement to create a shadow generator compatible with BJS.
  11420. */
  11421. export interface IShadowGenerator {
  11422. /**
  11423. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11424. * @returns The render target texture if present otherwise, null
  11425. */
  11426. getShadowMap(): Nullable<RenderTargetTexture>;
  11427. /**
  11428. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11429. * @returns The render target texture if the shadow map is present otherwise, null
  11430. */
  11431. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11432. /**
  11433. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11434. * @param subMesh The submesh we want to render in the shadow map
  11435. * @param useInstances Defines wether will draw in the map using instances
  11436. * @returns true if ready otherwise, false
  11437. */
  11438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11439. /**
  11440. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11441. * @param defines Defines of the material we want to update
  11442. * @param lightIndex Index of the light in the enabled light list of the material
  11443. */
  11444. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11445. /**
  11446. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11447. * defined in the generator but impacting the effect).
  11448. * It implies the unifroms available on the materials are the standard BJS ones.
  11449. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11450. * @param effect The effect we are binfing the information for
  11451. */
  11452. bindShadowLight(lightIndex: string, effect: Effect): void;
  11453. /**
  11454. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11455. * (eq to shadow prjection matrix * light transform matrix)
  11456. * @returns The transform matrix used to create the shadow map
  11457. */
  11458. getTransformMatrix(): Matrix;
  11459. /**
  11460. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11461. * Cube and 2D textures for instance.
  11462. */
  11463. recreateShadowMap(): void;
  11464. /**
  11465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11466. * @param onCompiled Callback triggered at the and of the effects compilation
  11467. * @param options Sets of optional options forcing the compilation with different modes
  11468. */
  11469. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11470. useInstances: boolean;
  11471. }>): void;
  11472. /**
  11473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11474. * @param options Sets of optional options forcing the compilation with different modes
  11475. * @returns A promise that resolves when the compilation completes
  11476. */
  11477. forceCompilationAsync(options?: Partial<{
  11478. useInstances: boolean;
  11479. }>): Promise<void>;
  11480. /**
  11481. * Serializes the shadow generator setup to a json object.
  11482. * @returns The serialized JSON object
  11483. */
  11484. serialize(): any;
  11485. /**
  11486. * Disposes the Shadow map and related Textures and effects.
  11487. */
  11488. dispose(): void;
  11489. }
  11490. /**
  11491. * Default implementation IShadowGenerator.
  11492. * This is the main object responsible of generating shadows in the framework.
  11493. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11494. */
  11495. export class ShadowGenerator implements IShadowGenerator {
  11496. /**
  11497. * Shadow generator mode None: no filtering applied.
  11498. */
  11499. static readonly FILTER_NONE: number;
  11500. /**
  11501. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11507. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11508. */
  11509. static readonly FILTER_POISSONSAMPLING: number;
  11510. /**
  11511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11513. */
  11514. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11515. /**
  11516. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11517. * edge artifacts on steep falloff.
  11518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11519. */
  11520. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11521. /**
  11522. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11523. * edge artifacts on steep falloff.
  11524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11525. */
  11526. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11527. /**
  11528. * Shadow generator mode PCF: Percentage Closer Filtering
  11529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11530. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11531. */
  11532. static readonly FILTER_PCF: number;
  11533. /**
  11534. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11536. * Contact Hardening
  11537. */
  11538. static readonly FILTER_PCSS: number;
  11539. /**
  11540. * Reserved for PCF and PCSS
  11541. * Highest Quality.
  11542. *
  11543. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11544. *
  11545. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11546. */
  11547. static readonly QUALITY_HIGH: number;
  11548. /**
  11549. * Reserved for PCF and PCSS
  11550. * Good tradeoff for quality/perf cross devices
  11551. *
  11552. * Execute PCF on a 3*3 kernel.
  11553. *
  11554. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11555. */
  11556. static readonly QUALITY_MEDIUM: number;
  11557. /**
  11558. * Reserved for PCF and PCSS
  11559. * The lowest quality but the fastest.
  11560. *
  11561. * Execute PCF on a 1*1 kernel.
  11562. *
  11563. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11564. */
  11565. static readonly QUALITY_LOW: number;
  11566. /** Gets or sets the custom shader name to use */
  11567. customShaderOptions: ICustomShaderOptions;
  11568. /**
  11569. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11570. */
  11571. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11572. /**
  11573. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11574. */
  11575. onAfterShadowMapRenderObservable: Observable<Effect>;
  11576. /**
  11577. * Observable triggered before a mesh is rendered in the shadow map.
  11578. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11579. */
  11580. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11581. /**
  11582. * Observable triggered after a mesh is rendered in the shadow map.
  11583. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11584. */
  11585. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11586. private _bias;
  11587. /**
  11588. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11589. */
  11590. /**
  11591. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11592. */
  11593. bias: number;
  11594. private _normalBias;
  11595. /**
  11596. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11597. */
  11598. /**
  11599. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11600. */
  11601. normalBias: number;
  11602. private _blurBoxOffset;
  11603. /**
  11604. * Gets the blur box offset: offset applied during the blur pass.
  11605. * Only useful if useKernelBlur = false
  11606. */
  11607. /**
  11608. * Sets the blur box offset: offset applied during the blur pass.
  11609. * Only useful if useKernelBlur = false
  11610. */
  11611. blurBoxOffset: number;
  11612. private _blurScale;
  11613. /**
  11614. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11615. * 2 means half of the size.
  11616. */
  11617. /**
  11618. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11619. * 2 means half of the size.
  11620. */
  11621. blurScale: number;
  11622. private _blurKernel;
  11623. /**
  11624. * Gets the blur kernel: kernel size of the blur pass.
  11625. * Only useful if useKernelBlur = true
  11626. */
  11627. /**
  11628. * Sets the blur kernel: kernel size of the blur pass.
  11629. * Only useful if useKernelBlur = true
  11630. */
  11631. blurKernel: number;
  11632. private _useKernelBlur;
  11633. /**
  11634. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11635. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11636. */
  11637. /**
  11638. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11639. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11640. */
  11641. useKernelBlur: boolean;
  11642. private _depthScale;
  11643. /**
  11644. * Gets the depth scale used in ESM mode.
  11645. */
  11646. /**
  11647. * Sets the depth scale used in ESM mode.
  11648. * This can override the scale stored on the light.
  11649. */
  11650. depthScale: number;
  11651. private _filter;
  11652. /**
  11653. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11654. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11655. */
  11656. /**
  11657. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11659. */
  11660. filter: number;
  11661. /**
  11662. * Gets if the current filter is set to Poisson Sampling.
  11663. */
  11664. /**
  11665. * Sets the current filter to Poisson Sampling.
  11666. */
  11667. usePoissonSampling: boolean;
  11668. /**
  11669. * Gets if the current filter is set to ESM.
  11670. */
  11671. /**
  11672. * Sets the current filter is to ESM.
  11673. */
  11674. useExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered ESM.
  11677. */
  11678. /**
  11679. * Gets if the current filter is set to filtered ESM.
  11680. */
  11681. useBlurExponentialShadowMap: boolean;
  11682. /**
  11683. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11684. * exponential to prevent steep falloff artifacts).
  11685. */
  11686. /**
  11687. * Sets the current filter to "close ESM" (using the inverse of the
  11688. * exponential to prevent steep falloff artifacts).
  11689. */
  11690. useCloseExponentialShadowMap: boolean;
  11691. /**
  11692. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11693. * exponential to prevent steep falloff artifacts).
  11694. */
  11695. /**
  11696. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11697. * exponential to prevent steep falloff artifacts).
  11698. */
  11699. useBlurCloseExponentialShadowMap: boolean;
  11700. /**
  11701. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11702. */
  11703. /**
  11704. * Sets the current filter to "PCF" (percentage closer filtering).
  11705. */
  11706. usePercentageCloserFiltering: boolean;
  11707. private _filteringQuality;
  11708. /**
  11709. * Gets the PCF or PCSS Quality.
  11710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11711. */
  11712. /**
  11713. * Sets the PCF or PCSS Quality.
  11714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11715. */
  11716. filteringQuality: number;
  11717. /**
  11718. * Gets if the current filter is set to "PCSS" (contact hardening).
  11719. */
  11720. /**
  11721. * Sets the current filter to "PCSS" (contact hardening).
  11722. */
  11723. useContactHardeningShadow: boolean;
  11724. private _contactHardeningLightSizeUVRatio;
  11725. /**
  11726. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11727. * Using a ratio helps keeping shape stability independently of the map size.
  11728. *
  11729. * It does not account for the light projection as it was having too much
  11730. * instability during the light setup or during light position changes.
  11731. *
  11732. * Only valid if useContactHardeningShadow is true.
  11733. */
  11734. /**
  11735. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11736. * Using a ratio helps keeping shape stability independently of the map size.
  11737. *
  11738. * It does not account for the light projection as it was having too much
  11739. * instability during the light setup or during light position changes.
  11740. *
  11741. * Only valid if useContactHardeningShadow is true.
  11742. */
  11743. contactHardeningLightSizeUVRatio: number;
  11744. private _darkness;
  11745. /** Gets or sets the actual darkness of a shadow */
  11746. darkness: number;
  11747. /**
  11748. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11749. * 0 means strongest and 1 would means no shadow.
  11750. * @returns the darkness.
  11751. */
  11752. getDarkness(): number;
  11753. /**
  11754. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11755. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11756. * @returns the shadow generator allowing fluent coding.
  11757. */
  11758. setDarkness(darkness: number): ShadowGenerator;
  11759. private _transparencyShadow;
  11760. /** Gets or sets the ability to have transparent shadow */
  11761. transparencyShadow: boolean;
  11762. /**
  11763. * Sets the ability to have transparent shadow (boolean).
  11764. * @param transparent True if transparent else False
  11765. * @returns the shadow generator allowing fluent coding
  11766. */
  11767. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11768. private _shadowMap;
  11769. private _shadowMap2;
  11770. /**
  11771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11772. * @returns The render target texture if present otherwise, null
  11773. */
  11774. getShadowMap(): Nullable<RenderTargetTexture>;
  11775. /**
  11776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11777. * @returns The render target texture if the shadow map is present otherwise, null
  11778. */
  11779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11780. /**
  11781. * Gets the class name of that object
  11782. * @returns "ShadowGenerator"
  11783. */
  11784. getClassName(): string;
  11785. /**
  11786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11787. * @param mesh Mesh to add
  11788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11789. * @returns the Shadow Generator itself
  11790. */
  11791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11792. /**
  11793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11794. * @param mesh Mesh to remove
  11795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11796. * @returns the Shadow Generator itself
  11797. */
  11798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11799. /**
  11800. * Controls the extent to which the shadows fade out at the edge of the frustum
  11801. * Used only by directionals and spots
  11802. */
  11803. frustumEdgeFalloff: number;
  11804. private _light;
  11805. /**
  11806. * Returns the associated light object.
  11807. * @returns the light generating the shadow
  11808. */
  11809. getLight(): IShadowLight;
  11810. /**
  11811. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11812. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11813. * It might on the other hand introduce peter panning.
  11814. */
  11815. forceBackFacesOnly: boolean;
  11816. private _scene;
  11817. private _lightDirection;
  11818. private _effect;
  11819. private _viewMatrix;
  11820. private _projectionMatrix;
  11821. private _transformMatrix;
  11822. private _cachedPosition;
  11823. private _cachedDirection;
  11824. private _cachedDefines;
  11825. private _currentRenderID;
  11826. private _boxBlurPostprocess;
  11827. private _kernelBlurXPostprocess;
  11828. private _kernelBlurYPostprocess;
  11829. private _blurPostProcesses;
  11830. private _mapSize;
  11831. private _currentFaceIndex;
  11832. private _currentFaceIndexCache;
  11833. private _textureType;
  11834. private _defaultTextureMatrix;
  11835. /** @hidden */
  11836. static _SceneComponentInitialization: (scene: Scene) => void;
  11837. /**
  11838. * Creates a ShadowGenerator object.
  11839. * A ShadowGenerator is the required tool to use the shadows.
  11840. * Each light casting shadows needs to use its own ShadowGenerator.
  11841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11843. * @param light The light object generating the shadows.
  11844. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  11845. */
  11846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11847. private _initializeGenerator;
  11848. private _initializeShadowMap;
  11849. private _initializeBlurRTTAndPostProcesses;
  11850. private _renderForShadowMap;
  11851. private _renderSubMeshForShadowMap;
  11852. private _applyFilterValues;
  11853. /**
  11854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11855. * @param onCompiled Callback triggered at the and of the effects compilation
  11856. * @param options Sets of optional options forcing the compilation with different modes
  11857. */
  11858. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11859. useInstances: boolean;
  11860. }>): void;
  11861. /**
  11862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11863. * @param options Sets of optional options forcing the compilation with different modes
  11864. * @returns A promise that resolves when the compilation completes
  11865. */
  11866. forceCompilationAsync(options?: Partial<{
  11867. useInstances: boolean;
  11868. }>): Promise<void>;
  11869. /**
  11870. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11871. * @param subMesh The submesh we want to render in the shadow map
  11872. * @param useInstances Defines wether will draw in the map using instances
  11873. * @returns true if ready otherwise, false
  11874. */
  11875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11876. /**
  11877. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11878. * @param defines Defines of the material we want to update
  11879. * @param lightIndex Index of the light in the enabled light list of the material
  11880. */
  11881. prepareDefines(defines: any, lightIndex: number): void;
  11882. /**
  11883. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11884. * defined in the generator but impacting the effect).
  11885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11886. * @param effect The effect we are binfing the information for
  11887. */
  11888. bindShadowLight(lightIndex: string, effect: Effect): void;
  11889. /**
  11890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11891. * (eq to shadow prjection matrix * light transform matrix)
  11892. * @returns The transform matrix used to create the shadow map
  11893. */
  11894. getTransformMatrix(): Matrix;
  11895. /**
  11896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11897. * Cube and 2D textures for instance.
  11898. */
  11899. recreateShadowMap(): void;
  11900. private _disposeBlurPostProcesses;
  11901. private _disposeRTTandPostProcesses;
  11902. /**
  11903. * Disposes the ShadowGenerator.
  11904. * Returns nothing.
  11905. */
  11906. dispose(): void;
  11907. /**
  11908. * Serializes the shadow generator setup to a json object.
  11909. * @returns The serialized JSON object
  11910. */
  11911. serialize(): any;
  11912. /**
  11913. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11914. * @param parsedShadowGenerator The JSON object to parse
  11915. * @param scene The scene to create the shadow map for
  11916. * @returns The parsed shadow generator
  11917. */
  11918. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11919. }
  11920. }
  11921. declare module "babylonjs/Lights/light" {
  11922. import { Nullable } from "babylonjs/types";
  11923. import { Scene } from "babylonjs/scene";
  11924. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11925. import { Node } from "babylonjs/node";
  11926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11927. import { Effect } from "babylonjs/Materials/effect";
  11928. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11929. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11930. /**
  11931. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11932. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11933. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  11934. */
  11935. export abstract class Light extends Node {
  11936. /**
  11937. * Falloff Default: light is falling off following the material specification:
  11938. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11939. */
  11940. static readonly FALLOFF_DEFAULT: number;
  11941. /**
  11942. * Falloff Physical: light is falling off following the inverse squared distance law.
  11943. */
  11944. static readonly FALLOFF_PHYSICAL: number;
  11945. /**
  11946. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11947. * to enhance interoperability with other engines.
  11948. */
  11949. static readonly FALLOFF_GLTF: number;
  11950. /**
  11951. * Falloff Standard: light is falling off like in the standard material
  11952. * to enhance interoperability with other materials.
  11953. */
  11954. static readonly FALLOFF_STANDARD: number;
  11955. /**
  11956. * If every light affecting the material is in this lightmapMode,
  11957. * material.lightmapTexture adds or multiplies
  11958. * (depends on material.useLightmapAsShadowmap)
  11959. * after every other light calculations.
  11960. */
  11961. static readonly LIGHTMAP_DEFAULT: number;
  11962. /**
  11963. * material.lightmapTexture as only diffuse lighting from this light
  11964. * adds only specular lighting from this light
  11965. * adds dynamic shadows
  11966. */
  11967. static readonly LIGHTMAP_SPECULAR: number;
  11968. /**
  11969. * material.lightmapTexture as only lighting
  11970. * no light calculation from this light
  11971. * only adds dynamic shadows from this light
  11972. */
  11973. static readonly LIGHTMAP_SHADOWSONLY: number;
  11974. /**
  11975. * Each light type uses the default quantity according to its type:
  11976. * point/spot lights use luminous intensity
  11977. * directional lights use illuminance
  11978. */
  11979. static readonly INTENSITYMODE_AUTOMATIC: number;
  11980. /**
  11981. * lumen (lm)
  11982. */
  11983. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11984. /**
  11985. * candela (lm/sr)
  11986. */
  11987. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11988. /**
  11989. * lux (lm/m^2)
  11990. */
  11991. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11992. /**
  11993. * nit (cd/m^2)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINANCE: number;
  11996. /**
  11997. * Light type const id of the point light.
  11998. */
  11999. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12000. /**
  12001. * Light type const id of the directional light.
  12002. */
  12003. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12004. /**
  12005. * Light type const id of the spot light.
  12006. */
  12007. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12008. /**
  12009. * Light type const id of the hemispheric light.
  12010. */
  12011. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12012. /**
  12013. * Diffuse gives the basic color to an object.
  12014. */
  12015. diffuse: Color3;
  12016. /**
  12017. * Specular produces a highlight color on an object.
  12018. * Note: This is note affecting PBR materials.
  12019. */
  12020. specular: Color3;
  12021. /**
  12022. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12023. * falling off base on range or angle.
  12024. * This can be set to any values in Light.FALLOFF_x.
  12025. *
  12026. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12027. * other types of materials.
  12028. */
  12029. falloffType: number;
  12030. /**
  12031. * Strength of the light.
  12032. * Note: By default it is define in the framework own unit.
  12033. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12034. */
  12035. intensity: number;
  12036. private _range;
  12037. protected _inverseSquaredRange: number;
  12038. /**
  12039. * Defines how far from the source the light is impacting in scene units.
  12040. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12041. */
  12042. /**
  12043. * Defines how far from the source the light is impacting in scene units.
  12044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12045. */
  12046. range: number;
  12047. /**
  12048. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12049. * of light.
  12050. */
  12051. private _photometricScale;
  12052. private _intensityMode;
  12053. /**
  12054. * Gets the photometric scale used to interpret the intensity.
  12055. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12056. */
  12057. /**
  12058. * Sets the photometric scale used to interpret the intensity.
  12059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12060. */
  12061. intensityMode: number;
  12062. private _radius;
  12063. /**
  12064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12065. */
  12066. /**
  12067. * sets the light radius used by PBR Materials to simulate soft area lights.
  12068. */
  12069. radius: number;
  12070. private _renderPriority;
  12071. /**
  12072. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12073. * exceeding the number allowed of the materials.
  12074. */
  12075. renderPriority: number;
  12076. private _shadowEnabled;
  12077. /**
  12078. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12079. * the current shadow generator.
  12080. */
  12081. /**
  12082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12083. * the current shadow generator.
  12084. */
  12085. shadowEnabled: boolean;
  12086. private _includedOnlyMeshes;
  12087. /**
  12088. * Gets the only meshes impacted by this light.
  12089. */
  12090. /**
  12091. * Sets the only meshes impacted by this light.
  12092. */
  12093. includedOnlyMeshes: AbstractMesh[];
  12094. private _excludedMeshes;
  12095. /**
  12096. * Gets the meshes not impacted by this light.
  12097. */
  12098. /**
  12099. * Sets the meshes not impacted by this light.
  12100. */
  12101. excludedMeshes: AbstractMesh[];
  12102. private _excludeWithLayerMask;
  12103. /**
  12104. * Gets the layer id use to find what meshes are not impacted by the light.
  12105. * Inactive if 0
  12106. */
  12107. /**
  12108. * Sets the layer id use to find what meshes are not impacted by the light.
  12109. * Inactive if 0
  12110. */
  12111. excludeWithLayerMask: number;
  12112. private _includeOnlyWithLayerMask;
  12113. /**
  12114. * Gets the layer id use to find what meshes are impacted by the light.
  12115. * Inactive if 0
  12116. */
  12117. /**
  12118. * Sets the layer id use to find what meshes are impacted by the light.
  12119. * Inactive if 0
  12120. */
  12121. includeOnlyWithLayerMask: number;
  12122. private _lightmapMode;
  12123. /**
  12124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12125. */
  12126. /**
  12127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12128. */
  12129. lightmapMode: number;
  12130. /**
  12131. * Shadow generator associted to the light.
  12132. * @hidden Internal use only.
  12133. */
  12134. _shadowGenerator: Nullable<IShadowGenerator>;
  12135. /**
  12136. * @hidden Internal use only.
  12137. */
  12138. _excludedMeshesIds: string[];
  12139. /**
  12140. * @hidden Internal use only.
  12141. */
  12142. _includedOnlyMeshesIds: string[];
  12143. /**
  12144. * The current light unifom buffer.
  12145. * @hidden Internal use only.
  12146. */
  12147. _uniformBuffer: UniformBuffer;
  12148. /**
  12149. * Creates a Light object in the scene.
  12150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12151. * @param name The firendly name of the light
  12152. * @param scene The scene the light belongs too
  12153. */
  12154. constructor(name: string, scene: Scene);
  12155. protected abstract _buildUniformLayout(): void;
  12156. /**
  12157. * Sets the passed Effect "effect" with the Light information.
  12158. * @param effect The effect to update
  12159. * @param lightIndex The index of the light in the effect to update
  12160. * @returns The light
  12161. */
  12162. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12163. /**
  12164. * Returns the string "Light".
  12165. * @returns the class name
  12166. */
  12167. getClassName(): string;
  12168. /** @hidden */
  12169. readonly _isLight: boolean;
  12170. /**
  12171. * Converts the light information to a readable string for debug purpose.
  12172. * @param fullDetails Supports for multiple levels of logging within scene loading
  12173. * @returns the human readable light info
  12174. */
  12175. toString(fullDetails?: boolean): string;
  12176. /** @hidden */
  12177. protected _syncParentEnabledState(): void;
  12178. /**
  12179. * Set the enabled state of this node.
  12180. * @param value - the new enabled state
  12181. */
  12182. setEnabled(value: boolean): void;
  12183. /**
  12184. * Returns the Light associated shadow generator if any.
  12185. * @return the associated shadow generator.
  12186. */
  12187. getShadowGenerator(): Nullable<IShadowGenerator>;
  12188. /**
  12189. * Returns a Vector3, the absolute light position in the World.
  12190. * @returns the world space position of the light
  12191. */
  12192. getAbsolutePosition(): Vector3;
  12193. /**
  12194. * Specifies if the light will affect the passed mesh.
  12195. * @param mesh The mesh to test against the light
  12196. * @return true the mesh is affected otherwise, false.
  12197. */
  12198. canAffectMesh(mesh: AbstractMesh): boolean;
  12199. /**
  12200. * Sort function to order lights for rendering.
  12201. * @param a First Light object to compare to second.
  12202. * @param b Second Light object to compare first.
  12203. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12204. */
  12205. static CompareLightsPriority(a: Light, b: Light): number;
  12206. /**
  12207. * Releases resources associated with this node.
  12208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12210. */
  12211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12212. /**
  12213. * Returns the light type ID (integer).
  12214. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12215. */
  12216. getTypeID(): number;
  12217. /**
  12218. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12219. * @returns the scaled intensity in intensity mode unit
  12220. */
  12221. getScaledIntensity(): number;
  12222. /**
  12223. * Returns a new Light object, named "name", from the current one.
  12224. * @param name The name of the cloned light
  12225. * @returns the new created light
  12226. */
  12227. clone(name: string): Nullable<Light>;
  12228. /**
  12229. * Serializes the current light into a Serialization object.
  12230. * @returns the serialized object.
  12231. */
  12232. serialize(): any;
  12233. /**
  12234. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12235. * This new light is named "name" and added to the passed scene.
  12236. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12237. * @param name The friendly name of the light
  12238. * @param scene The scene the new light will belong to
  12239. * @returns the constructor function
  12240. */
  12241. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12242. /**
  12243. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12244. * @param parsedLight The JSON representation of the light
  12245. * @param scene The scene to create the parsed light in
  12246. * @returns the created light after parsing
  12247. */
  12248. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12249. private _hookArrayForExcluded;
  12250. private _hookArrayForIncludedOnly;
  12251. private _resyncMeshes;
  12252. /**
  12253. * Forces the meshes to update their light related information in their rendering used effects
  12254. * @hidden Internal Use Only
  12255. */
  12256. _markMeshesAsLightDirty(): void;
  12257. /**
  12258. * Recomputes the cached photometric scale if needed.
  12259. */
  12260. private _computePhotometricScale;
  12261. /**
  12262. * Returns the Photometric Scale according to the light type and intensity mode.
  12263. */
  12264. private _getPhotometricScale;
  12265. /**
  12266. * Reorder the light in the scene according to their defined priority.
  12267. * @hidden Internal Use Only
  12268. */
  12269. _reorderLightsInScene(): void;
  12270. /**
  12271. * Prepares the list of defines specific to the light type.
  12272. * @param defines the list of defines
  12273. * @param lightIndex defines the index of the light for the effect
  12274. */
  12275. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12276. }
  12277. }
  12278. declare module "babylonjs/Meshes/instancedMesh" {
  12279. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12280. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12281. import { Camera } from "babylonjs/Cameras/camera";
  12282. import { Node } from "babylonjs/node";
  12283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12284. import { Mesh } from "babylonjs/Meshes/mesh";
  12285. import { Material } from "babylonjs/Materials/material";
  12286. import { Skeleton } from "babylonjs/Bones/skeleton";
  12287. import { Light } from "babylonjs/Lights/light";
  12288. /**
  12289. * Creates an instance based on a source mesh.
  12290. */
  12291. export class InstancedMesh extends AbstractMesh {
  12292. private _sourceMesh;
  12293. private _currentLOD;
  12294. /** @hidden */
  12295. _indexInSourceMeshInstanceArray: number;
  12296. constructor(name: string, source: Mesh);
  12297. /**
  12298. * Returns the string "InstancedMesh".
  12299. */
  12300. getClassName(): string;
  12301. /** Gets the list of lights affecting that mesh */
  12302. readonly lightSources: Light[];
  12303. _resyncLightSources(): void;
  12304. _resyncLighSource(light: Light): void;
  12305. _removeLightSource(light: Light): void;
  12306. /**
  12307. * If the source mesh receives shadows
  12308. */
  12309. readonly receiveShadows: boolean;
  12310. /**
  12311. * The material of the source mesh
  12312. */
  12313. readonly material: Nullable<Material>;
  12314. /**
  12315. * Visibility of the source mesh
  12316. */
  12317. readonly visibility: number;
  12318. /**
  12319. * Skeleton of the source mesh
  12320. */
  12321. readonly skeleton: Nullable<Skeleton>;
  12322. /**
  12323. * Rendering ground id of the source mesh
  12324. */
  12325. renderingGroupId: number;
  12326. /**
  12327. * Returns the total number of vertices (integer).
  12328. */
  12329. getTotalVertices(): number;
  12330. /**
  12331. * Returns a positive integer : the total number of indices in this mesh geometry.
  12332. * @returns the numner of indices or zero if the mesh has no geometry.
  12333. */
  12334. getTotalIndices(): number;
  12335. /**
  12336. * The source mesh of the instance
  12337. */
  12338. readonly sourceMesh: Mesh;
  12339. /**
  12340. * Is this node ready to be used/rendered
  12341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12342. * @return {boolean} is it ready
  12343. */
  12344. isReady(completeCheck?: boolean): boolean;
  12345. /**
  12346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12348. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  12349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12350. */
  12351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12352. /**
  12353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12355. * The `data` are either a numeric array either a Float32Array.
  12356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12357. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  12358. * Note that a new underlying VertexBuffer object is created each call.
  12359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12360. *
  12361. * Possible `kind` values :
  12362. * - VertexBuffer.PositionKind
  12363. * - VertexBuffer.UVKind
  12364. * - VertexBuffer.UV2Kind
  12365. * - VertexBuffer.UV3Kind
  12366. * - VertexBuffer.UV4Kind
  12367. * - VertexBuffer.UV5Kind
  12368. * - VertexBuffer.UV6Kind
  12369. * - VertexBuffer.ColorKind
  12370. * - VertexBuffer.MatricesIndicesKind
  12371. * - VertexBuffer.MatricesIndicesExtraKind
  12372. * - VertexBuffer.MatricesWeightsKind
  12373. * - VertexBuffer.MatricesWeightsExtraKind
  12374. *
  12375. * Returns the Mesh.
  12376. */
  12377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12378. /**
  12379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12380. * If the mesh has no geometry, it is simply returned as it is.
  12381. * The `data` are either a numeric array either a Float32Array.
  12382. * No new underlying VertexBuffer object is created.
  12383. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12385. *
  12386. * Possible `kind` values :
  12387. * - VertexBuffer.PositionKind
  12388. * - VertexBuffer.UVKind
  12389. * - VertexBuffer.UV2Kind
  12390. * - VertexBuffer.UV3Kind
  12391. * - VertexBuffer.UV4Kind
  12392. * - VertexBuffer.UV5Kind
  12393. * - VertexBuffer.UV6Kind
  12394. * - VertexBuffer.ColorKind
  12395. * - VertexBuffer.MatricesIndicesKind
  12396. * - VertexBuffer.MatricesIndicesExtraKind
  12397. * - VertexBuffer.MatricesWeightsKind
  12398. * - VertexBuffer.MatricesWeightsExtraKind
  12399. *
  12400. * Returns the Mesh.
  12401. */
  12402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12403. /**
  12404. * Sets the mesh indices.
  12405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12407. * This method creates a new index buffer each call.
  12408. * Returns the Mesh.
  12409. */
  12410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12411. /**
  12412. * Boolean : True if the mesh owns the requested kind of data.
  12413. */
  12414. isVerticesDataPresent(kind: string): boolean;
  12415. /**
  12416. * Returns an array of indices (IndicesArray).
  12417. */
  12418. getIndices(): Nullable<IndicesArray>;
  12419. readonly _positions: Nullable<Vector3[]>;
  12420. /**
  12421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12422. * This means the mesh underlying bounding box and sphere are recomputed.
  12423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12424. * @returns the current mesh
  12425. */
  12426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12427. /** @hidden */
  12428. _preActivate(): InstancedMesh;
  12429. /** @hidden */
  12430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12431. /** @hidden */
  12432. _postActivate(): void;
  12433. getWorldMatrix(): Matrix;
  12434. readonly isAnInstance: boolean;
  12435. /**
  12436. * Returns the current associated LOD AbstractMesh.
  12437. */
  12438. getLOD(camera: Camera): AbstractMesh;
  12439. /** @hidden */
  12440. _syncSubMeshes(): InstancedMesh;
  12441. /** @hidden */
  12442. _generatePointsArray(): boolean;
  12443. /**
  12444. * Creates a new InstancedMesh from the current mesh.
  12445. * - name (string) : the cloned mesh name
  12446. * - newParent (optional Node) : the optional Node to parent the clone to.
  12447. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12448. *
  12449. * Returns the clone.
  12450. */
  12451. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12452. /**
  12453. * Disposes the InstancedMesh.
  12454. * Returns nothing.
  12455. */
  12456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12457. }
  12458. }
  12459. declare module "babylonjs/Materials/shaderMaterial" {
  12460. import { Scene } from "babylonjs/scene";
  12461. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12463. import { Mesh } from "babylonjs/Meshes/mesh";
  12464. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12466. import { Texture } from "babylonjs/Materials/Textures/texture";
  12467. import { Material } from "babylonjs/Materials/material";
  12468. /**
  12469. * Defines the options associated with the creation of a shader material.
  12470. */
  12471. export interface IShaderMaterialOptions {
  12472. /**
  12473. * Does the material work in alpha blend mode
  12474. */
  12475. needAlphaBlending: boolean;
  12476. /**
  12477. * Does the material work in alpha test mode
  12478. */
  12479. needAlphaTesting: boolean;
  12480. /**
  12481. * The list of attribute names used in the shader
  12482. */
  12483. attributes: string[];
  12484. /**
  12485. * The list of unifrom names used in the shader
  12486. */
  12487. uniforms: string[];
  12488. /**
  12489. * The list of UBO names used in the shader
  12490. */
  12491. uniformBuffers: string[];
  12492. /**
  12493. * The list of sampler names used in the shader
  12494. */
  12495. samplers: string[];
  12496. /**
  12497. * The list of defines used in the shader
  12498. */
  12499. defines: string[];
  12500. }
  12501. /**
  12502. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  12503. *
  12504. * This returned material effects how the mesh will look based on the code in the shaders.
  12505. *
  12506. * @see http://doc.babylonjs.com/how_to/shader_material
  12507. */
  12508. export class ShaderMaterial extends Material {
  12509. private _shaderPath;
  12510. private _options;
  12511. private _textures;
  12512. private _textureArrays;
  12513. private _floats;
  12514. private _ints;
  12515. private _floatsArrays;
  12516. private _colors3;
  12517. private _colors3Arrays;
  12518. private _colors4;
  12519. private _colors4Arrays;
  12520. private _vectors2;
  12521. private _vectors3;
  12522. private _vectors4;
  12523. private _matrices;
  12524. private _matrices3x3;
  12525. private _matrices2x2;
  12526. private _vectors2Arrays;
  12527. private _vectors3Arrays;
  12528. private _vectors4Arrays;
  12529. private _cachedWorldViewMatrix;
  12530. private _cachedWorldViewProjectionMatrix;
  12531. private _renderId;
  12532. /**
  12533. * Instantiate a new shader material.
  12534. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  12535. * This returned material effects how the mesh will look based on the code in the shaders.
  12536. * @see http://doc.babylonjs.com/how_to/shader_material
  12537. * @param name Define the name of the material in the scene
  12538. * @param scene Define the scene the material belongs to
  12539. * @param shaderPath Defines the route to the shader code in one of three ways:
  12540. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12541. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12542. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12543. * @param options Define the options used to create the shader
  12544. */
  12545. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12546. /**
  12547. * Gets the options used to compile the shader.
  12548. * They can be modified to trigger a new compilation
  12549. */
  12550. readonly options: IShaderMaterialOptions;
  12551. /**
  12552. * Gets the current class name of the material e.g. "ShaderMaterial"
  12553. * Mainly use in serialization.
  12554. * @returns the class name
  12555. */
  12556. getClassName(): string;
  12557. /**
  12558. * Specifies if the material will require alpha blending
  12559. * @returns a boolean specifying if alpha blending is needed
  12560. */
  12561. needAlphaBlending(): boolean;
  12562. /**
  12563. * Specifies if this material should be rendered in alpha test mode
  12564. * @returns a boolean specifying if an alpha test is needed.
  12565. */
  12566. needAlphaTesting(): boolean;
  12567. private _checkUniform;
  12568. /**
  12569. * Set a texture in the shader.
  12570. * @param name Define the name of the uniform samplers as defined in the shader
  12571. * @param texture Define the texture to bind to this sampler
  12572. * @return the material itself allowing "fluent" like uniform updates
  12573. */
  12574. setTexture(name: string, texture: Texture): ShaderMaterial;
  12575. /**
  12576. * Set a texture array in the shader.
  12577. * @param name Define the name of the uniform sampler array as defined in the shader
  12578. * @param textures Define the list of textures to bind to this sampler
  12579. * @return the material itself allowing "fluent" like uniform updates
  12580. */
  12581. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12582. /**
  12583. * Set a float in the shader.
  12584. * @param name Define the name of the uniform as defined in the shader
  12585. * @param value Define the value to give to the uniform
  12586. * @return the material itself allowing "fluent" like uniform updates
  12587. */
  12588. setFloat(name: string, value: number): ShaderMaterial;
  12589. /**
  12590. * Set a int in the shader.
  12591. * @param name Define the name of the uniform as defined in the shader
  12592. * @param value Define the value to give to the uniform
  12593. * @return the material itself allowing "fluent" like uniform updates
  12594. */
  12595. setInt(name: string, value: number): ShaderMaterial;
  12596. /**
  12597. * Set an array of floats in the shader.
  12598. * @param name Define the name of the uniform as defined in the shader
  12599. * @param value Define the value to give to the uniform
  12600. * @return the material itself allowing "fluent" like uniform updates
  12601. */
  12602. setFloats(name: string, value: number[]): ShaderMaterial;
  12603. /**
  12604. * Set a vec3 in the shader from a Color3.
  12605. * @param name Define the name of the uniform as defined in the shader
  12606. * @param value Define the value to give to the uniform
  12607. * @return the material itself allowing "fluent" like uniform updates
  12608. */
  12609. setColor3(name: string, value: Color3): ShaderMaterial;
  12610. /**
  12611. * Set a vec3 array in the shader from a Color3 array.
  12612. * @param name Define the name of the uniform as defined in the shader
  12613. * @param value Define the value to give to the uniform
  12614. * @return the material itself allowing "fluent" like uniform updates
  12615. */
  12616. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12617. /**
  12618. * Set a vec4 in the shader from a Color4.
  12619. * @param name Define the name of the uniform as defined in the shader
  12620. * @param value Define the value to give to the uniform
  12621. * @return the material itself allowing "fluent" like uniform updates
  12622. */
  12623. setColor4(name: string, value: Color4): ShaderMaterial;
  12624. /**
  12625. * Set a vec4 array in the shader from a Color4 array.
  12626. * @param name Define the name of the uniform as defined in the shader
  12627. * @param value Define the value to give to the uniform
  12628. * @return the material itself allowing "fluent" like uniform updates
  12629. */
  12630. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12631. /**
  12632. * Set a vec2 in the shader from a Vector2.
  12633. * @param name Define the name of the uniform as defined in the shader
  12634. * @param value Define the value to give to the uniform
  12635. * @return the material itself allowing "fluent" like uniform updates
  12636. */
  12637. setVector2(name: string, value: Vector2): ShaderMaterial;
  12638. /**
  12639. * Set a vec3 in the shader from a Vector3.
  12640. * @param name Define the name of the uniform as defined in the shader
  12641. * @param value Define the value to give to the uniform
  12642. * @return the material itself allowing "fluent" like uniform updates
  12643. */
  12644. setVector3(name: string, value: Vector3): ShaderMaterial;
  12645. /**
  12646. * Set a vec4 in the shader from a Vector4.
  12647. * @param name Define the name of the uniform as defined in the shader
  12648. * @param value Define the value to give to the uniform
  12649. * @return the material itself allowing "fluent" like uniform updates
  12650. */
  12651. setVector4(name: string, value: Vector4): ShaderMaterial;
  12652. /**
  12653. * Set a mat4 in the shader from a Matrix.
  12654. * @param name Define the name of the uniform as defined in the shader
  12655. * @param value Define the value to give to the uniform
  12656. * @return the material itself allowing "fluent" like uniform updates
  12657. */
  12658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12659. /**
  12660. * Set a mat3 in the shader from a Float32Array.
  12661. * @param name Define the name of the uniform as defined in the shader
  12662. * @param value Define the value to give to the uniform
  12663. * @return the material itself allowing "fluent" like uniform updates
  12664. */
  12665. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12666. /**
  12667. * Set a mat2 in the shader from a Float32Array.
  12668. * @param name Define the name of the uniform as defined in the shader
  12669. * @param value Define the value to give to the uniform
  12670. * @return the material itself allowing "fluent" like uniform updates
  12671. */
  12672. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12673. /**
  12674. * Set a vec2 array in the shader from a number array.
  12675. * @param name Define the name of the uniform as defined in the shader
  12676. * @param value Define the value to give to the uniform
  12677. * @return the material itself allowing "fluent" like uniform updates
  12678. */
  12679. setArray2(name: string, value: number[]): ShaderMaterial;
  12680. /**
  12681. * Set a vec3 array in the shader from a number array.
  12682. * @param name Define the name of the uniform as defined in the shader
  12683. * @param value Define the value to give to the uniform
  12684. * @return the material itself allowing "fluent" like uniform updates
  12685. */
  12686. setArray3(name: string, value: number[]): ShaderMaterial;
  12687. /**
  12688. * Set a vec4 array in the shader from a number array.
  12689. * @param name Define the name of the uniform as defined in the shader
  12690. * @param value Define the value to give to the uniform
  12691. * @return the material itself allowing "fluent" like uniform updates
  12692. */
  12693. setArray4(name: string, value: number[]): ShaderMaterial;
  12694. private _checkCache;
  12695. /**
  12696. * Specifies that the submesh is ready to be used
  12697. * @param mesh defines the mesh to check
  12698. * @param subMesh defines which submesh to check
  12699. * @param useInstances specifies that instances should be used
  12700. * @returns a boolean indicating that the submesh is ready or not
  12701. */
  12702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12703. /**
  12704. * Checks if the material is ready to render the requested mesh
  12705. * @param mesh Define the mesh to render
  12706. * @param useInstances Define whether or not the material is used with instances
  12707. * @returns true if ready, otherwise false
  12708. */
  12709. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12710. /**
  12711. * Binds the world matrix to the material
  12712. * @param world defines the world transformation matrix
  12713. */
  12714. bindOnlyWorldMatrix(world: Matrix): void;
  12715. /**
  12716. * Binds the material to the mesh
  12717. * @param world defines the world transformation matrix
  12718. * @param mesh defines the mesh to bind the material to
  12719. */
  12720. bind(world: Matrix, mesh?: Mesh): void;
  12721. /**
  12722. * Gets the active textures from the material
  12723. * @returns an array of textures
  12724. */
  12725. getActiveTextures(): BaseTexture[];
  12726. /**
  12727. * Specifies if the material uses a texture
  12728. * @param texture defines the texture to check against the material
  12729. * @returns a boolean specifying if the material uses the texture
  12730. */
  12731. hasTexture(texture: BaseTexture): boolean;
  12732. /**
  12733. * Makes a duplicate of the material, and gives it a new name
  12734. * @param name defines the new name for the duplicated material
  12735. * @returns the cloned material
  12736. */
  12737. clone(name: string): ShaderMaterial;
  12738. /**
  12739. * Disposes the material
  12740. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12741. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12742. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12743. */
  12744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12745. /**
  12746. * Serializes this material in a JSON representation
  12747. * @returns the serialized material object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Creates a shader material from parsed shader material data
  12752. * @param source defines the JSON represnetation of the material
  12753. * @param scene defines the hosting scene
  12754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12755. * @returns a new material
  12756. */
  12757. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12758. }
  12759. }
  12760. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12761. /** @hidden */
  12762. export var clipPlaneFragmentDeclaration: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12768. /** @hidden */
  12769. export var clipPlaneFragment: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/color.fragment" {
  12775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12777. /** @hidden */
  12778. export var colorPixelShader: {
  12779. name: string;
  12780. shader: string;
  12781. };
  12782. }
  12783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12784. /** @hidden */
  12785. export var clipPlaneVertexDeclaration: {
  12786. name: string;
  12787. shader: string;
  12788. };
  12789. }
  12790. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12791. /** @hidden */
  12792. export var clipPlaneVertex: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Shaders/color.vertex" {
  12798. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12800. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12801. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12804. /** @hidden */
  12805. export var colorVertexShader: {
  12806. name: string;
  12807. shader: string;
  12808. };
  12809. }
  12810. declare module "babylonjs/Meshes/linesMesh" {
  12811. import { Nullable } from "babylonjs/types";
  12812. import { Scene } from "babylonjs/scene";
  12813. import { Color3 } from "babylonjs/Maths/math";
  12814. import { Node } from "babylonjs/node";
  12815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12816. import { Mesh } from "babylonjs/Meshes/mesh";
  12817. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12818. import { Effect } from "babylonjs/Materials/effect";
  12819. import { Material } from "babylonjs/Materials/material";
  12820. import "babylonjs/Shaders/color.fragment";
  12821. import "babylonjs/Shaders/color.vertex";
  12822. /**
  12823. * Line mesh
  12824. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12825. */
  12826. export class LinesMesh extends Mesh {
  12827. /**
  12828. * If vertex color should be applied to the mesh
  12829. */
  12830. readonly useVertexColor?: boolean | undefined;
  12831. /**
  12832. * If vertex alpha should be applied to the mesh
  12833. */
  12834. readonly useVertexAlpha?: boolean | undefined;
  12835. /**
  12836. * Color of the line (Default: White)
  12837. */
  12838. color: Color3;
  12839. /**
  12840. * Alpha of the line (Default: 1)
  12841. */
  12842. alpha: number;
  12843. /**
  12844. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12845. * This margin is expressed in world space coordinates, so its value may vary.
  12846. * Default value is 0.1
  12847. */
  12848. intersectionThreshold: number;
  12849. private _colorShader;
  12850. private color4;
  12851. /**
  12852. * Creates a new LinesMesh
  12853. * @param name defines the name
  12854. * @param scene defines the hosting scene
  12855. * @param parent defines the parent mesh if any
  12856. * @param source defines the optional source LinesMesh used to clone data from
  12857. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12858. * When false, achieved by calling a clone(), also passing False.
  12859. * This will make creation of children, recursive.
  12860. * @param useVertexColor defines if this LinesMesh supports vertex color
  12861. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12862. */
  12863. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12864. /**
  12865. * If vertex color should be applied to the mesh
  12866. */
  12867. useVertexColor?: boolean | undefined,
  12868. /**
  12869. * If vertex alpha should be applied to the mesh
  12870. */
  12871. useVertexAlpha?: boolean | undefined);
  12872. private _addClipPlaneDefine;
  12873. private _removeClipPlaneDefine;
  12874. isReady(): boolean;
  12875. /**
  12876. * Returns the string "LineMesh"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * @hidden
  12881. */
  12882. /**
  12883. * @hidden
  12884. */
  12885. material: Material;
  12886. /**
  12887. * @hidden
  12888. */
  12889. readonly checkCollisions: boolean;
  12890. /** @hidden */
  12891. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12892. /** @hidden */
  12893. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12894. /**
  12895. * Disposes of the line mesh
  12896. * @param doNotRecurse If children should be disposed
  12897. */
  12898. dispose(doNotRecurse?: boolean): void;
  12899. /**
  12900. * Returns a new LineMesh object cloned from the current one.
  12901. */
  12902. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12903. /**
  12904. * Creates a new InstancedLinesMesh object from the mesh model.
  12905. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12906. * @param name defines the name of the new instance
  12907. * @returns a new InstancedLinesMesh
  12908. */
  12909. createInstance(name: string): InstancedLinesMesh;
  12910. }
  12911. /**
  12912. * Creates an instance based on a source LinesMesh
  12913. */
  12914. export class InstancedLinesMesh extends InstancedMesh {
  12915. /**
  12916. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12917. * This margin is expressed in world space coordinates, so its value may vary.
  12918. * Initilized with the intersectionThreshold value of the source LinesMesh
  12919. */
  12920. intersectionThreshold: number;
  12921. constructor(name: string, source: LinesMesh);
  12922. /**
  12923. * Returns the string "InstancedLinesMesh".
  12924. */
  12925. getClassName(): string;
  12926. }
  12927. }
  12928. declare module "babylonjs/Meshes/groundMesh" {
  12929. import { Scene } from "babylonjs/scene";
  12930. import { Vector3 } from "babylonjs/Maths/math";
  12931. import { Mesh } from "babylonjs/Meshes/mesh";
  12932. /**
  12933. * Mesh representing the gorund
  12934. */
  12935. export class GroundMesh extends Mesh {
  12936. /** If octree should be generated */
  12937. generateOctree: boolean;
  12938. private _heightQuads;
  12939. /** @hidden */
  12940. _subdivisionsX: number;
  12941. /** @hidden */
  12942. _subdivisionsY: number;
  12943. /** @hidden */
  12944. _width: number;
  12945. /** @hidden */
  12946. _height: number;
  12947. /** @hidden */
  12948. _minX: number;
  12949. /** @hidden */
  12950. _maxX: number;
  12951. /** @hidden */
  12952. _minZ: number;
  12953. /** @hidden */
  12954. _maxZ: number;
  12955. constructor(name: string, scene: Scene);
  12956. /**
  12957. * "GroundMesh"
  12958. * @returns "GroundMesh"
  12959. */
  12960. getClassName(): string;
  12961. /**
  12962. * The minimum of x and y subdivisions
  12963. */
  12964. readonly subdivisions: number;
  12965. /**
  12966. * X subdivisions
  12967. */
  12968. readonly subdivisionsX: number;
  12969. /**
  12970. * Y subdivisions
  12971. */
  12972. readonly subdivisionsY: number;
  12973. /**
  12974. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12976. * @param chunksCount the number of subdivisions for x and y
  12977. * @param octreeBlocksSize (Default: 32)
  12978. */
  12979. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12980. /**
  12981. * Returns a height (y) value in the Worl system :
  12982. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12983. * @param x x coordinate
  12984. * @param z z coordinate
  12985. * @returns the ground y position if (x, z) are outside the ground surface.
  12986. */
  12987. getHeightAtCoordinates(x: number, z: number): number;
  12988. /**
  12989. * Returns a normalized vector (Vector3) orthogonal to the ground
  12990. * at the ground coordinates (x, z) expressed in the World system.
  12991. * @param x x coordinate
  12992. * @param z z coordinate
  12993. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12994. */
  12995. getNormalAtCoordinates(x: number, z: number): Vector3;
  12996. /**
  12997. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12998. * at the ground coordinates (x, z) expressed in the World system.
  12999. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13000. * @param x x coordinate
  13001. * @param z z coordinate
  13002. * @param ref vector to store the result
  13003. * @returns the GroundMesh.
  13004. */
  13005. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13006. /**
  13007. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13008. * if the ground has been updated.
  13009. * This can be used in the render loop.
  13010. * @returns the GroundMesh.
  13011. */
  13012. updateCoordinateHeights(): GroundMesh;
  13013. private _getFacetAt;
  13014. private _initHeightQuads;
  13015. private _computeHeightQuads;
  13016. /**
  13017. * Serializes this ground mesh
  13018. * @param serializationObject object to write serialization to
  13019. */
  13020. serialize(serializationObject: any): void;
  13021. /**
  13022. * Parses a serialized ground mesh
  13023. * @param parsedMesh the serialized mesh
  13024. * @param scene the scene to create the ground mesh in
  13025. * @returns the created ground mesh
  13026. */
  13027. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13028. }
  13029. }
  13030. declare module "babylonjs/Physics/physicsJoint" {
  13031. import { Vector3 } from "babylonjs/Maths/math";
  13032. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13033. /**
  13034. * Interface for Physics-Joint data
  13035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13036. */
  13037. export interface PhysicsJointData {
  13038. /**
  13039. * The main pivot of the joint
  13040. */
  13041. mainPivot?: Vector3;
  13042. /**
  13043. * The connected pivot of the joint
  13044. */
  13045. connectedPivot?: Vector3;
  13046. /**
  13047. * The main axis of the joint
  13048. */
  13049. mainAxis?: Vector3;
  13050. /**
  13051. * The connected axis of the joint
  13052. */
  13053. connectedAxis?: Vector3;
  13054. /**
  13055. * The collision of the joint
  13056. */
  13057. collision?: boolean;
  13058. /**
  13059. * Native Oimo/Cannon/Energy data
  13060. */
  13061. nativeParams?: any;
  13062. }
  13063. /**
  13064. * This is a holder class for the physics joint created by the physics plugin
  13065. * It holds a set of functions to control the underlying joint
  13066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13067. */
  13068. export class PhysicsJoint {
  13069. /**
  13070. * The type of the physics joint
  13071. */
  13072. type: number;
  13073. /**
  13074. * The data for the physics joint
  13075. */
  13076. jointData: PhysicsJointData;
  13077. private _physicsJoint;
  13078. protected _physicsPlugin: IPhysicsEnginePlugin;
  13079. /**
  13080. * Initializes the physics joint
  13081. * @param type The type of the physics joint
  13082. * @param jointData The data for the physics joint
  13083. */
  13084. constructor(
  13085. /**
  13086. * The type of the physics joint
  13087. */
  13088. type: number,
  13089. /**
  13090. * The data for the physics joint
  13091. */
  13092. jointData: PhysicsJointData);
  13093. /**
  13094. * Gets the physics joint
  13095. */
  13096. /**
  13097. * Sets the physics joint
  13098. */
  13099. physicsJoint: any;
  13100. /**
  13101. * Sets the physics plugin
  13102. */
  13103. physicsPlugin: IPhysicsEnginePlugin;
  13104. /**
  13105. * Execute a function that is physics-plugin specific.
  13106. * @param {Function} func the function that will be executed.
  13107. * It accepts two parameters: the physics world and the physics joint
  13108. */
  13109. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13110. /**
  13111. * Distance-Joint type
  13112. */
  13113. static DistanceJoint: number;
  13114. /**
  13115. * Hinge-Joint type
  13116. */
  13117. static HingeJoint: number;
  13118. /**
  13119. * Ball-and-Socket joint type
  13120. */
  13121. static BallAndSocketJoint: number;
  13122. /**
  13123. * Wheel-Joint type
  13124. */
  13125. static WheelJoint: number;
  13126. /**
  13127. * Slider-Joint type
  13128. */
  13129. static SliderJoint: number;
  13130. /**
  13131. * Prismatic-Joint type
  13132. */
  13133. static PrismaticJoint: number;
  13134. /**
  13135. * Universal-Joint type
  13136. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13137. */
  13138. static UniversalJoint: number;
  13139. /**
  13140. * Hinge-Joint 2 type
  13141. */
  13142. static Hinge2Joint: number;
  13143. /**
  13144. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13145. */
  13146. static PointToPointJoint: number;
  13147. /**
  13148. * Spring-Joint type
  13149. */
  13150. static SpringJoint: number;
  13151. /**
  13152. * Lock-Joint type
  13153. */
  13154. static LockJoint: number;
  13155. }
  13156. /**
  13157. * A class representing a physics distance joint
  13158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13159. */
  13160. export class DistanceJoint extends PhysicsJoint {
  13161. /**
  13162. *
  13163. * @param jointData The data for the Distance-Joint
  13164. */
  13165. constructor(jointData: DistanceJointData);
  13166. /**
  13167. * Update the predefined distance.
  13168. * @param maxDistance The maximum preferred distance
  13169. * @param minDistance The minimum preferred distance
  13170. */
  13171. updateDistance(maxDistance: number, minDistance?: number): void;
  13172. }
  13173. /**
  13174. * Represents a Motor-Enabled Joint
  13175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13176. */
  13177. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13178. /**
  13179. * Initializes the Motor-Enabled Joint
  13180. * @param type The type of the joint
  13181. * @param jointData The physica joint data for the joint
  13182. */
  13183. constructor(type: number, jointData: PhysicsJointData);
  13184. /**
  13185. * Set the motor values.
  13186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13187. * @param force the force to apply
  13188. * @param maxForce max force for this motor.
  13189. */
  13190. setMotor(force?: number, maxForce?: number): void;
  13191. /**
  13192. * Set the motor's limits.
  13193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13194. * @param upperLimit The upper limit of the motor
  13195. * @param lowerLimit The lower limit of the motor
  13196. */
  13197. setLimit(upperLimit: number, lowerLimit?: number): void;
  13198. }
  13199. /**
  13200. * This class represents a single physics Hinge-Joint
  13201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13202. */
  13203. export class HingeJoint extends MotorEnabledJoint {
  13204. /**
  13205. * Initializes the Hinge-Joint
  13206. * @param jointData The joint data for the Hinge-Joint
  13207. */
  13208. constructor(jointData: PhysicsJointData);
  13209. /**
  13210. * Set the motor values.
  13211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13212. * @param {number} force the force to apply
  13213. * @param {number} maxForce max force for this motor.
  13214. */
  13215. setMotor(force?: number, maxForce?: number): void;
  13216. /**
  13217. * Set the motor's limits.
  13218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13219. * @param upperLimit The upper limit of the motor
  13220. * @param lowerLimit The lower limit of the motor
  13221. */
  13222. setLimit(upperLimit: number, lowerLimit?: number): void;
  13223. }
  13224. /**
  13225. * This class represents a dual hinge physics joint (same as wheel joint)
  13226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13227. */
  13228. export class Hinge2Joint extends MotorEnabledJoint {
  13229. /**
  13230. * Initializes the Hinge2-Joint
  13231. * @param jointData The joint data for the Hinge2-Joint
  13232. */
  13233. constructor(jointData: PhysicsJointData);
  13234. /**
  13235. * Set the motor values.
  13236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13237. * @param {number} targetSpeed the speed the motor is to reach
  13238. * @param {number} maxForce max force for this motor.
  13239. * @param {motorIndex} the motor's index, 0 or 1.
  13240. */
  13241. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13242. /**
  13243. * Set the motor limits.
  13244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13245. * @param {number} upperLimit the upper limit
  13246. * @param {number} lowerLimit lower limit
  13247. * @param {motorIndex} the motor's index, 0 or 1.
  13248. */
  13249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13250. }
  13251. /**
  13252. * Interface for a motor enabled joint
  13253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13254. */
  13255. export interface IMotorEnabledJoint {
  13256. /**
  13257. * Physics joint
  13258. */
  13259. physicsJoint: any;
  13260. /**
  13261. * Sets the motor of the motor-enabled joint
  13262. * @param force The force of the motor
  13263. * @param maxForce The maximum force of the motor
  13264. * @param motorIndex The index of the motor
  13265. */
  13266. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13267. /**
  13268. * Sets the limit of the motor
  13269. * @param upperLimit The upper limit of the motor
  13270. * @param lowerLimit The lower limit of the motor
  13271. * @param motorIndex The index of the motor
  13272. */
  13273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13274. }
  13275. /**
  13276. * Joint data for a Distance-Joint
  13277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13278. */
  13279. export interface DistanceJointData extends PhysicsJointData {
  13280. /**
  13281. * Max distance the 2 joint objects can be apart
  13282. */
  13283. maxDistance: number;
  13284. }
  13285. /**
  13286. * Joint data from a spring joint
  13287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13288. */
  13289. export interface SpringJointData extends PhysicsJointData {
  13290. /**
  13291. * Length of the spring
  13292. */
  13293. length: number;
  13294. /**
  13295. * Stiffness of the spring
  13296. */
  13297. stiffness: number;
  13298. /**
  13299. * Damping of the spring
  13300. */
  13301. damping: number;
  13302. /** this callback will be called when applying the force to the impostors. */
  13303. forceApplicationCallback: () => void;
  13304. }
  13305. }
  13306. declare module "babylonjs/Physics/physicsRaycastResult" {
  13307. import { Vector3 } from "babylonjs/Maths/math";
  13308. /**
  13309. * Holds the data for the raycast result
  13310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13311. */
  13312. export class PhysicsRaycastResult {
  13313. private _hasHit;
  13314. private _hitDistance;
  13315. private _hitNormalWorld;
  13316. private _hitPointWorld;
  13317. private _rayFromWorld;
  13318. private _rayToWorld;
  13319. /**
  13320. * Gets if there was a hit
  13321. */
  13322. readonly hasHit: boolean;
  13323. /**
  13324. * Gets the distance from the hit
  13325. */
  13326. readonly hitDistance: number;
  13327. /**
  13328. * Gets the hit normal/direction in the world
  13329. */
  13330. readonly hitNormalWorld: Vector3;
  13331. /**
  13332. * Gets the hit point in the world
  13333. */
  13334. readonly hitPointWorld: Vector3;
  13335. /**
  13336. * Gets the ray "start point" of the ray in the world
  13337. */
  13338. readonly rayFromWorld: Vector3;
  13339. /**
  13340. * Gets the ray "end point" of the ray in the world
  13341. */
  13342. readonly rayToWorld: Vector3;
  13343. /**
  13344. * Sets the hit data (normal & point in world space)
  13345. * @param hitNormalWorld defines the normal in world space
  13346. * @param hitPointWorld defines the point in world space
  13347. */
  13348. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13349. /**
  13350. * Sets the distance from the start point to the hit point
  13351. * @param distance
  13352. */
  13353. setHitDistance(distance: number): void;
  13354. /**
  13355. * Calculates the distance manually
  13356. */
  13357. calculateHitDistance(): void;
  13358. /**
  13359. * Resets all the values to default
  13360. * @param from The from point on world space
  13361. * @param to The to point on world space
  13362. */
  13363. reset(from?: Vector3, to?: Vector3): void;
  13364. }
  13365. /**
  13366. * Interface for the size containing width and height
  13367. */
  13368. interface IXYZ {
  13369. /**
  13370. * X
  13371. */
  13372. x: number;
  13373. /**
  13374. * Y
  13375. */
  13376. y: number;
  13377. /**
  13378. * Z
  13379. */
  13380. z: number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Physics/IPhysicsEngine" {
  13384. import { Nullable } from "babylonjs/types";
  13385. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13387. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13388. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13389. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13390. /**
  13391. * Interface used to describe a physics joint
  13392. */
  13393. export interface PhysicsImpostorJoint {
  13394. /** Defines the main impostor to which the joint is linked */
  13395. mainImpostor: PhysicsImpostor;
  13396. /** Defines the impostor that is connected to the main impostor using this joint */
  13397. connectedImpostor: PhysicsImpostor;
  13398. /** Defines the joint itself */
  13399. joint: PhysicsJoint;
  13400. }
  13401. /** @hidden */
  13402. export interface IPhysicsEnginePlugin {
  13403. world: any;
  13404. name: string;
  13405. setGravity(gravity: Vector3): void;
  13406. setTimeStep(timeStep: number): void;
  13407. getTimeStep(): number;
  13408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13412. removePhysicsBody(impostor: PhysicsImpostor): void;
  13413. generateJoint(joint: PhysicsImpostorJoint): void;
  13414. removeJoint(joint: PhysicsImpostorJoint): void;
  13415. isSupported(): boolean;
  13416. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13417. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13419. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13420. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13421. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13423. getBodyMass(impostor: PhysicsImpostor): number;
  13424. getBodyFriction(impostor: PhysicsImpostor): number;
  13425. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13426. getBodyRestitution(impostor: PhysicsImpostor): number;
  13427. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13428. getBodyPressure?(impostor: PhysicsImpostor): number;
  13429. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13430. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13431. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13432. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13433. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13434. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13435. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13436. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13437. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13438. sleepBody(impostor: PhysicsImpostor): void;
  13439. wakeUpBody(impostor: PhysicsImpostor): void;
  13440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13441. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13442. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13443. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13444. getRadius(impostor: PhysicsImpostor): number;
  13445. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13447. dispose(): void;
  13448. }
  13449. /**
  13450. * Interface used to define a physics engine
  13451. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13452. */
  13453. export interface IPhysicsEngine {
  13454. /**
  13455. * Gets the gravity vector used by the simulation
  13456. */
  13457. gravity: Vector3;
  13458. /**
  13459. * Sets the gravity vector used by the simulation
  13460. * @param gravity defines the gravity vector to use
  13461. */
  13462. setGravity(gravity: Vector3): void;
  13463. /**
  13464. * Set the time step of the physics engine.
  13465. * Default is 1/60.
  13466. * To slow it down, enter 1/600 for example.
  13467. * To speed it up, 1/30
  13468. * @param newTimeStep the new timestep to apply to this world.
  13469. */
  13470. setTimeStep(newTimeStep: number): void;
  13471. /**
  13472. * Get the time step of the physics engine.
  13473. * @returns the current time step
  13474. */
  13475. getTimeStep(): number;
  13476. /**
  13477. * Release all resources
  13478. */
  13479. dispose(): void;
  13480. /**
  13481. * Gets the name of the current physics plugin
  13482. * @returns the name of the plugin
  13483. */
  13484. getPhysicsPluginName(): string;
  13485. /**
  13486. * Adding a new impostor for the impostor tracking.
  13487. * This will be done by the impostor itself.
  13488. * @param impostor the impostor to add
  13489. */
  13490. addImpostor(impostor: PhysicsImpostor): void;
  13491. /**
  13492. * Remove an impostor from the engine.
  13493. * This impostor and its mesh will not longer be updated by the physics engine.
  13494. * @param impostor the impostor to remove
  13495. */
  13496. removeImpostor(impostor: PhysicsImpostor): void;
  13497. /**
  13498. * Add a joint to the physics engine
  13499. * @param mainImpostor defines the main impostor to which the joint is added.
  13500. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13501. * @param joint defines the joint that will connect both impostors.
  13502. */
  13503. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13504. /**
  13505. * Removes a joint from the simulation
  13506. * @param mainImpostor defines the impostor used with the joint
  13507. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13508. * @param joint defines the joint to remove
  13509. */
  13510. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13511. /**
  13512. * Gets the current plugin used to run the simulation
  13513. * @returns current plugin
  13514. */
  13515. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13516. /**
  13517. * Gets the list of physic impostors
  13518. * @returns an array of PhysicsImpostor
  13519. */
  13520. getImpostors(): Array<PhysicsImpostor>;
  13521. /**
  13522. * Gets the impostor for a physics enabled object
  13523. * @param object defines the object impersonated by the impostor
  13524. * @returns the PhysicsImpostor or null if not found
  13525. */
  13526. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13527. /**
  13528. * Gets the impostor for a physics body object
  13529. * @param body defines physics body used by the impostor
  13530. * @returns the PhysicsImpostor or null if not found
  13531. */
  13532. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13533. /**
  13534. * Does a raycast in the physics world
  13535. * @param from when should the ray start?
  13536. * @param to when should the ray end?
  13537. * @returns PhysicsRaycastResult
  13538. */
  13539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13540. /**
  13541. * Called by the scene. No need to call it.
  13542. * @param delta defines the timespam between frames
  13543. */
  13544. _step(delta: number): void;
  13545. }
  13546. }
  13547. declare module "babylonjs/Physics/physicsImpostor" {
  13548. import { Nullable, IndicesArray } from "babylonjs/types";
  13549. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13552. import { Scene } from "babylonjs/scene";
  13553. import { Bone } from "babylonjs/Bones/bone";
  13554. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13555. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13556. /**
  13557. * The interface for the physics imposter parameters
  13558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13559. */
  13560. export interface PhysicsImpostorParameters {
  13561. /**
  13562. * The mass of the physics imposter
  13563. */
  13564. mass: number;
  13565. /**
  13566. * The friction of the physics imposter
  13567. */
  13568. friction?: number;
  13569. /**
  13570. * The coefficient of restitution of the physics imposter
  13571. */
  13572. restitution?: number;
  13573. /**
  13574. * The native options of the physics imposter
  13575. */
  13576. nativeOptions?: any;
  13577. /**
  13578. * Specifies if the parent should be ignored
  13579. */
  13580. ignoreParent?: boolean;
  13581. /**
  13582. * Specifies if bi-directional transformations should be disabled
  13583. */
  13584. disableBidirectionalTransformation?: boolean;
  13585. /**
  13586. * The pressure inside the physics imposter, soft object only
  13587. */
  13588. pressure?: number;
  13589. /**
  13590. * The stiffness the physics imposter, soft object only
  13591. */
  13592. stiffness?: number;
  13593. /**
  13594. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13595. */
  13596. velocityIterations?: number;
  13597. /**
  13598. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13599. */
  13600. positionIterations?: number;
  13601. /**
  13602. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13603. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13604. * Add to fix multiple points
  13605. */
  13606. fixedPoints?: number;
  13607. /**
  13608. * The collision margin around a soft object
  13609. */
  13610. margin?: number;
  13611. /**
  13612. * The collision margin around a soft object
  13613. */
  13614. damping?: number;
  13615. /**
  13616. * The path for a rope based on an extrusion
  13617. */
  13618. path?: any;
  13619. /**
  13620. * The shape of an extrusion used for a rope based on an extrusion
  13621. */
  13622. shape?: any;
  13623. }
  13624. /**
  13625. * Interface for a physics-enabled object
  13626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13627. */
  13628. export interface IPhysicsEnabledObject {
  13629. /**
  13630. * The position of the physics-enabled object
  13631. */
  13632. position: Vector3;
  13633. /**
  13634. * The rotation of the physics-enabled object
  13635. */
  13636. rotationQuaternion: Nullable<Quaternion>;
  13637. /**
  13638. * The scale of the physics-enabled object
  13639. */
  13640. scaling: Vector3;
  13641. /**
  13642. * The rotation of the physics-enabled object
  13643. */
  13644. rotation?: Vector3;
  13645. /**
  13646. * The parent of the physics-enabled object
  13647. */
  13648. parent?: any;
  13649. /**
  13650. * The bounding info of the physics-enabled object
  13651. * @returns The bounding info of the physics-enabled object
  13652. */
  13653. getBoundingInfo(): BoundingInfo;
  13654. /**
  13655. * Computes the world matrix
  13656. * @param force Specifies if the world matrix should be computed by force
  13657. * @returns A world matrix
  13658. */
  13659. computeWorldMatrix(force: boolean): Matrix;
  13660. /**
  13661. * Gets the world matrix
  13662. * @returns A world matrix
  13663. */
  13664. getWorldMatrix?(): Matrix;
  13665. /**
  13666. * Gets the child meshes
  13667. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13668. * @returns An array of abstract meshes
  13669. */
  13670. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13671. /**
  13672. * Gets the vertex data
  13673. * @param kind The type of vertex data
  13674. * @returns A nullable array of numbers, or a float32 array
  13675. */
  13676. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13677. /**
  13678. * Gets the indices from the mesh
  13679. * @returns A nullable array of index arrays
  13680. */
  13681. getIndices?(): Nullable<IndicesArray>;
  13682. /**
  13683. * Gets the scene from the mesh
  13684. * @returns the indices array or null
  13685. */
  13686. getScene?(): Scene;
  13687. /**
  13688. * Gets the absolute position from the mesh
  13689. * @returns the absolute position
  13690. */
  13691. getAbsolutePosition(): Vector3;
  13692. /**
  13693. * Gets the absolute pivot point from the mesh
  13694. * @returns the absolute pivot point
  13695. */
  13696. getAbsolutePivotPoint(): Vector3;
  13697. /**
  13698. * Rotates the mesh
  13699. * @param axis The axis of rotation
  13700. * @param amount The amount of rotation
  13701. * @param space The space of the rotation
  13702. * @returns The rotation transform node
  13703. */
  13704. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13705. /**
  13706. * Translates the mesh
  13707. * @param axis The axis of translation
  13708. * @param distance The distance of translation
  13709. * @param space The space of the translation
  13710. * @returns The transform node
  13711. */
  13712. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13713. /**
  13714. * Sets the absolute position of the mesh
  13715. * @param absolutePosition The absolute position of the mesh
  13716. * @returns The transform node
  13717. */
  13718. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13719. /**
  13720. * Gets the class name of the mesh
  13721. * @returns The class name
  13722. */
  13723. getClassName(): string;
  13724. }
  13725. /**
  13726. * Represents a physics imposter
  13727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13728. */
  13729. export class PhysicsImpostor {
  13730. /**
  13731. * The physics-enabled object used as the physics imposter
  13732. */
  13733. object: IPhysicsEnabledObject;
  13734. /**
  13735. * The type of the physics imposter
  13736. */
  13737. type: number;
  13738. private _options;
  13739. private _scene?;
  13740. /**
  13741. * The default object size of the imposter
  13742. */
  13743. static DEFAULT_OBJECT_SIZE: Vector3;
  13744. /**
  13745. * The identity quaternion of the imposter
  13746. */
  13747. static IDENTITY_QUATERNION: Quaternion;
  13748. /** @hidden */
  13749. _pluginData: any;
  13750. private _physicsEngine;
  13751. private _physicsBody;
  13752. private _bodyUpdateRequired;
  13753. private _onBeforePhysicsStepCallbacks;
  13754. private _onAfterPhysicsStepCallbacks;
  13755. /** @hidden */
  13756. _onPhysicsCollideCallbacks: Array<{
  13757. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13758. otherImpostors: Array<PhysicsImpostor>;
  13759. }>;
  13760. private _deltaPosition;
  13761. private _deltaRotation;
  13762. private _deltaRotationConjugated;
  13763. /** @hidden */
  13764. _isFromLine: boolean;
  13765. private _parent;
  13766. private _isDisposed;
  13767. private static _tmpVecs;
  13768. private static _tmpQuat;
  13769. /**
  13770. * Specifies if the physics imposter is disposed
  13771. */
  13772. readonly isDisposed: boolean;
  13773. /**
  13774. * Gets the mass of the physics imposter
  13775. */
  13776. mass: number;
  13777. /**
  13778. * Gets the coefficient of friction
  13779. */
  13780. /**
  13781. * Sets the coefficient of friction
  13782. */
  13783. friction: number;
  13784. /**
  13785. * Gets the coefficient of restitution
  13786. */
  13787. /**
  13788. * Sets the coefficient of restitution
  13789. */
  13790. restitution: number;
  13791. /**
  13792. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13793. */
  13794. /**
  13795. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13796. */
  13797. pressure: number;
  13798. /**
  13799. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13800. */
  13801. /**
  13802. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13803. */
  13804. stiffness: number;
  13805. /**
  13806. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13807. */
  13808. /**
  13809. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13810. */
  13811. velocityIterations: number;
  13812. /**
  13813. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13814. */
  13815. /**
  13816. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13817. */
  13818. positionIterations: number;
  13819. /**
  13820. * The unique id of the physics imposter
  13821. * set by the physics engine when adding this impostor to the array
  13822. */
  13823. uniqueId: number;
  13824. /**
  13825. * @hidden
  13826. */
  13827. soft: boolean;
  13828. /**
  13829. * @hidden
  13830. */
  13831. segments: number;
  13832. private _joints;
  13833. /**
  13834. * Initializes the physics imposter
  13835. * @param object The physics-enabled object used as the physics imposter
  13836. * @param type The type of the physics imposter
  13837. * @param _options The options for the physics imposter
  13838. * @param _scene The Babylon scene
  13839. */
  13840. constructor(
  13841. /**
  13842. * The physics-enabled object used as the physics imposter
  13843. */
  13844. object: IPhysicsEnabledObject,
  13845. /**
  13846. * The type of the physics imposter
  13847. */
  13848. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13849. /**
  13850. * This function will completly initialize this impostor.
  13851. * It will create a new body - but only if this mesh has no parent.
  13852. * If it has, this impostor will not be used other than to define the impostor
  13853. * of the child mesh.
  13854. * @hidden
  13855. */
  13856. _init(): void;
  13857. private _getPhysicsParent;
  13858. /**
  13859. * Should a new body be generated.
  13860. * @returns boolean specifying if body initialization is required
  13861. */
  13862. isBodyInitRequired(): boolean;
  13863. /**
  13864. * Sets the updated scaling
  13865. * @param updated Specifies if the scaling is updated
  13866. */
  13867. setScalingUpdated(): void;
  13868. /**
  13869. * Force a regeneration of this or the parent's impostor's body.
  13870. * Use under cautious - This will remove all joints already implemented.
  13871. */
  13872. forceUpdate(): void;
  13873. /**
  13874. * Gets the body that holds this impostor. Either its own, or its parent.
  13875. */
  13876. /**
  13877. * Set the physics body. Used mainly by the physics engine/plugin
  13878. */
  13879. physicsBody: any;
  13880. /**
  13881. * Get the parent of the physics imposter
  13882. * @returns Physics imposter or null
  13883. */
  13884. /**
  13885. * Sets the parent of the physics imposter
  13886. */
  13887. parent: Nullable<PhysicsImpostor>;
  13888. /**
  13889. * Resets the update flags
  13890. */
  13891. resetUpdateFlags(): void;
  13892. /**
  13893. * Gets the object extend size
  13894. * @returns the object extend size
  13895. */
  13896. getObjectExtendSize(): Vector3;
  13897. /**
  13898. * Gets the object center
  13899. * @returns The object center
  13900. */
  13901. getObjectCenter(): Vector3;
  13902. /**
  13903. * Get a specific parametes from the options parameter
  13904. * @param paramName The object parameter name
  13905. * @returns The object parameter
  13906. */
  13907. getParam(paramName: string): any;
  13908. /**
  13909. * Sets a specific parameter in the options given to the physics plugin
  13910. * @param paramName The parameter name
  13911. * @param value The value of the parameter
  13912. */
  13913. setParam(paramName: string, value: number): void;
  13914. /**
  13915. * Specifically change the body's mass option. Won't recreate the physics body object
  13916. * @param mass The mass of the physics imposter
  13917. */
  13918. setMass(mass: number): void;
  13919. /**
  13920. * Gets the linear velocity
  13921. * @returns linear velocity or null
  13922. */
  13923. getLinearVelocity(): Nullable<Vector3>;
  13924. /**
  13925. * Sets the linear velocity
  13926. * @param velocity linear velocity or null
  13927. */
  13928. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13929. /**
  13930. * Gets the angular velocity
  13931. * @returns angular velocity or null
  13932. */
  13933. getAngularVelocity(): Nullable<Vector3>;
  13934. /**
  13935. * Sets the angular velocity
  13936. * @param velocity The velocity or null
  13937. */
  13938. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13939. /**
  13940. * Execute a function with the physics plugin native code
  13941. * Provide a function the will have two variables - the world object and the physics body object
  13942. * @param func The function to execute with the physics plugin native code
  13943. */
  13944. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13945. /**
  13946. * Register a function that will be executed before the physics world is stepping forward
  13947. * @param func The function to execute before the physics world is stepped forward
  13948. */
  13949. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13950. /**
  13951. * Unregister a function that will be executed before the physics world is stepping forward
  13952. * @param func The function to execute before the physics world is stepped forward
  13953. */
  13954. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Register a function that will be executed after the physics step
  13957. * @param func The function to execute after physics step
  13958. */
  13959. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13960. /**
  13961. * Unregisters a function that will be executed after the physics step
  13962. * @param func The function to execute after physics step
  13963. */
  13964. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13965. /**
  13966. * register a function that will be executed when this impostor collides against a different body
  13967. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13968. * @param func Callback that is executed on collision
  13969. */
  13970. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13971. /**
  13972. * Unregisters the physics imposter on contact
  13973. * @param collideAgainst The physics object to collide against
  13974. * @param func Callback to execute on collision
  13975. */
  13976. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13977. private _tmpQuat;
  13978. private _tmpQuat2;
  13979. /**
  13980. * Get the parent rotation
  13981. * @returns The parent rotation
  13982. */
  13983. getParentsRotation(): Quaternion;
  13984. /**
  13985. * this function is executed by the physics engine.
  13986. */
  13987. beforeStep: () => void;
  13988. /**
  13989. * this function is executed by the physics engine
  13990. */
  13991. afterStep: () => void;
  13992. /**
  13993. * Legacy collision detection event support
  13994. */
  13995. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13996. /**
  13997. * event and body object due to cannon's event-based architecture.
  13998. */
  13999. onCollide: (e: {
  14000. body: any;
  14001. }) => void;
  14002. /**
  14003. * Apply a force
  14004. * @param force The force to apply
  14005. * @param contactPoint The contact point for the force
  14006. * @returns The physics imposter
  14007. */
  14008. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14009. /**
  14010. * Apply an impulse
  14011. * @param force The impulse force
  14012. * @param contactPoint The contact point for the impulse force
  14013. * @returns The physics imposter
  14014. */
  14015. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14016. /**
  14017. * A help function to create a joint
  14018. * @param otherImpostor A physics imposter used to create a joint
  14019. * @param jointType The type of joint
  14020. * @param jointData The data for the joint
  14021. * @returns The physics imposter
  14022. */
  14023. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14024. /**
  14025. * Add a joint to this impostor with a different impostor
  14026. * @param otherImpostor A physics imposter used to add a joint
  14027. * @param joint The joint to add
  14028. * @returns The physics imposter
  14029. */
  14030. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14031. /**
  14032. * Add an anchor to a cloth impostor
  14033. * @param otherImpostor rigid impostor to anchor to
  14034. * @param width ratio across width from 0 to 1
  14035. * @param height ratio up height from 0 to 1
  14036. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14037. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14038. * @returns impostor the soft imposter
  14039. */
  14040. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14041. /**
  14042. * Add a hook to a rope impostor
  14043. * @param otherImpostor rigid impostor to anchor to
  14044. * @param length ratio across rope from 0 to 1
  14045. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14046. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14047. * @returns impostor the rope imposter
  14048. */
  14049. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14050. /**
  14051. * Will keep this body still, in a sleep mode.
  14052. * @returns the physics imposter
  14053. */
  14054. sleep(): PhysicsImpostor;
  14055. /**
  14056. * Wake the body up.
  14057. * @returns The physics imposter
  14058. */
  14059. wakeUp(): PhysicsImpostor;
  14060. /**
  14061. * Clones the physics imposter
  14062. * @param newObject The physics imposter clones to this physics-enabled object
  14063. * @returns A nullable physics imposter
  14064. */
  14065. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14066. /**
  14067. * Disposes the physics imposter
  14068. */
  14069. dispose(): void;
  14070. /**
  14071. * Sets the delta position
  14072. * @param position The delta position amount
  14073. */
  14074. setDeltaPosition(position: Vector3): void;
  14075. /**
  14076. * Sets the delta rotation
  14077. * @param rotation The delta rotation amount
  14078. */
  14079. setDeltaRotation(rotation: Quaternion): void;
  14080. /**
  14081. * Gets the box size of the physics imposter and stores the result in the input parameter
  14082. * @param result Stores the box size
  14083. * @returns The physics imposter
  14084. */
  14085. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14086. /**
  14087. * Gets the radius of the physics imposter
  14088. * @returns Radius of the physics imposter
  14089. */
  14090. getRadius(): number;
  14091. /**
  14092. * Sync a bone with this impostor
  14093. * @param bone The bone to sync to the impostor.
  14094. * @param boneMesh The mesh that the bone is influencing.
  14095. * @param jointPivot The pivot of the joint / bone in local space.
  14096. * @param distToJoint Optional distance from the impostor to the joint.
  14097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14098. */
  14099. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14100. /**
  14101. * Sync impostor to a bone
  14102. * @param bone The bone that the impostor will be synced to.
  14103. * @param boneMesh The mesh that the bone is influencing.
  14104. * @param jointPivot The pivot of the joint / bone in local space.
  14105. * @param distToJoint Optional distance from the impostor to the joint.
  14106. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14107. * @param boneAxis Optional vector3 axis the bone is aligned with
  14108. */
  14109. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14110. /**
  14111. * No-Imposter type
  14112. */
  14113. static NoImpostor: number;
  14114. /**
  14115. * Sphere-Imposter type
  14116. */
  14117. static SphereImpostor: number;
  14118. /**
  14119. * Box-Imposter type
  14120. */
  14121. static BoxImpostor: number;
  14122. /**
  14123. * Plane-Imposter type
  14124. */
  14125. static PlaneImpostor: number;
  14126. /**
  14127. * Mesh-imposter type
  14128. */
  14129. static MeshImpostor: number;
  14130. /**
  14131. * Capsule-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static CapsuleImpostor: number;
  14134. /**
  14135. * Cylinder-Imposter type
  14136. */
  14137. static CylinderImpostor: number;
  14138. /**
  14139. * Particle-Imposter type
  14140. */
  14141. static ParticleImpostor: number;
  14142. /**
  14143. * Heightmap-Imposter type
  14144. */
  14145. static HeightmapImpostor: number;
  14146. /**
  14147. * ConvexHull-Impostor type (Ammo.js plugin only)
  14148. */
  14149. static ConvexHullImpostor: number;
  14150. /**
  14151. * Rope-Imposter type
  14152. */
  14153. static RopeImpostor: number;
  14154. /**
  14155. * Cloth-Imposter type
  14156. */
  14157. static ClothImpostor: number;
  14158. /**
  14159. * Softbody-Imposter type
  14160. */
  14161. static SoftbodyImpostor: number;
  14162. }
  14163. }
  14164. declare module "babylonjs/Meshes/mesh" {
  14165. import { Observable } from "babylonjs/Misc/observable";
  14166. import { IAnimatable } from "babylonjs/Misc/tools";
  14167. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14168. import { Camera } from "babylonjs/Cameras/camera";
  14169. import { Scene } from "babylonjs/scene";
  14170. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14171. import { Engine } from "babylonjs/Engines/engine";
  14172. import { Node } from "babylonjs/node";
  14173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14174. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14175. import { Buffer } from "babylonjs/Meshes/buffer";
  14176. import { Geometry } from "babylonjs/Meshes/geometry";
  14177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14179. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14180. import { Effect } from "babylonjs/Materials/effect";
  14181. import { Material } from "babylonjs/Materials/material";
  14182. import { Skeleton } from "babylonjs/Bones/skeleton";
  14183. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14184. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14185. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14186. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14187. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14188. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14189. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14190. /**
  14191. * @hidden
  14192. **/
  14193. export class _CreationDataStorage {
  14194. closePath?: boolean;
  14195. closeArray?: boolean;
  14196. idx: number[];
  14197. dashSize: number;
  14198. gapSize: number;
  14199. path3D: Path3D;
  14200. pathArray: Vector3[][];
  14201. arc: number;
  14202. radius: number;
  14203. cap: number;
  14204. tessellation: number;
  14205. }
  14206. /**
  14207. * @hidden
  14208. **/
  14209. class _InstanceDataStorage {
  14210. visibleInstances: any;
  14211. batchCache: _InstancesBatch;
  14212. instancesBufferSize: number;
  14213. instancesBuffer: Nullable<Buffer>;
  14214. instancesData: Float32Array;
  14215. overridenInstanceCount: number;
  14216. isFrozen: boolean;
  14217. previousBatch: Nullable<_InstancesBatch>;
  14218. hardwareInstancedRendering: boolean;
  14219. sideOrientation: number;
  14220. }
  14221. /**
  14222. * @hidden
  14223. **/
  14224. export class _InstancesBatch {
  14225. mustReturn: boolean;
  14226. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14227. renderSelf: boolean[];
  14228. hardwareInstancedRendering: boolean[];
  14229. }
  14230. /**
  14231. * Class used to represent renderable models
  14232. */
  14233. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14234. /**
  14235. * Mesh side orientation : usually the external or front surface
  14236. */
  14237. static readonly FRONTSIDE: number;
  14238. /**
  14239. * Mesh side orientation : usually the internal or back surface
  14240. */
  14241. static readonly BACKSIDE: number;
  14242. /**
  14243. * Mesh side orientation : both internal and external or front and back surfaces
  14244. */
  14245. static readonly DOUBLESIDE: number;
  14246. /**
  14247. * Mesh side orientation : by default, `FRONTSIDE`
  14248. */
  14249. static readonly DEFAULTSIDE: number;
  14250. /**
  14251. * Mesh cap setting : no cap
  14252. */
  14253. static readonly NO_CAP: number;
  14254. /**
  14255. * Mesh cap setting : one cap at the beginning of the mesh
  14256. */
  14257. static readonly CAP_START: number;
  14258. /**
  14259. * Mesh cap setting : one cap at the end of the mesh
  14260. */
  14261. static readonly CAP_END: number;
  14262. /**
  14263. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14264. */
  14265. static readonly CAP_ALL: number;
  14266. /**
  14267. * Mesh pattern setting : no flip or rotate
  14268. */
  14269. static readonly NO_FLIP: number;
  14270. /**
  14271. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14276. */
  14277. static readonly ROTATE_TILE: number;
  14278. /**
  14279. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14280. */
  14281. static readonly FLIP_ROW: number;
  14282. /**
  14283. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14284. */
  14285. static readonly ROTATE_ROW: number;
  14286. /**
  14287. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14288. */
  14289. static readonly FLIP_N_ROTATE_TILE: number;
  14290. /**
  14291. * Mesh pattern setting : rotate pattern and rotate
  14292. */
  14293. static readonly FLIP_N_ROTATE_ROW: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14296. */
  14297. static readonly CENTER: number;
  14298. /**
  14299. * Mesh tile positioning : part tiles on left
  14300. */
  14301. static readonly LEFT: number;
  14302. /**
  14303. * Mesh tile positioning : part tiles on right
  14304. */
  14305. static readonly RIGHT: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles on top
  14308. */
  14309. static readonly TOP: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on bottom
  14312. */
  14313. static readonly BOTTOM: number;
  14314. /**
  14315. * Gets the default side orientation.
  14316. * @param orientation the orientation to value to attempt to get
  14317. * @returns the default orientation
  14318. * @hidden
  14319. */
  14320. static _GetDefaultSideOrientation(orientation?: number): number;
  14321. private _internalMeshDataInfo;
  14322. /**
  14323. * An event triggered before rendering the mesh
  14324. */
  14325. readonly onBeforeRenderObservable: Observable<Mesh>;
  14326. /**
  14327. * An event triggered before binding the mesh
  14328. */
  14329. readonly onBeforeBindObservable: Observable<Mesh>;
  14330. /**
  14331. * An event triggered after rendering the mesh
  14332. */
  14333. readonly onAfterRenderObservable: Observable<Mesh>;
  14334. /**
  14335. * An event triggered before drawing the mesh
  14336. */
  14337. readonly onBeforeDrawObservable: Observable<Mesh>;
  14338. private _onBeforeDrawObserver;
  14339. /**
  14340. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14341. */
  14342. onBeforeDraw: () => void;
  14343. /**
  14344. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14345. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14346. */
  14347. delayLoadState: number;
  14348. /**
  14349. * Gets the list of instances created from this mesh
  14350. * it is not supposed to be modified manually.
  14351. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14353. */
  14354. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14355. /**
  14356. * Gets the file containing delay loading data for this mesh
  14357. */
  14358. delayLoadingFile: string;
  14359. /** @hidden */
  14360. _binaryInfo: any;
  14361. /**
  14362. * User defined function used to change how LOD level selection is done
  14363. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14364. */
  14365. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14366. /**
  14367. * Gets or sets the morph target manager
  14368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14369. */
  14370. morphTargetManager: Nullable<MorphTargetManager>;
  14371. /** @hidden */
  14372. _creationDataStorage: Nullable<_CreationDataStorage>;
  14373. /** @hidden */
  14374. _geometry: Nullable<Geometry>;
  14375. /** @hidden */
  14376. _delayInfo: Array<string>;
  14377. /** @hidden */
  14378. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14379. /** @hidden */
  14380. _instanceDataStorage: _InstanceDataStorage;
  14381. private _effectiveMaterial;
  14382. /** @hidden */
  14383. _shouldGenerateFlatShading: boolean;
  14384. /** @hidden */
  14385. _originalBuilderSideOrientation: number;
  14386. /**
  14387. * Use this property to change the original side orientation defined at construction time
  14388. */
  14389. overrideMaterialSideOrientation: Nullable<number>;
  14390. /**
  14391. * Gets the source mesh (the one used to clone this one from)
  14392. */
  14393. readonly source: Nullable<Mesh>;
  14394. /**
  14395. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14396. */
  14397. isUnIndexed: boolean;
  14398. /**
  14399. * @constructor
  14400. * @param name The value used by scene.getMeshByName() to do a lookup.
  14401. * @param scene The scene to add this mesh to.
  14402. * @param parent The parent of this mesh, if it has one
  14403. * @param source An optional Mesh from which geometry is shared, cloned.
  14404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14405. * When false, achieved by calling a clone(), also passing False.
  14406. * This will make creation of children, recursive.
  14407. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14408. */
  14409. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14410. /**
  14411. * Gets the class name
  14412. * @returns the string "Mesh".
  14413. */
  14414. getClassName(): string;
  14415. /** @hidden */
  14416. readonly _isMesh: boolean;
  14417. /**
  14418. * Returns a description of this mesh
  14419. * @param fullDetails define if full details about this mesh must be used
  14420. * @returns a descriptive string representing this mesh
  14421. */
  14422. toString(fullDetails?: boolean): string;
  14423. /** @hidden */
  14424. _unBindEffect(): void;
  14425. /**
  14426. * Gets a boolean indicating if this mesh has LOD
  14427. */
  14428. readonly hasLODLevels: boolean;
  14429. /**
  14430. * Gets the list of MeshLODLevel associated with the current mesh
  14431. * @returns an array of MeshLODLevel
  14432. */
  14433. getLODLevels(): MeshLODLevel[];
  14434. private _sortLODLevels;
  14435. /**
  14436. * Add a mesh as LOD level triggered at the given distance.
  14437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14438. * @param distance The distance from the center of the object to show this level
  14439. * @param mesh The mesh to be added as LOD level (can be null)
  14440. * @return This mesh (for chaining)
  14441. */
  14442. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14443. /**
  14444. * Returns the LOD level mesh at the passed distance or null if not found.
  14445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14446. * @param distance The distance from the center of the object to show this level
  14447. * @returns a Mesh or `null`
  14448. */
  14449. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14450. /**
  14451. * Remove a mesh from the LOD array
  14452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14453. * @param mesh defines the mesh to be removed
  14454. * @return This mesh (for chaining)
  14455. */
  14456. removeLODLevel(mesh: Mesh): Mesh;
  14457. /**
  14458. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14460. * @param camera defines the camera to use to compute distance
  14461. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14462. * @return This mesh (for chaining)
  14463. */
  14464. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14465. /**
  14466. * Gets the mesh internal Geometry object
  14467. */
  14468. readonly geometry: Nullable<Geometry>;
  14469. /**
  14470. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14471. * @returns the total number of vertices
  14472. */
  14473. getTotalVertices(): number;
  14474. /**
  14475. * Returns the content of an associated vertex buffer
  14476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14477. * - VertexBuffer.PositionKind
  14478. * - VertexBuffer.UVKind
  14479. * - VertexBuffer.UV2Kind
  14480. * - VertexBuffer.UV3Kind
  14481. * - VertexBuffer.UV4Kind
  14482. * - VertexBuffer.UV5Kind
  14483. * - VertexBuffer.UV6Kind
  14484. * - VertexBuffer.ColorKind
  14485. * - VertexBuffer.MatricesIndicesKind
  14486. * - VertexBuffer.MatricesIndicesExtraKind
  14487. * - VertexBuffer.MatricesWeightsKind
  14488. * - VertexBuffer.MatricesWeightsExtraKind
  14489. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  14490. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14491. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14492. */
  14493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14494. /**
  14495. * Returns the mesh VertexBuffer object from the requested `kind`
  14496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14497. * - VertexBuffer.PositionKind
  14498. * - VertexBuffer.NormalKind
  14499. * - VertexBuffer.UVKind
  14500. * - VertexBuffer.UV2Kind
  14501. * - VertexBuffer.UV3Kind
  14502. * - VertexBuffer.UV4Kind
  14503. * - VertexBuffer.UV5Kind
  14504. * - VertexBuffer.UV6Kind
  14505. * - VertexBuffer.ColorKind
  14506. * - VertexBuffer.MatricesIndicesKind
  14507. * - VertexBuffer.MatricesIndicesExtraKind
  14508. * - VertexBuffer.MatricesWeightsKind
  14509. * - VertexBuffer.MatricesWeightsExtraKind
  14510. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14511. */
  14512. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14513. /**
  14514. * Tests if a specific vertex buffer is associated with this mesh
  14515. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14516. * - VertexBuffer.PositionKind
  14517. * - VertexBuffer.NormalKind
  14518. * - VertexBuffer.UVKind
  14519. * - VertexBuffer.UV2Kind
  14520. * - VertexBuffer.UV3Kind
  14521. * - VertexBuffer.UV4Kind
  14522. * - VertexBuffer.UV5Kind
  14523. * - VertexBuffer.UV6Kind
  14524. * - VertexBuffer.ColorKind
  14525. * - VertexBuffer.MatricesIndicesKind
  14526. * - VertexBuffer.MatricesIndicesExtraKind
  14527. * - VertexBuffer.MatricesWeightsKind
  14528. * - VertexBuffer.MatricesWeightsExtraKind
  14529. * @returns a boolean
  14530. */
  14531. isVerticesDataPresent(kind: string): boolean;
  14532. /**
  14533. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14534. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14535. * - VertexBuffer.PositionKind
  14536. * - VertexBuffer.UVKind
  14537. * - VertexBuffer.UV2Kind
  14538. * - VertexBuffer.UV3Kind
  14539. * - VertexBuffer.UV4Kind
  14540. * - VertexBuffer.UV5Kind
  14541. * - VertexBuffer.UV6Kind
  14542. * - VertexBuffer.ColorKind
  14543. * - VertexBuffer.MatricesIndicesKind
  14544. * - VertexBuffer.MatricesIndicesExtraKind
  14545. * - VertexBuffer.MatricesWeightsKind
  14546. * - VertexBuffer.MatricesWeightsExtraKind
  14547. * @returns a boolean
  14548. */
  14549. isVertexBufferUpdatable(kind: string): boolean;
  14550. /**
  14551. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14552. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14553. * - VertexBuffer.PositionKind
  14554. * - VertexBuffer.NormalKind
  14555. * - VertexBuffer.UVKind
  14556. * - VertexBuffer.UV2Kind
  14557. * - VertexBuffer.UV3Kind
  14558. * - VertexBuffer.UV4Kind
  14559. * - VertexBuffer.UV5Kind
  14560. * - VertexBuffer.UV6Kind
  14561. * - VertexBuffer.ColorKind
  14562. * - VertexBuffer.MatricesIndicesKind
  14563. * - VertexBuffer.MatricesIndicesExtraKind
  14564. * - VertexBuffer.MatricesWeightsKind
  14565. * - VertexBuffer.MatricesWeightsExtraKind
  14566. * @returns an array of strings
  14567. */
  14568. getVerticesDataKinds(): string[];
  14569. /**
  14570. * Returns a positive integer : the total number of indices in this mesh geometry.
  14571. * @returns the numner of indices or zero if the mesh has no geometry.
  14572. */
  14573. getTotalIndices(): number;
  14574. /**
  14575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14576. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  14577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14578. * @returns the indices array or an empty array if the mesh has no geometry
  14579. */
  14580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14581. readonly isBlocked: boolean;
  14582. /**
  14583. * Determine if the current mesh is ready to be rendered
  14584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14585. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14586. * @returns true if all associated assets are ready (material, textures, shaders)
  14587. */
  14588. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14589. /**
  14590. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  14591. */
  14592. readonly areNormalsFrozen: boolean;
  14593. /**
  14594. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  14595. * @returns the current mesh
  14596. */
  14597. freezeNormals(): Mesh;
  14598. /**
  14599. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  14600. * @returns the current mesh
  14601. */
  14602. unfreezeNormals(): Mesh;
  14603. /**
  14604. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14605. */
  14606. overridenInstanceCount: number;
  14607. /** @hidden */
  14608. _preActivate(): Mesh;
  14609. /** @hidden */
  14610. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14611. /** @hidden */
  14612. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14613. /**
  14614. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14615. * This means the mesh underlying bounding box and sphere are recomputed.
  14616. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14617. * @returns the current mesh
  14618. */
  14619. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14620. /** @hidden */
  14621. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14622. /**
  14623. * This function will subdivide the mesh into multiple submeshes
  14624. * @param count defines the expected number of submeshes
  14625. */
  14626. subdivide(count: number): void;
  14627. /**
  14628. * Copy a FloatArray into a specific associated vertex buffer
  14629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14630. * - VertexBuffer.PositionKind
  14631. * - VertexBuffer.UVKind
  14632. * - VertexBuffer.UV2Kind
  14633. * - VertexBuffer.UV3Kind
  14634. * - VertexBuffer.UV4Kind
  14635. * - VertexBuffer.UV5Kind
  14636. * - VertexBuffer.UV6Kind
  14637. * - VertexBuffer.ColorKind
  14638. * - VertexBuffer.MatricesIndicesKind
  14639. * - VertexBuffer.MatricesIndicesExtraKind
  14640. * - VertexBuffer.MatricesWeightsKind
  14641. * - VertexBuffer.MatricesWeightsExtraKind
  14642. * @param data defines the data source
  14643. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14644. * @param stride defines the data stride size (can be null)
  14645. * @returns the current mesh
  14646. */
  14647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14648. /**
  14649. * Flags an associated vertex buffer as updatable
  14650. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14651. * - VertexBuffer.PositionKind
  14652. * - VertexBuffer.UVKind
  14653. * - VertexBuffer.UV2Kind
  14654. * - VertexBuffer.UV3Kind
  14655. * - VertexBuffer.UV4Kind
  14656. * - VertexBuffer.UV5Kind
  14657. * - VertexBuffer.UV6Kind
  14658. * - VertexBuffer.ColorKind
  14659. * - VertexBuffer.MatricesIndicesKind
  14660. * - VertexBuffer.MatricesIndicesExtraKind
  14661. * - VertexBuffer.MatricesWeightsKind
  14662. * - VertexBuffer.MatricesWeightsExtraKind
  14663. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14664. */
  14665. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14666. /**
  14667. * Sets the mesh global Vertex Buffer
  14668. * @param buffer defines the buffer to use
  14669. * @returns the current mesh
  14670. */
  14671. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14672. /**
  14673. * Update a specific associated vertex buffer
  14674. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14675. * - VertexBuffer.PositionKind
  14676. * - VertexBuffer.UVKind
  14677. * - VertexBuffer.UV2Kind
  14678. * - VertexBuffer.UV3Kind
  14679. * - VertexBuffer.UV4Kind
  14680. * - VertexBuffer.UV5Kind
  14681. * - VertexBuffer.UV6Kind
  14682. * - VertexBuffer.ColorKind
  14683. * - VertexBuffer.MatricesIndicesKind
  14684. * - VertexBuffer.MatricesIndicesExtraKind
  14685. * - VertexBuffer.MatricesWeightsKind
  14686. * - VertexBuffer.MatricesWeightsExtraKind
  14687. * @param data defines the data source
  14688. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14689. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  14690. * @returns the current mesh
  14691. */
  14692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14693. /**
  14694. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14695. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14696. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14697. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14698. * @returns the current mesh
  14699. */
  14700. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14701. /**
  14702. * Creates a un-shared specific occurence of the geometry for the mesh.
  14703. * @returns the current mesh
  14704. */
  14705. makeGeometryUnique(): Mesh;
  14706. /**
  14707. * Set the index buffer of this mesh
  14708. * @param indices defines the source data
  14709. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14710. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14711. * @returns the current mesh
  14712. */
  14713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14714. /**
  14715. * Update the current index buffer
  14716. * @param indices defines the source data
  14717. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14718. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  14719. * @returns the current mesh
  14720. */
  14721. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14722. /**
  14723. * Invert the geometry to move from a right handed system to a left handed one.
  14724. * @returns the current mesh
  14725. */
  14726. toLeftHanded(): Mesh;
  14727. /** @hidden */
  14728. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14729. /** @hidden */
  14730. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14731. /**
  14732. * Registers for this mesh a javascript function called just before the rendering process
  14733. * @param func defines the function to call before rendering this mesh
  14734. * @returns the current mesh
  14735. */
  14736. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14737. /**
  14738. * Disposes a previously registered javascript function called before the rendering
  14739. * @param func defines the function to remove
  14740. * @returns the current mesh
  14741. */
  14742. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14743. /**
  14744. * Registers for this mesh a javascript function called just after the rendering is complete
  14745. * @param func defines the function to call after rendering this mesh
  14746. * @returns the current mesh
  14747. */
  14748. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14749. /**
  14750. * Disposes a previously registered javascript function called after the rendering.
  14751. * @param func defines the function to remove
  14752. * @returns the current mesh
  14753. */
  14754. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14755. /** @hidden */
  14756. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14757. /** @hidden */
  14758. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14759. /** @hidden */
  14760. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14761. /** @hidden */
  14762. _rebuild(): void;
  14763. /** @hidden */
  14764. _freeze(): void;
  14765. /** @hidden */
  14766. _unFreeze(): void;
  14767. /**
  14768. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  14769. * @param subMesh defines the subMesh to render
  14770. * @param enableAlphaMode defines if alpha mode can be changed
  14771. * @returns the current mesh
  14772. */
  14773. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14774. private _onBeforeDraw;
  14775. /**
  14776. * Renormalize the mesh and patch it up if there are no weights
  14777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14778. * However in the case of zero weights then we set just a single influence to 1.
  14779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14780. */
  14781. cleanMatrixWeights(): void;
  14782. private normalizeSkinFourWeights;
  14783. private normalizeSkinWeightsAndExtra;
  14784. /**
  14785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14787. * the user know there was an issue with importing the mesh
  14788. * @returns a validation object with skinned, valid and report string
  14789. */
  14790. validateSkinning(): {
  14791. skinned: boolean;
  14792. valid: boolean;
  14793. report: string;
  14794. };
  14795. /** @hidden */
  14796. _checkDelayState(): Mesh;
  14797. private _queueLoad;
  14798. /**
  14799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14800. * A mesh is in the frustum if its bounding box intersects the frustum
  14801. * @param frustumPlanes defines the frustum to test
  14802. * @returns true if the mesh is in the frustum planes
  14803. */
  14804. isInFrustum(frustumPlanes: Plane[]): boolean;
  14805. /**
  14806. * Sets the mesh material by the material or multiMaterial `id` property
  14807. * @param id is a string identifying the material or the multiMaterial
  14808. * @returns the current mesh
  14809. */
  14810. setMaterialByID(id: string): Mesh;
  14811. /**
  14812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14813. * @returns an array of IAnimatable
  14814. */
  14815. getAnimatables(): IAnimatable[];
  14816. /**
  14817. * Modifies the mesh geometry according to the passed transformation matrix.
  14818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14819. * The mesh normals are modified using the same transformation.
  14820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14821. * @param transform defines the transform matrix to use
  14822. * @see http://doc.babylonjs.com/resources/baking_transformations
  14823. * @returns the current mesh
  14824. */
  14825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14826. /**
  14827. * Modifies the mesh geometry according to its own current World Matrix.
  14828. * The mesh World Matrix is then reset.
  14829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14831. * @see http://doc.babylonjs.com/resources/baking_transformations
  14832. * @returns the current mesh
  14833. */
  14834. bakeCurrentTransformIntoVertices(): Mesh;
  14835. /** @hidden */
  14836. readonly _positions: Nullable<Vector3[]>;
  14837. /** @hidden */
  14838. _resetPointsArrayCache(): Mesh;
  14839. /** @hidden */
  14840. _generatePointsArray(): boolean;
  14841. /**
  14842. * Returns a new Mesh object generated from the current mesh properties.
  14843. * This method must not get confused with createInstance()
  14844. * @param name is a string, the name given to the new mesh
  14845. * @param newParent can be any Node object (default `null`)
  14846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14848. * @returns a new mesh
  14849. */
  14850. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14851. /**
  14852. * Releases resources associated with this mesh.
  14853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14855. */
  14856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14857. /**
  14858. * Modifies the mesh geometry according to a displacement map.
  14859. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  14860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14861. * @param url is a string, the URL from the image file is to be downloaded.
  14862. * @param minHeight is the lower limit of the displacement.
  14863. * @param maxHeight is the upper limit of the displacement.
  14864. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  14865. * @param uvOffset is an optional vector2 used to offset UV.
  14866. * @param uvScale is an optional vector2 used to scale UV.
  14867. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  14868. * @returns the Mesh.
  14869. */
  14870. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modifies the mesh geometry according to a displacementMap buffer.
  14873. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  14874. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14875. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14876. * @param heightMapWidth is the width of the buffer image.
  14877. * @param heightMapHeight is the height of the buffer image.
  14878. * @param minHeight is the lower limit of the displacement.
  14879. * @param maxHeight is the upper limit of the displacement.
  14880. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  14881. * @param uvOffset is an optional vector2 used to offset UV.
  14882. * @param uvScale is an optional vector2 used to scale UV.
  14883. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  14884. * @returns the Mesh.
  14885. */
  14886. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14887. /**
  14888. * Modify the mesh to get a flat shading rendering.
  14889. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14890. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14891. * @returns current mesh
  14892. */
  14893. convertToFlatShadedMesh(): Mesh;
  14894. /**
  14895. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14896. * In other words, more vertices, no more indices and a single bigger VBO.
  14897. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14898. * @returns current mesh
  14899. */
  14900. convertToUnIndexedMesh(): Mesh;
  14901. /**
  14902. * Inverses facet orientations.
  14903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14904. * @param flipNormals will also inverts the normals
  14905. * @returns current mesh
  14906. */
  14907. flipFaces(flipNormals?: boolean): Mesh;
  14908. /**
  14909. * Increase the number of facets and hence vertices in a mesh
  14910. * Vertex normals are interpolated from existing vertex normals
  14911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14912. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14913. */
  14914. increaseVertices(numberPerEdge: number): void;
  14915. /**
  14916. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14917. * This will undo any application of covertToFlatShadedMesh
  14918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14919. */
  14920. forceSharedVertices(): void;
  14921. /** @hidden */
  14922. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14923. /** @hidden */
  14924. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14925. /**
  14926. * Creates a new InstancedMesh object from the mesh model.
  14927. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14928. * @param name defines the name of the new instance
  14929. * @returns a new InstancedMesh
  14930. */
  14931. createInstance(name: string): InstancedMesh;
  14932. /**
  14933. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14934. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14935. * @returns the current mesh
  14936. */
  14937. synchronizeInstances(): Mesh;
  14938. /**
  14939. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14940. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14941. * This should be used together with the simplification to avoid disappearing triangles.
  14942. * @param successCallback an optional success callback to be called after the optimization finished.
  14943. * @returns the current mesh
  14944. */
  14945. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14946. /**
  14947. * Serialize current mesh
  14948. * @param serializationObject defines the object which will receive the serialization data
  14949. */
  14950. serialize(serializationObject: any): void;
  14951. /** @hidden */
  14952. _syncGeometryWithMorphTargetManager(): void;
  14953. /** @hidden */
  14954. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14955. /**
  14956. * Returns a new Mesh object parsed from the source provided.
  14957. * @param parsedMesh is the source
  14958. * @param scene defines the hosting scene
  14959. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14960. * @returns a new Mesh
  14961. */
  14962. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14963. /**
  14964. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14965. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14966. * @param name defines the name of the mesh to create
  14967. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14968. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14969. * @param closePath creates a seam between the first and the last points of each path of the path array
  14970. * @param offset is taken in account only if the `pathArray` is containing a single path
  14971. * @param scene defines the hosting scene
  14972. * @param updatable defines if the mesh must be flagged as updatable
  14973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14974. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  14975. * @returns a new Mesh
  14976. */
  14977. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14978. /**
  14979. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14980. * @param name defines the name of the mesh to create
  14981. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14982. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  14983. * @param scene defines the hosting scene
  14984. * @param updatable defines if the mesh must be flagged as updatable
  14985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14986. * @returns a new Mesh
  14987. */
  14988. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14989. /**
  14990. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14991. * @param name defines the name of the mesh to create
  14992. * @param size sets the size (float) of each box side (default 1)
  14993. * @param scene defines the hosting scene
  14994. * @param updatable defines if the mesh must be flagged as updatable
  14995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14996. * @returns a new Mesh
  14997. */
  14998. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14999. /**
  15000. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15001. * @param name defines the name of the mesh to create
  15002. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15003. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15004. * @param scene defines the hosting scene
  15005. * @param updatable defines if the mesh must be flagged as updatable
  15006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15007. * @returns a new Mesh
  15008. */
  15009. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15010. /**
  15011. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15012. * @param name defines the name of the mesh to create
  15013. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15014. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15015. * @param scene defines the hosting scene
  15016. * @returns a new Mesh
  15017. */
  15018. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15019. /**
  15020. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15021. * @param name defines the name of the mesh to create
  15022. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15023. * @param diameterTop set the top cap diameter (floats, default 1)
  15024. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15025. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15026. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15027. * @param scene defines the hosting scene
  15028. * @param updatable defines if the mesh must be flagged as updatable
  15029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15030. * @returns a new Mesh
  15031. */
  15032. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15033. /**
  15034. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15035. * @param name defines the name of the mesh to create
  15036. * @param diameter sets the diameter size (float) of the torus (default 1)
  15037. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15038. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15039. * @param scene defines the hosting scene
  15040. * @param updatable defines if the mesh must be flagged as updatable
  15041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15042. * @returns a new Mesh
  15043. */
  15044. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15045. /**
  15046. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15047. * @param name defines the name of the mesh to create
  15048. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15049. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15050. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15051. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15052. * @param p the number of windings on X axis (positive integers, default 2)
  15053. * @param q the number of windings on Y axis (positive integers, default 3)
  15054. * @param scene defines the hosting scene
  15055. * @param updatable defines if the mesh must be flagged as updatable
  15056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15057. * @returns a new Mesh
  15058. */
  15059. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15060. /**
  15061. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15062. * @param name defines the name of the mesh to create
  15063. * @param points is an array successive Vector3
  15064. * @param scene defines the hosting scene
  15065. * @param updatable defines if the mesh must be flagged as updatable
  15066. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  15067. * @returns a new Mesh
  15068. */
  15069. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15070. /**
  15071. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15072. * @param name defines the name of the mesh to create
  15073. * @param points is an array successive Vector3
  15074. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15075. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15076. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15077. * @param scene defines the hosting scene
  15078. * @param updatable defines if the mesh must be flagged as updatable
  15079. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  15080. * @returns a new Mesh
  15081. */
  15082. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15083. /**
  15084. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15086. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  15087. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15088. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15089. * Remember you can only change the shape positions, not their number when updating a polygon.
  15090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15091. * @param name defines the name of the mesh to create
  15092. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  15093. * @param scene defines the hosting scene
  15094. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15095. * @param updatable defines if the mesh must be flagged as updatable
  15096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15097. * @param earcutInjection can be used to inject your own earcut reference
  15098. * @returns a new Mesh
  15099. */
  15100. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15101. /**
  15102. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15104. * @param name defines the name of the mesh to create
  15105. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  15106. * @param depth defines the height of extrusion
  15107. * @param scene defines the hosting scene
  15108. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15109. * @param updatable defines if the mesh must be flagged as updatable
  15110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15111. * @param earcutInjection can be used to inject your own earcut reference
  15112. * @returns a new Mesh
  15113. */
  15114. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15115. /**
  15116. * Creates an extruded shape mesh.
  15117. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  15118. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15120. * @param name defines the name of the mesh to create
  15121. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  15122. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15123. * @param scale is the value to scale the shape
  15124. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  15125. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  15126. * @param scene defines the hosting scene
  15127. * @param updatable defines if the mesh must be flagged as updatable
  15128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15129. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  15130. * @returns a new Mesh
  15131. */
  15132. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15133. /**
  15134. * Creates an custom extruded shape mesh.
  15135. * The custom extrusion is a parametric shape.
  15136. * It has no predefined shape. Its final shape will depend on the input parameters.
  15137. * Please consider using the same method from the MeshBuilder class instead
  15138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15139. * @param name defines the name of the mesh to create
  15140. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  15141. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15142. * @param scaleFunction is a custom Javascript function called on each path point
  15143. * @param rotationFunction is a custom Javascript function called on each path point
  15144. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15145. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15146. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  15147. * @param scene defines the hosting scene
  15148. * @param updatable defines if the mesh must be flagged as updatable
  15149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15150. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  15151. * @returns a new Mesh
  15152. */
  15153. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15154. /**
  15155. * Creates lathe mesh.
  15156. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15157. * Please consider using the same method from the MeshBuilder class instead
  15158. * @param name defines the name of the mesh to create
  15159. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  15160. * @param radius is the radius value of the lathe
  15161. * @param tessellation is the side number of the lathe.
  15162. * @param scene defines the hosting scene
  15163. * @param updatable defines if the mesh must be flagged as updatable
  15164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15165. * @returns a new Mesh
  15166. */
  15167. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15168. /**
  15169. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15170. * @param name defines the name of the mesh to create
  15171. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15172. * @param scene defines the hosting scene
  15173. * @param updatable defines if the mesh must be flagged as updatable
  15174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15175. * @returns a new Mesh
  15176. */
  15177. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15178. /**
  15179. * Creates a ground mesh.
  15180. * Please consider using the same method from the MeshBuilder class instead
  15181. * @param name defines the name of the mesh to create
  15182. * @param width set the width of the ground
  15183. * @param height set the height of the ground
  15184. * @param subdivisions sets the number of subdivisions per side
  15185. * @param scene defines the hosting scene
  15186. * @param updatable defines if the mesh must be flagged as updatable
  15187. * @returns a new Mesh
  15188. */
  15189. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15190. /**
  15191. * Creates a tiled ground mesh.
  15192. * Please consider using the same method from the MeshBuilder class instead
  15193. * @param name defines the name of the mesh to create
  15194. * @param xmin set the ground minimum X coordinate
  15195. * @param zmin set the ground minimum Y coordinate
  15196. * @param xmax set the ground maximum X coordinate
  15197. * @param zmax set the ground maximum Z coordinate
  15198. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  15199. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  15200. * @param scene defines the hosting scene
  15201. * @param updatable defines if the mesh must be flagged as updatable
  15202. * @returns a new Mesh
  15203. */
  15204. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15205. w: number;
  15206. h: number;
  15207. }, precision: {
  15208. w: number;
  15209. h: number;
  15210. }, scene: Scene, updatable?: boolean): Mesh;
  15211. /**
  15212. * Creates a ground mesh from a height map.
  15213. * Please consider using the same method from the MeshBuilder class instead
  15214. * @see http://doc.babylonjs.com/babylon101/height_map
  15215. * @param name defines the name of the mesh to create
  15216. * @param url sets the URL of the height map image resource
  15217. * @param width set the ground width size
  15218. * @param height set the ground height size
  15219. * @param subdivisions sets the number of subdivision per side
  15220. * @param minHeight is the minimum altitude on the ground
  15221. * @param maxHeight is the maximum altitude on the ground
  15222. * @param scene defines the hosting scene
  15223. * @param updatable defines if the mesh must be flagged as updatable
  15224. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15225. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15226. * @returns a new Mesh
  15227. */
  15228. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  15229. /**
  15230. * Creates a tube mesh.
  15231. * The tube is a parametric shape.
  15232. * It has no predefined shape. Its final shape will depend on the input parameters.
  15233. * Please consider using the same method from the MeshBuilder class instead
  15234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15235. * @param name defines the name of the mesh to create
  15236. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15237. * @param radius sets the tube radius size
  15238. * @param tessellation is the number of sides on the tubular surface
  15239. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  15240. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  15241. * @param scene defines the hosting scene
  15242. * @param updatable defines if the mesh must be flagged as updatable
  15243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15244. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  15245. * @returns a new Mesh
  15246. */
  15247. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15248. (i: number, distance: number): number;
  15249. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15250. /**
  15251. * Creates a polyhedron mesh.
  15252. * Please consider using the same method from the MeshBuilder class instead.
  15253. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  15254. * * The parameter `size` (positive float, default 1) sets the polygon size
  15255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15256. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  15257. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  15258. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  15259. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  15260. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  15261. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  15263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15264. * @param name defines the name of the mesh to create
  15265. * @param options defines the options used to create the mesh
  15266. * @param scene defines the hosting scene
  15267. * @returns a new Mesh
  15268. */
  15269. static CreatePolyhedron(name: string, options: {
  15270. type?: number;
  15271. size?: number;
  15272. sizeX?: number;
  15273. sizeY?: number;
  15274. sizeZ?: number;
  15275. custom?: any;
  15276. faceUV?: Vector4[];
  15277. faceColors?: Color4[];
  15278. updatable?: boolean;
  15279. sideOrientation?: number;
  15280. }, scene: Scene): Mesh;
  15281. /**
  15282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15284. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  15285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15286. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  15287. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  15289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15290. * @param name defines the name of the mesh
  15291. * @param options defines the options used to create the mesh
  15292. * @param scene defines the hosting scene
  15293. * @returns a new Mesh
  15294. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15295. */
  15296. static CreateIcoSphere(name: string, options: {
  15297. radius?: number;
  15298. flat?: boolean;
  15299. subdivisions?: number;
  15300. sideOrientation?: number;
  15301. updatable?: boolean;
  15302. }, scene: Scene): Mesh;
  15303. /**
  15304. * Creates a decal mesh.
  15305. * Please consider using the same method from the MeshBuilder class instead.
  15306. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15307. * @param name defines the name of the mesh
  15308. * @param sourceMesh defines the mesh receiving the decal
  15309. * @param position sets the position of the decal in world coordinates
  15310. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15311. * @param size sets the decal scaling
  15312. * @param angle sets the angle to rotate the decal
  15313. * @returns a new Mesh
  15314. */
  15315. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15316. /**
  15317. * Prepare internal position array for software CPU skinning
  15318. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15319. */
  15320. setPositionsForCPUSkinning(): Float32Array;
  15321. /**
  15322. * Prepare internal normal array for software CPU skinning
  15323. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15324. */
  15325. setNormalsForCPUSkinning(): Float32Array;
  15326. /**
  15327. * Updates the vertex buffer by applying transformation from the bones
  15328. * @param skeleton defines the skeleton to apply to current mesh
  15329. * @returns the current mesh
  15330. */
  15331. applySkeleton(skeleton: Skeleton): Mesh;
  15332. /**
  15333. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  15334. * @param meshes defines the list of meshes to scan
  15335. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15336. */
  15337. static MinMax(meshes: AbstractMesh[]): {
  15338. min: Vector3;
  15339. max: Vector3;
  15340. };
  15341. /**
  15342. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15343. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15344. * @returns a vector3
  15345. */
  15346. static Center(meshesOrMinMaxVector: {
  15347. min: Vector3;
  15348. max: Vector3;
  15349. } | AbstractMesh[]): Vector3;
  15350. /**
  15351. * Merge the array of meshes into a single mesh for performance reasons.
  15352. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15353. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15354. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15355. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15356. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15357. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15358. * @returns a new mesh
  15359. */
  15360. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15361. /** @hidden */
  15362. addInstance(instance: InstancedMesh): void;
  15363. /** @hidden */
  15364. removeInstance(instance: InstancedMesh): void;
  15365. }
  15366. }
  15367. declare module "babylonjs/Actions/action" {
  15368. import { Observable } from "babylonjs/Misc/observable";
  15369. import { Condition } from "babylonjs/Actions/condition";
  15370. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15371. import { ActionManager } from "babylonjs/Actions/actionManager";
  15372. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15373. /**
  15374. * Interface used to define Action
  15375. */
  15376. export interface IAction {
  15377. /**
  15378. * Trigger for the action
  15379. */
  15380. trigger: number;
  15381. /** Options of the trigger */
  15382. triggerOptions: any;
  15383. /**
  15384. * Gets the trigger parameters
  15385. * @returns the trigger parameters
  15386. */
  15387. getTriggerParameter(): any;
  15388. /**
  15389. * Internal only - executes current action event
  15390. * @hidden
  15391. */
  15392. _executeCurrent(evt?: ActionEvent): void;
  15393. /**
  15394. * Serialize placeholder for child classes
  15395. * @param parent of child
  15396. * @returns the serialized object
  15397. */
  15398. serialize(parent: any): any;
  15399. /**
  15400. * Internal only
  15401. * @hidden
  15402. */
  15403. _prepare(): void;
  15404. /**
  15405. * Internal only - manager for action
  15406. * @hidden
  15407. */
  15408. _actionManager: AbstractActionManager;
  15409. /**
  15410. * Adds action to chain of actions, may be a DoNothingAction
  15411. * @param action defines the next action to execute
  15412. * @returns The action passed in
  15413. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15414. */
  15415. then(action: IAction): IAction;
  15416. }
  15417. /**
  15418. * The action to be carried out following a trigger
  15419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15420. */
  15421. export class Action implements IAction {
  15422. /** the trigger, with or without parameters, for the action */
  15423. triggerOptions: any;
  15424. /**
  15425. * Trigger for the action
  15426. */
  15427. trigger: number;
  15428. /**
  15429. * Internal only - manager for action
  15430. * @hidden
  15431. */
  15432. _actionManager: ActionManager;
  15433. private _nextActiveAction;
  15434. private _child;
  15435. private _condition?;
  15436. private _triggerParameter;
  15437. /**
  15438. * An event triggered prior to action being executed.
  15439. */
  15440. onBeforeExecuteObservable: Observable<Action>;
  15441. /**
  15442. * Creates a new Action
  15443. * @param triggerOptions the trigger, with or without parameters, for the action
  15444. * @param condition an optional determinant of action
  15445. */
  15446. constructor(
  15447. /** the trigger, with or without parameters, for the action */
  15448. triggerOptions: any, condition?: Condition);
  15449. /**
  15450. * Internal only
  15451. * @hidden
  15452. */
  15453. _prepare(): void;
  15454. /**
  15455. * Gets the trigger parameters
  15456. * @returns the trigger parameters
  15457. */
  15458. getTriggerParameter(): any;
  15459. /**
  15460. * Internal only - executes current action event
  15461. * @hidden
  15462. */
  15463. _executeCurrent(evt?: ActionEvent): void;
  15464. /**
  15465. * Execute placeholder for child classes
  15466. * @param evt optional action event
  15467. */
  15468. execute(evt?: ActionEvent): void;
  15469. /**
  15470. * Skips to next active action
  15471. */
  15472. skipToNextActiveAction(): void;
  15473. /**
  15474. * Adds action to chain of actions, may be a DoNothingAction
  15475. * @param action defines the next action to execute
  15476. * @returns The action passed in
  15477. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15478. */
  15479. then(action: Action): Action;
  15480. /**
  15481. * Internal only
  15482. * @hidden
  15483. */
  15484. _getProperty(propertyPath: string): string;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. _getEffectiveTarget(target: any, propertyPath: string): any;
  15490. /**
  15491. * Serialize placeholder for child classes
  15492. * @param parent of child
  15493. * @returns the serialized object
  15494. */
  15495. serialize(parent: any): any;
  15496. /**
  15497. * Internal only called by serialize
  15498. * @hidden
  15499. */
  15500. protected _serialize(serializedAction: any, parent?: any): any;
  15501. /**
  15502. * Internal only
  15503. * @hidden
  15504. */
  15505. static _SerializeValueAsString: (value: any) => string;
  15506. /**
  15507. * Internal only
  15508. * @hidden
  15509. */
  15510. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15511. name: string;
  15512. targetType: string;
  15513. value: string;
  15514. };
  15515. }
  15516. }
  15517. declare module "babylonjs/Actions/condition" {
  15518. import { ActionManager } from "babylonjs/Actions/actionManager";
  15519. /**
  15520. * A Condition applied to an Action
  15521. */
  15522. export class Condition {
  15523. /**
  15524. * Internal only - manager for action
  15525. * @hidden
  15526. */
  15527. _actionManager: ActionManager;
  15528. /**
  15529. * Internal only
  15530. * @hidden
  15531. */
  15532. _evaluationId: number;
  15533. /**
  15534. * Internal only
  15535. * @hidden
  15536. */
  15537. _currentResult: boolean;
  15538. /**
  15539. * Creates a new Condition
  15540. * @param actionManager the manager of the action the condition is applied to
  15541. */
  15542. constructor(actionManager: ActionManager);
  15543. /**
  15544. * Check if the current condition is valid
  15545. * @returns a boolean
  15546. */
  15547. isValid(): boolean;
  15548. /**
  15549. * Internal only
  15550. * @hidden
  15551. */
  15552. _getProperty(propertyPath: string): string;
  15553. /**
  15554. * Internal only
  15555. * @hidden
  15556. */
  15557. _getEffectiveTarget(target: any, propertyPath: string): any;
  15558. /**
  15559. * Serialize placeholder for child classes
  15560. * @returns the serialized object
  15561. */
  15562. serialize(): any;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. protected _serialize(serializedCondition: any): any;
  15568. }
  15569. /**
  15570. * Defines specific conditional operators as extensions of Condition
  15571. */
  15572. export class ValueCondition extends Condition {
  15573. /** path to specify the property of the target the conditional operator uses */
  15574. propertyPath: string;
  15575. /** the value compared by the conditional operator against the current value of the property */
  15576. value: any;
  15577. /** the conditional operator, default ValueCondition.IsEqual */
  15578. operator: number;
  15579. /**
  15580. * Internal only
  15581. * @hidden
  15582. */
  15583. private static _IsEqual;
  15584. /**
  15585. * Internal only
  15586. * @hidden
  15587. */
  15588. private static _IsDifferent;
  15589. /**
  15590. * Internal only
  15591. * @hidden
  15592. */
  15593. private static _IsGreater;
  15594. /**
  15595. * Internal only
  15596. * @hidden
  15597. */
  15598. private static _IsLesser;
  15599. /**
  15600. * returns the number for IsEqual
  15601. */
  15602. static readonly IsEqual: number;
  15603. /**
  15604. * Returns the number for IsDifferent
  15605. */
  15606. static readonly IsDifferent: number;
  15607. /**
  15608. * Returns the number for IsGreater
  15609. */
  15610. static readonly IsGreater: number;
  15611. /**
  15612. * Returns the number for IsLesser
  15613. */
  15614. static readonly IsLesser: number;
  15615. /**
  15616. * Internal only The action manager for the condition
  15617. * @hidden
  15618. */
  15619. _actionManager: ActionManager;
  15620. /**
  15621. * Internal only
  15622. * @hidden
  15623. */
  15624. private _target;
  15625. /**
  15626. * Internal only
  15627. * @hidden
  15628. */
  15629. private _effectiveTarget;
  15630. /**
  15631. * Internal only
  15632. * @hidden
  15633. */
  15634. private _property;
  15635. /**
  15636. * Creates a new ValueCondition
  15637. * @param actionManager manager for the action the condition applies to
  15638. * @param target for the action
  15639. * @param propertyPath path to specify the property of the target the conditional operator uses
  15640. * @param value the value compared by the conditional operator against the current value of the property
  15641. * @param operator the conditional operator, default ValueCondition.IsEqual
  15642. */
  15643. constructor(actionManager: ActionManager, target: any,
  15644. /** path to specify the property of the target the conditional operator uses */
  15645. propertyPath: string,
  15646. /** the value compared by the conditional operator against the current value of the property */
  15647. value: any,
  15648. /** the conditional operator, default ValueCondition.IsEqual */
  15649. operator?: number);
  15650. /**
  15651. * Compares the given value with the property value for the specified conditional operator
  15652. * @returns the result of the comparison
  15653. */
  15654. isValid(): boolean;
  15655. /**
  15656. * Serialize the ValueCondition into a JSON compatible object
  15657. * @returns serialization object
  15658. */
  15659. serialize(): any;
  15660. /**
  15661. * Gets the name of the conditional operator for the ValueCondition
  15662. * @param operator the conditional operator
  15663. * @returns the name
  15664. */
  15665. static GetOperatorName(operator: number): string;
  15666. }
  15667. /**
  15668. * Defines a predicate condition as an extension of Condition
  15669. */
  15670. export class PredicateCondition extends Condition {
  15671. /** defines the predicate function used to validate the condition */
  15672. predicate: () => boolean;
  15673. /**
  15674. * Internal only - manager for action
  15675. * @hidden
  15676. */
  15677. _actionManager: ActionManager;
  15678. /**
  15679. * Creates a new PredicateCondition
  15680. * @param actionManager manager for the action the condition applies to
  15681. * @param predicate defines the predicate function used to validate the condition
  15682. */
  15683. constructor(actionManager: ActionManager,
  15684. /** defines the predicate function used to validate the condition */
  15685. predicate: () => boolean);
  15686. /**
  15687. * @returns the validity of the predicate condition
  15688. */
  15689. isValid(): boolean;
  15690. }
  15691. /**
  15692. * Defines a state condition as an extension of Condition
  15693. */
  15694. export class StateCondition extends Condition {
  15695. /** Value to compare with target state */
  15696. value: string;
  15697. /**
  15698. * Internal only - manager for action
  15699. * @hidden
  15700. */
  15701. _actionManager: ActionManager;
  15702. /**
  15703. * Internal only
  15704. * @hidden
  15705. */
  15706. private _target;
  15707. /**
  15708. * Creates a new StateCondition
  15709. * @param actionManager manager for the action the condition applies to
  15710. * @param target of the condition
  15711. * @param value to compare with target state
  15712. */
  15713. constructor(actionManager: ActionManager, target: any,
  15714. /** Value to compare with target state */
  15715. value: string);
  15716. /**
  15717. * Gets a boolean indicating if the current condition is met
  15718. * @returns the validity of the state
  15719. */
  15720. isValid(): boolean;
  15721. /**
  15722. * Serialize the StateCondition into a JSON compatible object
  15723. * @returns serialization object
  15724. */
  15725. serialize(): any;
  15726. }
  15727. }
  15728. declare module "babylonjs/Actions/directActions" {
  15729. import { Action } from "babylonjs/Actions/action";
  15730. import { Condition } from "babylonjs/Actions/condition";
  15731. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15732. /**
  15733. * This defines an action responsible to toggle a boolean once triggered.
  15734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15735. */
  15736. export class SwitchBooleanAction extends Action {
  15737. /**
  15738. * The path to the boolean property in the target object
  15739. */
  15740. propertyPath: string;
  15741. private _target;
  15742. private _effectiveTarget;
  15743. private _property;
  15744. /**
  15745. * Instantiate the action
  15746. * @param triggerOptions defines the trigger options
  15747. * @param target defines the object containing the boolean
  15748. * @param propertyPath defines the path to the boolean property in the target object
  15749. * @param condition defines the trigger related conditions
  15750. */
  15751. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15752. /** @hidden */
  15753. _prepare(): void;
  15754. /**
  15755. * Execute the action toggle the boolean value.
  15756. */
  15757. execute(): void;
  15758. /**
  15759. * Serializes the actions and its related information.
  15760. * @param parent defines the object to serialize in
  15761. * @returns the serialized object
  15762. */
  15763. serialize(parent: any): any;
  15764. }
  15765. /**
  15766. * This defines an action responsible to set a the state field of the target
  15767. * to a desired value once triggered.
  15768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15769. */
  15770. export class SetStateAction extends Action {
  15771. /**
  15772. * The value to store in the state field.
  15773. */
  15774. value: string;
  15775. private _target;
  15776. /**
  15777. * Instantiate the action
  15778. * @param triggerOptions defines the trigger options
  15779. * @param target defines the object containing the state property
  15780. * @param value defines the value to store in the state field
  15781. * @param condition defines the trigger related conditions
  15782. */
  15783. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15784. /**
  15785. * Execute the action and store the value on the target state property.
  15786. */
  15787. execute(): void;
  15788. /**
  15789. * Serializes the actions and its related information.
  15790. * @param parent defines the object to serialize in
  15791. * @returns the serialized object
  15792. */
  15793. serialize(parent: any): any;
  15794. }
  15795. /**
  15796. * This defines an action responsible to set a property of the target
  15797. * to a desired value once triggered.
  15798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15799. */
  15800. export class SetValueAction extends Action {
  15801. /**
  15802. * The path of the property to set in the target.
  15803. */
  15804. propertyPath: string;
  15805. /**
  15806. * The value to set in the property
  15807. */
  15808. value: any;
  15809. private _target;
  15810. private _effectiveTarget;
  15811. private _property;
  15812. /**
  15813. * Instantiate the action
  15814. * @param triggerOptions defines the trigger options
  15815. * @param target defines the object containing the property
  15816. * @param propertyPath defines the path of the property to set in the target
  15817. * @param value defines the value to set in the property
  15818. * @param condition defines the trigger related conditions
  15819. */
  15820. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15821. /** @hidden */
  15822. _prepare(): void;
  15823. /**
  15824. * Execute the action and set the targetted property to the desired value.
  15825. */
  15826. execute(): void;
  15827. /**
  15828. * Serializes the actions and its related information.
  15829. * @param parent defines the object to serialize in
  15830. * @returns the serialized object
  15831. */
  15832. serialize(parent: any): any;
  15833. }
  15834. /**
  15835. * This defines an action responsible to increment the target value
  15836. * to a desired value once triggered.
  15837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15838. */
  15839. export class IncrementValueAction extends Action {
  15840. /**
  15841. * The path of the property to increment in the target.
  15842. */
  15843. propertyPath: string;
  15844. /**
  15845. * The value we should increment the property by.
  15846. */
  15847. value: any;
  15848. private _target;
  15849. private _effectiveTarget;
  15850. private _property;
  15851. /**
  15852. * Instantiate the action
  15853. * @param triggerOptions defines the trigger options
  15854. * @param target defines the object containing the property
  15855. * @param propertyPath defines the path of the property to increment in the target
  15856. * @param value defines the value value we should increment the property by
  15857. * @param condition defines the trigger related conditions
  15858. */
  15859. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15860. /** @hidden */
  15861. _prepare(): void;
  15862. /**
  15863. * Execute the action and increment the target of the value amount.
  15864. */
  15865. execute(): void;
  15866. /**
  15867. * Serializes the actions and its related information.
  15868. * @param parent defines the object to serialize in
  15869. * @returns the serialized object
  15870. */
  15871. serialize(parent: any): any;
  15872. }
  15873. /**
  15874. * This defines an action responsible to start an animation once triggered.
  15875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15876. */
  15877. export class PlayAnimationAction extends Action {
  15878. /**
  15879. * Where the animation should start (animation frame)
  15880. */
  15881. from: number;
  15882. /**
  15883. * Where the animation should stop (animation frame)
  15884. */
  15885. to: number;
  15886. /**
  15887. * Define if the animation should loop or stop after the first play.
  15888. */
  15889. loop?: boolean;
  15890. private _target;
  15891. /**
  15892. * Instantiate the action
  15893. * @param triggerOptions defines the trigger options
  15894. * @param target defines the target animation or animation name
  15895. * @param from defines from where the animation should start (animation frame)
  15896. * @param end defines where the animation should stop (animation frame)
  15897. * @param loop defines if the animation should loop or stop after the first play
  15898. * @param condition defines the trigger related conditions
  15899. */
  15900. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15901. /** @hidden */
  15902. _prepare(): void;
  15903. /**
  15904. * Execute the action and play the animation.
  15905. */
  15906. execute(): void;
  15907. /**
  15908. * Serializes the actions and its related information.
  15909. * @param parent defines the object to serialize in
  15910. * @returns the serialized object
  15911. */
  15912. serialize(parent: any): any;
  15913. }
  15914. /**
  15915. * This defines an action responsible to stop an animation once triggered.
  15916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15917. */
  15918. export class StopAnimationAction extends Action {
  15919. private _target;
  15920. /**
  15921. * Instantiate the action
  15922. * @param triggerOptions defines the trigger options
  15923. * @param target defines the target animation or animation name
  15924. * @param condition defines the trigger related conditions
  15925. */
  15926. constructor(triggerOptions: any, target: any, condition?: Condition);
  15927. /** @hidden */
  15928. _prepare(): void;
  15929. /**
  15930. * Execute the action and stop the animation.
  15931. */
  15932. execute(): void;
  15933. /**
  15934. * Serializes the actions and its related information.
  15935. * @param parent defines the object to serialize in
  15936. * @returns the serialized object
  15937. */
  15938. serialize(parent: any): any;
  15939. }
  15940. /**
  15941. * This defines an action responsible that does nothing once triggered.
  15942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15943. */
  15944. export class DoNothingAction extends Action {
  15945. /**
  15946. * Instantiate the action
  15947. * @param triggerOptions defines the trigger options
  15948. * @param condition defines the trigger related conditions
  15949. */
  15950. constructor(triggerOptions?: any, condition?: Condition);
  15951. /**
  15952. * Execute the action and do nothing.
  15953. */
  15954. execute(): void;
  15955. /**
  15956. * Serializes the actions and its related information.
  15957. * @param parent defines the object to serialize in
  15958. * @returns the serialized object
  15959. */
  15960. serialize(parent: any): any;
  15961. }
  15962. /**
  15963. * This defines an action responsible to trigger several actions once triggered.
  15964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15965. */
  15966. export class CombineAction extends Action {
  15967. /**
  15968. * The list of aggregated animations to run.
  15969. */
  15970. children: Action[];
  15971. /**
  15972. * Instantiate the action
  15973. * @param triggerOptions defines the trigger options
  15974. * @param children defines the list of aggregated animations to run
  15975. * @param condition defines the trigger related conditions
  15976. */
  15977. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15978. /** @hidden */
  15979. _prepare(): void;
  15980. /**
  15981. * Execute the action and executes all the aggregated actions.
  15982. */
  15983. execute(evt: ActionEvent): void;
  15984. /**
  15985. * Serializes the actions and its related information.
  15986. * @param parent defines the object to serialize in
  15987. * @returns the serialized object
  15988. */
  15989. serialize(parent: any): any;
  15990. }
  15991. /**
  15992. * This defines an action responsible to run code (external event) once triggered.
  15993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15994. */
  15995. export class ExecuteCodeAction extends Action {
  15996. /**
  15997. * The callback function to run.
  15998. */
  15999. func: (evt: ActionEvent) => void;
  16000. /**
  16001. * Instantiate the action
  16002. * @param triggerOptions defines the trigger options
  16003. * @param func defines the callback function to run
  16004. * @param condition defines the trigger related conditions
  16005. */
  16006. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16007. /**
  16008. * Execute the action and run the attached code.
  16009. */
  16010. execute(evt: ActionEvent): void;
  16011. }
  16012. /**
  16013. * This defines an action responsible to set the parent property of the target once triggered.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16015. */
  16016. export class SetParentAction extends Action {
  16017. private _parent;
  16018. private _target;
  16019. /**
  16020. * Instantiate the action
  16021. * @param triggerOptions defines the trigger options
  16022. * @param target defines the target containing the parent property
  16023. * @param parent defines from where the animation should start (animation frame)
  16024. * @param condition defines the trigger related conditions
  16025. */
  16026. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16027. /** @hidden */
  16028. _prepare(): void;
  16029. /**
  16030. * Execute the action and set the parent property.
  16031. */
  16032. execute(): void;
  16033. /**
  16034. * Serializes the actions and its related information.
  16035. * @param parent defines the object to serialize in
  16036. * @returns the serialized object
  16037. */
  16038. serialize(parent: any): any;
  16039. }
  16040. }
  16041. declare module "babylonjs/Actions/actionManager" {
  16042. import { Nullable } from "babylonjs/types";
  16043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16044. import { Scene } from "babylonjs/scene";
  16045. import { IAction } from "babylonjs/Actions/action";
  16046. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16047. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16048. /**
  16049. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16050. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16052. */
  16053. export class ActionManager extends AbstractActionManager {
  16054. /**
  16055. * Nothing
  16056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16057. */
  16058. static readonly NothingTrigger: number;
  16059. /**
  16060. * On pick
  16061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16062. */
  16063. static readonly OnPickTrigger: number;
  16064. /**
  16065. * On left pick
  16066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16067. */
  16068. static readonly OnLeftPickTrigger: number;
  16069. /**
  16070. * On right pick
  16071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16072. */
  16073. static readonly OnRightPickTrigger: number;
  16074. /**
  16075. * On center pick
  16076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16077. */
  16078. static readonly OnCenterPickTrigger: number;
  16079. /**
  16080. * On pick down
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickDownTrigger: number;
  16084. /**
  16085. * On double pick
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnDoublePickTrigger: number;
  16089. /**
  16090. * On pick up
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPickUpTrigger: number;
  16094. /**
  16095. * On pick out.
  16096. * This trigger will only be raised if you also declared a OnPickDown
  16097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16098. */
  16099. static readonly OnPickOutTrigger: number;
  16100. /**
  16101. * On long press
  16102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16103. */
  16104. static readonly OnLongPressTrigger: number;
  16105. /**
  16106. * On pointer over
  16107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16108. */
  16109. static readonly OnPointerOverTrigger: number;
  16110. /**
  16111. * On pointer out
  16112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16113. */
  16114. static readonly OnPointerOutTrigger: number;
  16115. /**
  16116. * On every frame
  16117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16118. */
  16119. static readonly OnEveryFrameTrigger: number;
  16120. /**
  16121. * On intersection enter
  16122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16123. */
  16124. static readonly OnIntersectionEnterTrigger: number;
  16125. /**
  16126. * On intersection exit
  16127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16128. */
  16129. static readonly OnIntersectionExitTrigger: number;
  16130. /**
  16131. * On key down
  16132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16133. */
  16134. static readonly OnKeyDownTrigger: number;
  16135. /**
  16136. * On key up
  16137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16138. */
  16139. static readonly OnKeyUpTrigger: number;
  16140. private _scene;
  16141. /**
  16142. * Creates a new action manager
  16143. * @param scene defines the hosting scene
  16144. */
  16145. constructor(scene: Scene);
  16146. /**
  16147. * Releases all associated resources
  16148. */
  16149. dispose(): void;
  16150. /**
  16151. * Gets hosting scene
  16152. * @returns the hosting scene
  16153. */
  16154. getScene(): Scene;
  16155. /**
  16156. * Does this action manager handles actions of any of the given triggers
  16157. * @param triggers defines the triggers to be tested
  16158. * @return a boolean indicating whether one (or more) of the triggers is handled
  16159. */
  16160. hasSpecificTriggers(triggers: number[]): boolean;
  16161. /**
  16162. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16163. * speed.
  16164. * @param triggerA defines the trigger to be tested
  16165. * @param triggerB defines the trigger to be tested
  16166. * @return a boolean indicating whether one (or more) of the triggers is handled
  16167. */
  16168. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16169. /**
  16170. * Does this action manager handles actions of a given trigger
  16171. * @param trigger defines the trigger to be tested
  16172. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16173. * @return whether the trigger is handled
  16174. */
  16175. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16176. /**
  16177. * Does this action manager has pointer triggers
  16178. */
  16179. readonly hasPointerTriggers: boolean;
  16180. /**
  16181. * Does this action manager has pick triggers
  16182. */
  16183. readonly hasPickTriggers: boolean;
  16184. /**
  16185. * Registers an action to this action manager
  16186. * @param action defines the action to be registered
  16187. * @return the action amended (prepared) after registration
  16188. */
  16189. registerAction(action: IAction): Nullable<IAction>;
  16190. /**
  16191. * Unregisters an action to this action manager
  16192. * @param action defines the action to be unregistered
  16193. * @return a boolean indicating whether the action has been unregistered
  16194. */
  16195. unregisterAction(action: IAction): Boolean;
  16196. /**
  16197. * Process a specific trigger
  16198. * @param trigger defines the trigger to process
  16199. * @param evt defines the event details to be processed
  16200. */
  16201. processTrigger(trigger: number, evt?: IActionEvent): void;
  16202. /** @hidden */
  16203. _getEffectiveTarget(target: any, propertyPath: string): any;
  16204. /** @hidden */
  16205. _getProperty(propertyPath: string): string;
  16206. /**
  16207. * Serialize this manager to a JSON object
  16208. * @param name defines the property name to store this manager
  16209. * @returns a JSON representation of this manager
  16210. */
  16211. serialize(name: string): any;
  16212. /**
  16213. * Creates a new ActionManager from a JSON data
  16214. * @param parsedActions defines the JSON data to read from
  16215. * @param object defines the hosting mesh
  16216. * @param scene defines the hosting scene
  16217. */
  16218. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16219. /**
  16220. * Get a trigger name by index
  16221. * @param trigger defines the trigger index
  16222. * @returns a trigger name
  16223. */
  16224. static GetTriggerName(trigger: number): string;
  16225. }
  16226. }
  16227. declare module "babylonjs/Culling/ray" {
  16228. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16229. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16231. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16232. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16233. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16234. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16235. /**
  16236. * Class representing a ray with position and direction
  16237. */
  16238. export class Ray {
  16239. /** origin point */
  16240. origin: Vector3;
  16241. /** direction */
  16242. direction: Vector3;
  16243. /** length of the ray */
  16244. length: number;
  16245. private static readonly TmpVector3;
  16246. private _tmpRay;
  16247. /**
  16248. * Creates a new ray
  16249. * @param origin origin point
  16250. * @param direction direction
  16251. * @param length length of the ray
  16252. */
  16253. constructor(
  16254. /** origin point */
  16255. origin: Vector3,
  16256. /** direction */
  16257. direction: Vector3,
  16258. /** length of the ray */
  16259. length?: number);
  16260. /**
  16261. * Checks if the ray intersects a box
  16262. * @param minimum bound of the box
  16263. * @param maximum bound of the box
  16264. * @param intersectionTreshold extra extend to be added to the box in all direction
  16265. * @returns if the box was hit
  16266. */
  16267. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16268. /**
  16269. * Checks if the ray intersects a box
  16270. * @param box the bounding box to check
  16271. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16272. * @returns if the box was hit
  16273. */
  16274. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16275. /**
  16276. * If the ray hits a sphere
  16277. * @param sphere the bounding sphere to check
  16278. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16279. * @returns true if it hits the sphere
  16280. */
  16281. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16282. /**
  16283. * If the ray hits a triange
  16284. * @param vertex0 triangle vertex
  16285. * @param vertex1 triangle vertex
  16286. * @param vertex2 triangle vertex
  16287. * @returns intersection information if hit
  16288. */
  16289. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16290. /**
  16291. * Checks if ray intersects a plane
  16292. * @param plane the plane to check
  16293. * @returns the distance away it was hit
  16294. */
  16295. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16296. /**
  16297. * Checks if ray intersects a mesh
  16298. * @param mesh the mesh to check
  16299. * @param fastCheck if only the bounding box should checked
  16300. * @returns picking info of the intersecton
  16301. */
  16302. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16303. /**
  16304. * Checks if ray intersects a mesh
  16305. * @param meshes the meshes to check
  16306. * @param fastCheck if only the bounding box should checked
  16307. * @param results array to store result in
  16308. * @returns Array of picking infos
  16309. */
  16310. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16311. private _comparePickingInfo;
  16312. private static smallnum;
  16313. private static rayl;
  16314. /**
  16315. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16316. * @param sega the first point of the segment to test the intersection against
  16317. * @param segb the second point of the segment to test the intersection against
  16318. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16319. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16320. */
  16321. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16322. /**
  16323. * Update the ray from viewport position
  16324. * @param x position
  16325. * @param y y position
  16326. * @param viewportWidth viewport width
  16327. * @param viewportHeight viewport height
  16328. * @param world world matrix
  16329. * @param view view matrix
  16330. * @param projection projection matrix
  16331. * @returns this ray updated
  16332. */
  16333. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16334. /**
  16335. * Creates a ray with origin and direction of 0,0,0
  16336. * @returns the new ray
  16337. */
  16338. static Zero(): Ray;
  16339. /**
  16340. * Creates a new ray from screen space and viewport
  16341. * @param x position
  16342. * @param y y position
  16343. * @param viewportWidth viewport width
  16344. * @param viewportHeight viewport height
  16345. * @param world world matrix
  16346. * @param view view matrix
  16347. * @param projection projection matrix
  16348. * @returns new ray
  16349. */
  16350. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  16353. * transformed to the given world matrix.
  16354. * @param origin The origin point
  16355. * @param end The end point
  16356. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16357. * @returns the new ray
  16358. */
  16359. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16360. /**
  16361. * Transforms a ray by a matrix
  16362. * @param ray ray to transform
  16363. * @param matrix matrix to apply
  16364. * @returns the resulting new ray
  16365. */
  16366. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16367. /**
  16368. * Transforms a ray by a matrix
  16369. * @param ray ray to transform
  16370. * @param matrix matrix to apply
  16371. * @param result ray to store result in
  16372. */
  16373. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16374. /**
  16375. * Unproject a ray from screen space to object space
  16376. * @param sourceX defines the screen space x coordinate to use
  16377. * @param sourceY defines the screen space y coordinate to use
  16378. * @param viewportWidth defines the current width of the viewport
  16379. * @param viewportHeight defines the current height of the viewport
  16380. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16381. * @param view defines the view matrix to use
  16382. * @param projection defines the projection matrix to use
  16383. */
  16384. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16385. }
  16386. /**
  16387. * Type used to define predicate used to select faces when a mesh intersection is detected
  16388. */
  16389. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16390. module "babylonjs/scene" {
  16391. interface Scene {
  16392. /** @hidden */
  16393. _tempPickingRay: Nullable<Ray>;
  16394. /** @hidden */
  16395. _cachedRayForTransform: Ray;
  16396. /** @hidden */
  16397. _pickWithRayInverseMatrix: Matrix;
  16398. /** @hidden */
  16399. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16400. /** @hidden */
  16401. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16402. }
  16403. }
  16404. }
  16405. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16406. import { Nullable } from "babylonjs/types";
  16407. import { Observable } from "babylonjs/Misc/observable";
  16408. import { Scene } from "babylonjs/scene";
  16409. import { Sprite } from "babylonjs/Sprites/sprite";
  16410. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16411. import { Ray } from "babylonjs/Culling/ray";
  16412. import { Camera } from "babylonjs/Cameras/camera";
  16413. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16414. import { ISceneComponent } from "babylonjs/sceneComponent";
  16415. module "babylonjs/scene" {
  16416. interface Scene {
  16417. /** @hidden */
  16418. _pointerOverSprite: Nullable<Sprite>;
  16419. /** @hidden */
  16420. _pickedDownSprite: Nullable<Sprite>;
  16421. /** @hidden */
  16422. _tempSpritePickingRay: Nullable<Ray>;
  16423. /**
  16424. * All of the sprite managers added to this scene
  16425. * @see http://doc.babylonjs.com/babylon101/sprites
  16426. */
  16427. spriteManagers: Array<ISpriteManager>;
  16428. /**
  16429. * An event triggered when sprites rendering is about to start
  16430. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16431. */
  16432. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16433. /**
  16434. * An event triggered when sprites rendering is done
  16435. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16436. */
  16437. onAfterSpritesRenderingObservable: Observable<Scene>;
  16438. /** @hidden */
  16439. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16440. /** Launch a ray to try to pick a sprite in the scene
  16441. * @param x position on screen
  16442. * @param y position on screen
  16443. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  16444. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16445. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16446. * @returns a PickingInfo
  16447. */
  16448. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16449. /** Use the given ray to pick a sprite in the scene
  16450. * @param ray The ray (in world space) to use to pick meshes
  16451. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  16452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16453. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16454. * @returns a PickingInfo
  16455. */
  16456. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16457. /**
  16458. * Force the sprite under the pointer
  16459. * @param sprite defines the sprite to use
  16460. */
  16461. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16462. /**
  16463. * Gets the sprite under the pointer
  16464. * @returns a Sprite or null if no sprite is under the pointer
  16465. */
  16466. getPointerOverSprite(): Nullable<Sprite>;
  16467. }
  16468. }
  16469. /**
  16470. * Defines the sprite scene component responsible to manage sprites
  16471. * in a given scene.
  16472. */
  16473. export class SpriteSceneComponent implements ISceneComponent {
  16474. /**
  16475. * The component name helpfull to identify the component in the list of scene components.
  16476. */
  16477. readonly name: string;
  16478. /**
  16479. * The scene the component belongs to.
  16480. */
  16481. scene: Scene;
  16482. /** @hidden */
  16483. private _spritePredicate;
  16484. /**
  16485. * Creates a new instance of the component for the given scene
  16486. * @param scene Defines the scene to register the component in
  16487. */
  16488. constructor(scene: Scene);
  16489. /**
  16490. * Registers the component in a given scene
  16491. */
  16492. register(): void;
  16493. /**
  16494. * Rebuilds the elements related to this component in case of
  16495. * context lost for instance.
  16496. */
  16497. rebuild(): void;
  16498. /**
  16499. * Disposes the component and the associated ressources.
  16500. */
  16501. dispose(): void;
  16502. private _pickSpriteButKeepRay;
  16503. private _pointerMove;
  16504. private _pointerDown;
  16505. private _pointerUp;
  16506. }
  16507. }
  16508. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16509. /** @hidden */
  16510. export var fogFragmentDeclaration: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16516. /** @hidden */
  16517. export var fogFragment: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.fragment" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16524. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16525. /** @hidden */
  16526. export var spritesPixelShader: {
  16527. name: string;
  16528. shader: string;
  16529. };
  16530. }
  16531. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16532. /** @hidden */
  16533. export var fogVertexDeclaration: {
  16534. name: string;
  16535. shader: string;
  16536. };
  16537. }
  16538. declare module "babylonjs/Shaders/sprites.vertex" {
  16539. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16540. /** @hidden */
  16541. export var spritesVertexShader: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module "babylonjs/Sprites/spriteManager" {
  16547. import { IDisposable, Scene } from "babylonjs/scene";
  16548. import { Nullable } from "babylonjs/types";
  16549. import { Observable } from "babylonjs/Misc/observable";
  16550. import { Sprite } from "babylonjs/Sprites/sprite";
  16551. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16552. import { Camera } from "babylonjs/Cameras/camera";
  16553. import { Texture } from "babylonjs/Materials/Textures/texture";
  16554. import "babylonjs/Shaders/sprites.fragment";
  16555. import "babylonjs/Shaders/sprites.vertex";
  16556. import { Ray } from "babylonjs/Culling/ray";
  16557. /**
  16558. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16559. */
  16560. export interface ISpriteManager extends IDisposable {
  16561. /**
  16562. * Restricts the camera to viewing objects with the same layerMask.
  16563. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16564. */
  16565. layerMask: number;
  16566. /**
  16567. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16568. */
  16569. isPickable: boolean;
  16570. /**
  16571. * Specifies the rendering group id for this mesh (0 by default)
  16572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16573. */
  16574. renderingGroupId: number;
  16575. /**
  16576. * Defines the list of sprites managed by the manager.
  16577. */
  16578. sprites: Array<Sprite>;
  16579. /**
  16580. * Tests the intersection of a sprite with a specific ray.
  16581. * @param ray The ray we are sending to test the collision
  16582. * @param camera The camera space we are sending rays in
  16583. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16584. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16585. * @returns picking info or null.
  16586. */
  16587. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16588. /**
  16589. * Renders the list of sprites on screen.
  16590. */
  16591. render(): void;
  16592. }
  16593. /**
  16594. * Class used to manage multiple sprites on the same spritesheet
  16595. * @see http://doc.babylonjs.com/babylon101/sprites
  16596. */
  16597. export class SpriteManager implements ISpriteManager {
  16598. /** defines the manager's name */
  16599. name: string;
  16600. /** Gets the list of sprites */
  16601. sprites: Sprite[];
  16602. /** Gets or sets the rendering group id (0 by default) */
  16603. renderingGroupId: number;
  16604. /** Gets or sets camera layer mask */
  16605. layerMask: number;
  16606. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16607. fogEnabled: boolean;
  16608. /** Gets or sets a boolean indicating if the sprites are pickable */
  16609. isPickable: boolean;
  16610. /** Defines the default width of a cell in the spritesheet */
  16611. cellWidth: number;
  16612. /** Defines the default height of a cell in the spritesheet */
  16613. cellHeight: number;
  16614. /**
  16615. * An event triggered when the manager is disposed.
  16616. */
  16617. onDisposeObservable: Observable<SpriteManager>;
  16618. private _onDisposeObserver;
  16619. /**
  16620. * Callback called when the manager is disposed
  16621. */
  16622. onDispose: () => void;
  16623. private _capacity;
  16624. private _spriteTexture;
  16625. private _epsilon;
  16626. private _scene;
  16627. private _vertexData;
  16628. private _buffer;
  16629. private _vertexBuffers;
  16630. private _indexBuffer;
  16631. private _effectBase;
  16632. private _effectFog;
  16633. /**
  16634. * Gets or sets the spritesheet texture
  16635. */
  16636. texture: Texture;
  16637. /**
  16638. * Creates a new sprite manager
  16639. * @param name defines the manager's name
  16640. * @param imgUrl defines the sprite sheet url
  16641. * @param capacity defines the maximum allowed number of sprites
  16642. * @param cellSize defines the size of a sprite cell
  16643. * @param scene defines the hosting scene
  16644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16645. * @param samplingMode defines the smapling mode to use with spritesheet
  16646. */
  16647. constructor(
  16648. /** defines the manager's name */
  16649. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16650. private _appendSpriteVertex;
  16651. /**
  16652. * Intersects the sprites with a ray
  16653. * @param ray defines the ray to intersect with
  16654. * @param camera defines the current active camera
  16655. * @param predicate defines a predicate used to select candidate sprites
  16656. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16657. * @returns null if no hit or a PickingInfo
  16658. */
  16659. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16660. /**
  16661. * Render all child sprites
  16662. */
  16663. render(): void;
  16664. /**
  16665. * Release associated resources
  16666. */
  16667. dispose(): void;
  16668. }
  16669. }
  16670. declare module "babylonjs/Sprites/sprite" {
  16671. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16672. import { Nullable } from "babylonjs/types";
  16673. import { ActionManager } from "babylonjs/Actions/actionManager";
  16674. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16675. /**
  16676. * Class used to represent a sprite
  16677. * @see http://doc.babylonjs.com/babylon101/sprites
  16678. */
  16679. export class Sprite {
  16680. /** defines the name */
  16681. name: string;
  16682. /** Gets or sets the current world position */
  16683. position: Vector3;
  16684. /** Gets or sets the main color */
  16685. color: Color4;
  16686. /** Gets or sets the width */
  16687. width: number;
  16688. /** Gets or sets the height */
  16689. height: number;
  16690. /** Gets or sets rotation angle */
  16691. angle: number;
  16692. /** Gets or sets the cell index in the sprite sheet */
  16693. cellIndex: number;
  16694. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16695. invertU: number;
  16696. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16697. invertV: number;
  16698. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16699. disposeWhenFinishedAnimating: boolean;
  16700. /** Gets the list of attached animations */
  16701. animations: Animation[];
  16702. /** Gets or sets a boolean indicating if the sprite can be picked */
  16703. isPickable: boolean;
  16704. /**
  16705. * Gets or sets the associated action manager
  16706. */
  16707. actionManager: Nullable<ActionManager>;
  16708. private _animationStarted;
  16709. private _loopAnimation;
  16710. private _fromIndex;
  16711. private _toIndex;
  16712. private _delay;
  16713. private _direction;
  16714. private _manager;
  16715. private _time;
  16716. private _onAnimationEnd;
  16717. /**
  16718. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16719. */
  16720. isVisible: boolean;
  16721. /**
  16722. * Gets or sets the sprite size
  16723. */
  16724. size: number;
  16725. /**
  16726. * Creates a new Sprite
  16727. * @param name defines the name
  16728. * @param manager defines the manager
  16729. */
  16730. constructor(
  16731. /** defines the name */
  16732. name: string, manager: ISpriteManager);
  16733. /**
  16734. * Starts an animation
  16735. * @param from defines the initial key
  16736. * @param to defines the end key
  16737. * @param loop defines if the animation must loop
  16738. * @param delay defines the start delay (in ms)
  16739. * @param onAnimationEnd defines a callback to call when animation ends
  16740. */
  16741. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16742. /** Stops current animation (if any) */
  16743. stopAnimation(): void;
  16744. /** @hidden */
  16745. _animate(deltaTime: number): void;
  16746. /** Release associated resources */
  16747. dispose(): void;
  16748. }
  16749. }
  16750. declare module "babylonjs/Collisions/pickingInfo" {
  16751. import { Nullable } from "babylonjs/types";
  16752. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16754. import { Sprite } from "babylonjs/Sprites/sprite";
  16755. import { Ray } from "babylonjs/Culling/ray";
  16756. /**
  16757. * Information about the result of picking within a scene
  16758. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16759. */
  16760. export class PickingInfo {
  16761. /** @hidden */
  16762. _pickingUnavailable: boolean;
  16763. /**
  16764. * If the pick collided with an object
  16765. */
  16766. hit: boolean;
  16767. /**
  16768. * Distance away where the pick collided
  16769. */
  16770. distance: number;
  16771. /**
  16772. * The location of pick collision
  16773. */
  16774. pickedPoint: Nullable<Vector3>;
  16775. /**
  16776. * The mesh corresponding the the pick collision
  16777. */
  16778. pickedMesh: Nullable<AbstractMesh>;
  16779. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16780. bu: number;
  16781. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16782. bv: number;
  16783. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16784. faceId: number;
  16785. /** Id of the the submesh that was picked */
  16786. subMeshId: number;
  16787. /** If a sprite was picked, this will be the sprite the pick collided with */
  16788. pickedSprite: Nullable<Sprite>;
  16789. /**
  16790. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16791. */
  16792. originMesh: Nullable<AbstractMesh>;
  16793. /**
  16794. * The ray that was used to perform the picking.
  16795. */
  16796. ray: Nullable<Ray>;
  16797. /**
  16798. * Gets the normal correspodning to the face the pick collided with
  16799. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16800. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16801. * @returns The normal correspodning to the face the pick collided with
  16802. */
  16803. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16804. /**
  16805. * Gets the texture coordinates of where the pick occured
  16806. * @returns the vector containing the coordnates of the texture
  16807. */
  16808. getTextureCoordinates(): Nullable<Vector2>;
  16809. }
  16810. }
  16811. declare module "babylonjs/Events/pointerEvents" {
  16812. import { Nullable } from "babylonjs/types";
  16813. import { Vector2 } from "babylonjs/Maths/math";
  16814. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16815. import { Ray } from "babylonjs/Culling/ray";
  16816. /**
  16817. * Gather the list of pointer event types as constants.
  16818. */
  16819. export class PointerEventTypes {
  16820. /**
  16821. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  16822. */
  16823. static readonly POINTERDOWN: number;
  16824. /**
  16825. * The pointerup event is fired when a pointer is no longer active.
  16826. */
  16827. static readonly POINTERUP: number;
  16828. /**
  16829. * The pointermove event is fired when a pointer changes coordinates.
  16830. */
  16831. static readonly POINTERMOVE: number;
  16832. /**
  16833. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16834. */
  16835. static readonly POINTERWHEEL: number;
  16836. /**
  16837. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16838. */
  16839. static readonly POINTERPICK: number;
  16840. /**
  16841. * The pointertap event is fired when a the object has been touched and released without drag.
  16842. */
  16843. static readonly POINTERTAP: number;
  16844. /**
  16845. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16846. */
  16847. static readonly POINTERDOUBLETAP: number;
  16848. }
  16849. /**
  16850. * Base class of pointer info types.
  16851. */
  16852. export class PointerInfoBase {
  16853. /**
  16854. * Defines the type of event (PointerEventTypes)
  16855. */
  16856. type: number;
  16857. /**
  16858. * Defines the related dom event
  16859. */
  16860. event: PointerEvent | MouseWheelEvent;
  16861. /**
  16862. * Instantiates the base class of pointers info.
  16863. * @param type Defines the type of event (PointerEventTypes)
  16864. * @param event Defines the related dom event
  16865. */
  16866. constructor(
  16867. /**
  16868. * Defines the type of event (PointerEventTypes)
  16869. */
  16870. type: number,
  16871. /**
  16872. * Defines the related dom event
  16873. */
  16874. event: PointerEvent | MouseWheelEvent);
  16875. }
  16876. /**
  16877. * This class is used to store pointer related info for the onPrePointerObservable event.
  16878. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16879. */
  16880. export class PointerInfoPre extends PointerInfoBase {
  16881. /**
  16882. * Ray from a pointer if availible (eg. 6dof controller)
  16883. */
  16884. ray: Nullable<Ray>;
  16885. /**
  16886. * Defines the local position of the pointer on the canvas.
  16887. */
  16888. localPosition: Vector2;
  16889. /**
  16890. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16891. */
  16892. skipOnPointerObservable: boolean;
  16893. /**
  16894. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16895. * @param type Defines the type of event (PointerEventTypes)
  16896. * @param event Defines the related dom event
  16897. * @param localX Defines the local x coordinates of the pointer when the event occured
  16898. * @param localY Defines the local y coordinates of the pointer when the event occured
  16899. */
  16900. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16901. }
  16902. /**
  16903. * This type contains all the data related to a pointer event in Babylon.js.
  16904. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  16905. */
  16906. export class PointerInfo extends PointerInfoBase {
  16907. /**
  16908. * Defines the picking info associated to the info (if any)\
  16909. */
  16910. pickInfo: Nullable<PickingInfo>;
  16911. /**
  16912. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16913. * @param type Defines the type of event (PointerEventTypes)
  16914. * @param event Defines the related dom event
  16915. * @param pickInfo Defines the picking info associated to the info (if any)\
  16916. */
  16917. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16918. /**
  16919. * Defines the picking info associated to the info (if any)\
  16920. */
  16921. pickInfo: Nullable<PickingInfo>);
  16922. }
  16923. /**
  16924. * Data relating to a touch event on the screen.
  16925. */
  16926. export interface PointerTouch {
  16927. /**
  16928. * X coordinate of touch.
  16929. */
  16930. x: number;
  16931. /**
  16932. * Y coordinate of touch.
  16933. */
  16934. y: number;
  16935. /**
  16936. * Id of touch. Unique for each finger.
  16937. */
  16938. pointerId: number;
  16939. /**
  16940. * Event type passed from DOM.
  16941. */
  16942. type: any;
  16943. }
  16944. }
  16945. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16946. import { Observable } from "babylonjs/Misc/observable";
  16947. import { Nullable } from "babylonjs/types";
  16948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16949. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16950. /**
  16951. * Manage the mouse inputs to control the movement of a free camera.
  16952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16953. */
  16954. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16955. /**
  16956. * Define if touch is enabled in the mouse input
  16957. */
  16958. touchEnabled: boolean;
  16959. /**
  16960. * Defines the camera the input is attached to.
  16961. */
  16962. camera: FreeCamera;
  16963. /**
  16964. * Defines the buttons associated with the input to handle camera move.
  16965. */
  16966. buttons: number[];
  16967. /**
  16968. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16969. */
  16970. angularSensibility: number;
  16971. private _pointerInput;
  16972. private _onMouseMove;
  16973. private _observer;
  16974. private previousPosition;
  16975. /**
  16976. * Observable for when a pointer move event occurs containing the move offset
  16977. */
  16978. onPointerMovedObservable: Observable<{
  16979. offsetX: number;
  16980. offsetY: number;
  16981. }>;
  16982. /**
  16983. * @hidden
  16984. * If the camera should be rotated automatically based on pointer movement
  16985. */
  16986. _allowCameraRotation: boolean;
  16987. /**
  16988. * Manage the mouse inputs to control the movement of a free camera.
  16989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16990. * @param touchEnabled Defines if touch is enabled or not
  16991. */
  16992. constructor(
  16993. /**
  16994. * Define if touch is enabled in the mouse input
  16995. */
  16996. touchEnabled?: boolean);
  16997. /**
  16998. * Attach the input controls to a specific dom element to get the input from.
  16999. * @param element Defines the element the controls should be listened from
  17000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17001. */
  17002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17003. /**
  17004. * Called on JS contextmenu event.
  17005. * Override this method to provide functionality.
  17006. */
  17007. protected onContextMenu(evt: PointerEvent): void;
  17008. /**
  17009. * Detach the current controls from the specified dom element.
  17010. * @param element Defines the element to stop listening the inputs from
  17011. */
  17012. detachControl(element: Nullable<HTMLElement>): void;
  17013. /**
  17014. * Gets the class name of the current intput.
  17015. * @returns the class name
  17016. */
  17017. getClassName(): string;
  17018. /**
  17019. * Get the friendly name associated with the input class.
  17020. * @returns the input friendly name
  17021. */
  17022. getSimpleName(): string;
  17023. }
  17024. }
  17025. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17026. import { Nullable } from "babylonjs/types";
  17027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17029. /**
  17030. * Manage the touch inputs to control the movement of a free camera.
  17031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17032. */
  17033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17034. /**
  17035. * Defines the camera the input is attached to.
  17036. */
  17037. camera: FreeCamera;
  17038. /**
  17039. * Defines the touch sensibility for rotation.
  17040. * The higher the faster.
  17041. */
  17042. touchAngularSensibility: number;
  17043. /**
  17044. * Defines the touch sensibility for move.
  17045. * The higher the faster.
  17046. */
  17047. touchMoveSensibility: number;
  17048. private _offsetX;
  17049. private _offsetY;
  17050. private _pointerPressed;
  17051. private _pointerInput;
  17052. private _observer;
  17053. private _onLostFocus;
  17054. /**
  17055. * Attach the input controls to a specific dom element to get the input from.
  17056. * @param element Defines the element the controls should be listened from
  17057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17058. */
  17059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17060. /**
  17061. * Detach the current controls from the specified dom element.
  17062. * @param element Defines the element to stop listening the inputs from
  17063. */
  17064. detachControl(element: Nullable<HTMLElement>): void;
  17065. /**
  17066. * Update the current camera state depending on the inputs that have been used this frame.
  17067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17068. */
  17069. checkInputs(): void;
  17070. /**
  17071. * Gets the class name of the current intput.
  17072. * @returns the class name
  17073. */
  17074. getClassName(): string;
  17075. /**
  17076. * Get the friendly name associated with the input class.
  17077. * @returns the input friendly name
  17078. */
  17079. getSimpleName(): string;
  17080. }
  17081. }
  17082. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17084. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17085. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17086. import { Nullable } from "babylonjs/types";
  17087. /**
  17088. * Default Inputs manager for the FreeCamera.
  17089. * It groups all the default supported inputs for ease of use.
  17090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17091. */
  17092. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17093. /**
  17094. * @hidden
  17095. */
  17096. _mouseInput: Nullable<FreeCameraMouseInput>;
  17097. /**
  17098. * Instantiates a new FreeCameraInputsManager.
  17099. * @param camera Defines the camera the inputs belong to
  17100. */
  17101. constructor(camera: FreeCamera);
  17102. /**
  17103. * Add keyboard input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addKeyboard(): FreeCameraInputsManager;
  17107. /**
  17108. * Add mouse input support to the input manager.
  17109. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17110. * @returns the current input manager
  17111. */
  17112. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17113. /**
  17114. * Removes the mouse input support from the manager
  17115. * @returns the current input manager
  17116. */
  17117. removeMouse(): FreeCameraInputsManager;
  17118. /**
  17119. * Add touch input support to the input manager.
  17120. * @returns the current input manager
  17121. */
  17122. addTouch(): FreeCameraInputsManager;
  17123. /**
  17124. * Remove all attached input methods from a camera
  17125. */
  17126. clear(): void;
  17127. }
  17128. }
  17129. declare module "babylonjs/Cameras/freeCamera" {
  17130. import { Vector3 } from "babylonjs/Maths/math";
  17131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17132. import { Scene } from "babylonjs/scene";
  17133. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17134. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17135. /**
  17136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17137. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17138. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17139. */
  17140. export class FreeCamera extends TargetCamera {
  17141. /**
  17142. * Define the collision ellipsoid of the camera.
  17143. * This is helpful to simulate a camera body like the player body around the camera
  17144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17145. */
  17146. ellipsoid: Vector3;
  17147. /**
  17148. * Define an offset for the position of the ellipsoid around the camera.
  17149. * This can be helpful to determine the center of the body near the gravity center of the body
  17150. * instead of its head.
  17151. */
  17152. ellipsoidOffset: Vector3;
  17153. /**
  17154. * Enable or disable collisions of the camera with the rest of the scene objects.
  17155. */
  17156. checkCollisions: boolean;
  17157. /**
  17158. * Enable or disable gravity on the camera.
  17159. */
  17160. applyGravity: boolean;
  17161. /**
  17162. * Define the input manager associated to the camera.
  17163. */
  17164. inputs: FreeCameraInputsManager;
  17165. /**
  17166. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17167. * Higher values reduce sensitivity.
  17168. */
  17169. /**
  17170. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17171. * Higher values reduce sensitivity.
  17172. */
  17173. angularSensibility: number;
  17174. /**
  17175. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17176. */
  17177. keysUp: number[];
  17178. /**
  17179. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17180. */
  17181. keysDown: number[];
  17182. /**
  17183. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17184. */
  17185. keysLeft: number[];
  17186. /**
  17187. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17188. */
  17189. keysRight: number[];
  17190. /**
  17191. * Event raised when the camera collide with a mesh in the scene.
  17192. */
  17193. onCollide: (collidedMesh: AbstractMesh) => void;
  17194. private _collider;
  17195. private _needMoveForGravity;
  17196. private _oldPosition;
  17197. private _diffPosition;
  17198. private _newPosition;
  17199. /** @hidden */
  17200. _localDirection: Vector3;
  17201. /** @hidden */
  17202. _transformedDirection: Vector3;
  17203. /**
  17204. * Instantiates a Free Camera.
  17205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17206. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17208. * @param name Define the name of the camera in the scene
  17209. * @param position Define the start position of the camera in the scene
  17210. * @param scene Define the scene the camera belongs to
  17211. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17212. */
  17213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17214. /**
  17215. * Attached controls to the current camera.
  17216. * @param element Defines the element the controls should be listened from
  17217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17218. */
  17219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17220. /**
  17221. * Detach the current controls from the camera.
  17222. * The camera will stop reacting to inputs.
  17223. * @param element Defines the element to stop listening the inputs from
  17224. */
  17225. detachControl(element: HTMLElement): void;
  17226. private _collisionMask;
  17227. /**
  17228. * Define a collision mask to limit the list of object the camera can collide with
  17229. */
  17230. collisionMask: number;
  17231. /** @hidden */
  17232. _collideWithWorld(displacement: Vector3): void;
  17233. private _onCollisionPositionChange;
  17234. /** @hidden */
  17235. _checkInputs(): void;
  17236. /** @hidden */
  17237. _decideIfNeedsToMove(): boolean;
  17238. /** @hidden */
  17239. _updatePosition(): void;
  17240. /**
  17241. * Destroy the camera and release the current resources hold by it.
  17242. */
  17243. dispose(): void;
  17244. /**
  17245. * Gets the current object class name.
  17246. * @return the class name
  17247. */
  17248. getClassName(): string;
  17249. }
  17250. }
  17251. declare module "babylonjs/Gamepads/gamepad" {
  17252. import { Observable } from "babylonjs/Misc/observable";
  17253. /**
  17254. * Represents a gamepad control stick position
  17255. */
  17256. export class StickValues {
  17257. /**
  17258. * The x component of the control stick
  17259. */
  17260. x: number;
  17261. /**
  17262. * The y component of the control stick
  17263. */
  17264. y: number;
  17265. /**
  17266. * Initializes the gamepad x and y control stick values
  17267. * @param x The x component of the gamepad control stick value
  17268. * @param y The y component of the gamepad control stick value
  17269. */
  17270. constructor(
  17271. /**
  17272. * The x component of the control stick
  17273. */
  17274. x: number,
  17275. /**
  17276. * The y component of the control stick
  17277. */
  17278. y: number);
  17279. }
  17280. /**
  17281. * An interface which manages callbacks for gamepad button changes
  17282. */
  17283. export interface GamepadButtonChanges {
  17284. /**
  17285. * Called when a gamepad has been changed
  17286. */
  17287. changed: boolean;
  17288. /**
  17289. * Called when a gamepad press event has been triggered
  17290. */
  17291. pressChanged: boolean;
  17292. /**
  17293. * Called when a touch event has been triggered
  17294. */
  17295. touchChanged: boolean;
  17296. /**
  17297. * Called when a value has changed
  17298. */
  17299. valueChanged: boolean;
  17300. }
  17301. /**
  17302. * Represents a gamepad
  17303. */
  17304. export class Gamepad {
  17305. /**
  17306. * The id of the gamepad
  17307. */
  17308. id: string;
  17309. /**
  17310. * The index of the gamepad
  17311. */
  17312. index: number;
  17313. /**
  17314. * The browser gamepad
  17315. */
  17316. browserGamepad: any;
  17317. /**
  17318. * Specifies what type of gamepad this represents
  17319. */
  17320. type: number;
  17321. private _leftStick;
  17322. private _rightStick;
  17323. /** @hidden */
  17324. _isConnected: boolean;
  17325. private _leftStickAxisX;
  17326. private _leftStickAxisY;
  17327. private _rightStickAxisX;
  17328. private _rightStickAxisY;
  17329. /**
  17330. * Triggered when the left control stick has been changed
  17331. */
  17332. private _onleftstickchanged;
  17333. /**
  17334. * Triggered when the right control stick has been changed
  17335. */
  17336. private _onrightstickchanged;
  17337. /**
  17338. * Represents a gamepad controller
  17339. */
  17340. static GAMEPAD: number;
  17341. /**
  17342. * Represents a generic controller
  17343. */
  17344. static GENERIC: number;
  17345. /**
  17346. * Represents an XBox controller
  17347. */
  17348. static XBOX: number;
  17349. /**
  17350. * Represents a pose-enabled controller
  17351. */
  17352. static POSE_ENABLED: number;
  17353. /**
  17354. * Specifies whether the left control stick should be Y-inverted
  17355. */
  17356. protected _invertLeftStickY: boolean;
  17357. /**
  17358. * Specifies if the gamepad has been connected
  17359. */
  17360. readonly isConnected: boolean;
  17361. /**
  17362. * Initializes the gamepad
  17363. * @param id The id of the gamepad
  17364. * @param index The index of the gamepad
  17365. * @param browserGamepad The browser gamepad
  17366. * @param leftStickX The x component of the left joystick
  17367. * @param leftStickY The y component of the left joystick
  17368. * @param rightStickX The x component of the right joystick
  17369. * @param rightStickY The y component of the right joystick
  17370. */
  17371. constructor(
  17372. /**
  17373. * The id of the gamepad
  17374. */
  17375. id: string,
  17376. /**
  17377. * The index of the gamepad
  17378. */
  17379. index: number,
  17380. /**
  17381. * The browser gamepad
  17382. */
  17383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17384. /**
  17385. * Callback triggered when the left joystick has changed
  17386. * @param callback
  17387. */
  17388. onleftstickchanged(callback: (values: StickValues) => void): void;
  17389. /**
  17390. * Callback triggered when the right joystick has changed
  17391. * @param callback
  17392. */
  17393. onrightstickchanged(callback: (values: StickValues) => void): void;
  17394. /**
  17395. * Gets the left joystick
  17396. */
  17397. /**
  17398. * Sets the left joystick values
  17399. */
  17400. leftStick: StickValues;
  17401. /**
  17402. * Gets the right joystick
  17403. */
  17404. /**
  17405. * Sets the right joystick value
  17406. */
  17407. rightStick: StickValues;
  17408. /**
  17409. * Updates the gamepad joystick positions
  17410. */
  17411. update(): void;
  17412. /**
  17413. * Disposes the gamepad
  17414. */
  17415. dispose(): void;
  17416. }
  17417. /**
  17418. * Represents a generic gamepad
  17419. */
  17420. export class GenericPad extends Gamepad {
  17421. private _buttons;
  17422. private _onbuttondown;
  17423. private _onbuttonup;
  17424. /**
  17425. * Observable triggered when a button has been pressed
  17426. */
  17427. onButtonDownObservable: Observable<number>;
  17428. /**
  17429. * Observable triggered when a button has been released
  17430. */
  17431. onButtonUpObservable: Observable<number>;
  17432. /**
  17433. * Callback triggered when a button has been pressed
  17434. * @param callback Called when a button has been pressed
  17435. */
  17436. onbuttondown(callback: (buttonPressed: number) => void): void;
  17437. /**
  17438. * Callback triggered when a button has been released
  17439. * @param callback Called when a button has been released
  17440. */
  17441. onbuttonup(callback: (buttonReleased: number) => void): void;
  17442. /**
  17443. * Initializes the generic gamepad
  17444. * @param id The id of the generic gamepad
  17445. * @param index The index of the generic gamepad
  17446. * @param browserGamepad The browser gamepad
  17447. */
  17448. constructor(id: string, index: number, browserGamepad: any);
  17449. private _setButtonValue;
  17450. /**
  17451. * Updates the generic gamepad
  17452. */
  17453. update(): void;
  17454. /**
  17455. * Disposes the generic gamepad
  17456. */
  17457. dispose(): void;
  17458. }
  17459. }
  17460. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17461. import { Observable } from "babylonjs/Misc/observable";
  17462. import { Nullable } from "babylonjs/types";
  17463. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17466. import { Ray } from "babylonjs/Culling/ray";
  17467. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17468. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17469. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17470. /**
  17471. * Defines the types of pose enabled controllers that are supported
  17472. */
  17473. export enum PoseEnabledControllerType {
  17474. /**
  17475. * HTC Vive
  17476. */
  17477. VIVE = 0,
  17478. /**
  17479. * Oculus Rift
  17480. */
  17481. OCULUS = 1,
  17482. /**
  17483. * Windows mixed reality
  17484. */
  17485. WINDOWS = 2,
  17486. /**
  17487. * Samsung gear VR
  17488. */
  17489. GEAR_VR = 3,
  17490. /**
  17491. * Google Daydream
  17492. */
  17493. DAYDREAM = 4,
  17494. /**
  17495. * Generic
  17496. */
  17497. GENERIC = 5
  17498. }
  17499. /**
  17500. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17501. */
  17502. export interface MutableGamepadButton {
  17503. /**
  17504. * Value of the button/trigger
  17505. */
  17506. value: number;
  17507. /**
  17508. * If the button/trigger is currently touched
  17509. */
  17510. touched: boolean;
  17511. /**
  17512. * If the button/trigger is currently pressed
  17513. */
  17514. pressed: boolean;
  17515. }
  17516. /**
  17517. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17518. * @hidden
  17519. */
  17520. export interface ExtendedGamepadButton extends GamepadButton {
  17521. /**
  17522. * If the button/trigger is currently pressed
  17523. */
  17524. readonly pressed: boolean;
  17525. /**
  17526. * If the button/trigger is currently touched
  17527. */
  17528. readonly touched: boolean;
  17529. /**
  17530. * Value of the button/trigger
  17531. */
  17532. readonly value: number;
  17533. }
  17534. /** @hidden */
  17535. export interface _GamePadFactory {
  17536. /**
  17537. * Returns wether or not the current gamepad can be created for this type of controller.
  17538. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17539. * @returns true if it can be created, otherwise false
  17540. */
  17541. canCreate(gamepadInfo: any): boolean;
  17542. /**
  17543. * Creates a new instance of the Gamepad.
  17544. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17545. * @returns the new gamepad instance
  17546. */
  17547. create(gamepadInfo: any): Gamepad;
  17548. }
  17549. /**
  17550. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17551. */
  17552. export class PoseEnabledControllerHelper {
  17553. /** @hidden */
  17554. static _ControllerFactories: _GamePadFactory[];
  17555. /** @hidden */
  17556. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17557. /**
  17558. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17559. * @param vrGamepad the gamepad to initialized
  17560. * @returns a vr controller of the type the gamepad identified as
  17561. */
  17562. static InitiateController(vrGamepad: any): Gamepad;
  17563. }
  17564. /**
  17565. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17566. */
  17567. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17568. private _deviceRoomPosition;
  17569. private _deviceRoomRotationQuaternion;
  17570. /**
  17571. * The device position in babylon space
  17572. */
  17573. devicePosition: Vector3;
  17574. /**
  17575. * The device rotation in babylon space
  17576. */
  17577. deviceRotationQuaternion: Quaternion;
  17578. /**
  17579. * The scale factor of the device in babylon space
  17580. */
  17581. deviceScaleFactor: number;
  17582. /**
  17583. * (Likely devicePosition should be used instead) The device position in its room space
  17584. */
  17585. position: Vector3;
  17586. /**
  17587. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17588. */
  17589. rotationQuaternion: Quaternion;
  17590. /**
  17591. * The type of controller (Eg. Windows mixed reality)
  17592. */
  17593. controllerType: PoseEnabledControllerType;
  17594. protected _calculatedPosition: Vector3;
  17595. private _calculatedRotation;
  17596. /**
  17597. * The raw pose from the device
  17598. */
  17599. rawPose: DevicePose;
  17600. private _trackPosition;
  17601. private _maxRotationDistFromHeadset;
  17602. private _draggedRoomRotation;
  17603. /**
  17604. * @hidden
  17605. */
  17606. _disableTrackPosition(fixedPosition: Vector3): void;
  17607. /**
  17608. * Internal, the mesh attached to the controller
  17609. * @hidden
  17610. */
  17611. _mesh: Nullable<AbstractMesh>;
  17612. private _poseControlledCamera;
  17613. private _leftHandSystemQuaternion;
  17614. /**
  17615. * Internal, matrix used to convert room space to babylon space
  17616. * @hidden
  17617. */
  17618. _deviceToWorld: Matrix;
  17619. /**
  17620. * Node to be used when casting a ray from the controller
  17621. * @hidden
  17622. */
  17623. _pointingPoseNode: Nullable<TransformNode>;
  17624. /**
  17625. * Name of the child mesh that can be used to cast a ray from the controller
  17626. */
  17627. static readonly POINTING_POSE: string;
  17628. /**
  17629. * Creates a new PoseEnabledController from a gamepad
  17630. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17631. */
  17632. constructor(browserGamepad: any);
  17633. private _workingMatrix;
  17634. /**
  17635. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17636. */
  17637. update(): void;
  17638. /**
  17639. * Updates only the pose device and mesh without doing any button event checking
  17640. */
  17641. protected _updatePoseAndMesh(): void;
  17642. /**
  17643. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17644. * @param poseData raw pose fromthe device
  17645. */
  17646. updateFromDevice(poseData: DevicePose): void;
  17647. /**
  17648. * @hidden
  17649. */
  17650. _meshAttachedObservable: Observable<AbstractMesh>;
  17651. /**
  17652. * Attaches a mesh to the controller
  17653. * @param mesh the mesh to be attached
  17654. */
  17655. attachToMesh(mesh: AbstractMesh): void;
  17656. /**
  17657. * Attaches the controllers mesh to a camera
  17658. * @param camera the camera the mesh should be attached to
  17659. */
  17660. attachToPoseControlledCamera(camera: TargetCamera): void;
  17661. /**
  17662. * Disposes of the controller
  17663. */
  17664. dispose(): void;
  17665. /**
  17666. * The mesh that is attached to the controller
  17667. */
  17668. readonly mesh: Nullable<AbstractMesh>;
  17669. /**
  17670. * Gets the ray of the controller in the direction the controller is pointing
  17671. * @param length the length the resulting ray should be
  17672. * @returns a ray in the direction the controller is pointing
  17673. */
  17674. getForwardRay(length?: number): Ray;
  17675. }
  17676. }
  17677. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17678. import { Observable } from "babylonjs/Misc/observable";
  17679. import { Scene } from "babylonjs/scene";
  17680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17681. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17682. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17683. /**
  17684. * Defines the WebVRController object that represents controllers tracked in 3D space
  17685. */
  17686. export abstract class WebVRController extends PoseEnabledController {
  17687. /**
  17688. * Internal, the default controller model for the controller
  17689. */
  17690. protected _defaultModel: AbstractMesh;
  17691. /**
  17692. * Fired when the trigger state has changed
  17693. */
  17694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17695. /**
  17696. * Fired when the main button state has changed
  17697. */
  17698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17699. /**
  17700. * Fired when the secondary button state has changed
  17701. */
  17702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17703. /**
  17704. * Fired when the pad state has changed
  17705. */
  17706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17707. /**
  17708. * Fired when controllers stick values have changed
  17709. */
  17710. onPadValuesChangedObservable: Observable<StickValues>;
  17711. /**
  17712. * Array of button availible on the controller
  17713. */
  17714. protected _buttons: Array<MutableGamepadButton>;
  17715. private _onButtonStateChange;
  17716. /**
  17717. * Fired when a controller button's state has changed
  17718. * @param callback the callback containing the button that was modified
  17719. */
  17720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17721. /**
  17722. * X and Y axis corresponding to the controllers joystick
  17723. */
  17724. pad: StickValues;
  17725. /**
  17726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17727. */
  17728. hand: string;
  17729. /**
  17730. * The default controller model for the controller
  17731. */
  17732. readonly defaultModel: AbstractMesh;
  17733. /**
  17734. * Creates a new WebVRController from a gamepad
  17735. * @param vrGamepad the gamepad that the WebVRController should be created from
  17736. */
  17737. constructor(vrGamepad: any);
  17738. /**
  17739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17740. */
  17741. update(): void;
  17742. /**
  17743. * Function to be called when a button is modified
  17744. */
  17745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17746. /**
  17747. * Loads a mesh and attaches it to the controller
  17748. * @param scene the scene the mesh should be added to
  17749. * @param meshLoaded callback for when the mesh has been loaded
  17750. */
  17751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17752. private _setButtonValue;
  17753. private _changes;
  17754. private _checkChanges;
  17755. /**
  17756. * Disposes of th webVRCOntroller
  17757. */
  17758. dispose(): void;
  17759. }
  17760. }
  17761. declare module "babylonjs/Lights/hemisphericLight" {
  17762. import { Nullable } from "babylonjs/types";
  17763. import { Scene } from "babylonjs/scene";
  17764. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17765. import { Effect } from "babylonjs/Materials/effect";
  17766. import { Light } from "babylonjs/Lights/light";
  17767. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17768. /**
  17769. * The HemisphericLight simulates the ambient environment light,
  17770. * so the passed direction is the light reflection direction, not the incoming direction.
  17771. */
  17772. export class HemisphericLight extends Light {
  17773. /**
  17774. * The groundColor is the light in the opposite direction to the one specified during creation.
  17775. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  17776. */
  17777. groundColor: Color3;
  17778. /**
  17779. * The light reflection direction, not the incoming direction.
  17780. */
  17781. direction: Vector3;
  17782. /**
  17783. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17784. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17785. * The HemisphericLight can't cast shadows.
  17786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17787. * @param name The friendly name of the light
  17788. * @param direction The direction of the light reflection
  17789. * @param scene The scene the light belongs to
  17790. */
  17791. constructor(name: string, direction: Vector3, scene: Scene);
  17792. protected _buildUniformLayout(): void;
  17793. /**
  17794. * Returns the string "HemisphericLight".
  17795. * @return The class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17800. * Returns the updated direction.
  17801. * @param target The target the direction should point to
  17802. * @return The computed direction
  17803. */
  17804. setDirectionToTarget(target: Vector3): Vector3;
  17805. /**
  17806. * Returns the shadow generator associated to the light.
  17807. * @returns Always null for hemispheric lights because it does not support shadows.
  17808. */
  17809. getShadowGenerator(): Nullable<IShadowGenerator>;
  17810. /**
  17811. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17812. * @param effect The effect to update
  17813. * @param lightIndex The index of the light in the effect to update
  17814. * @returns The hemispheric light
  17815. */
  17816. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17817. /**
  17818. * Computes the world matrix of the node
  17819. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17820. * @param useWasUpdatedFlag defines a reserved property
  17821. * @returns the world matrix
  17822. */
  17823. computeWorldMatrix(): Matrix;
  17824. /**
  17825. * Returns the integer 3.
  17826. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17827. */
  17828. getTypeID(): number;
  17829. /**
  17830. * Prepares the list of defines specific to the light type.
  17831. * @param defines the list of defines
  17832. * @param lightIndex defines the index of the light for the effect
  17833. */
  17834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17835. }
  17836. }
  17837. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17838. /** @hidden */
  17839. export var vrMultiviewToSingleviewPixelShader: {
  17840. name: string;
  17841. shader: string;
  17842. };
  17843. }
  17844. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17846. import { Scene } from "babylonjs/scene";
  17847. /**
  17848. * Renders to multiple views with a single draw call
  17849. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17850. */
  17851. export class MultiviewRenderTarget extends RenderTargetTexture {
  17852. /**
  17853. * Creates a multiview render target
  17854. * @param scene scene used with the render target
  17855. * @param size the size of the render target (used for each view)
  17856. */
  17857. constructor(scene: Scene, size?: number | {
  17858. width: number;
  17859. height: number;
  17860. } | {
  17861. ratio: number;
  17862. });
  17863. /**
  17864. * @hidden
  17865. * @param faceIndex the face index, if its a cube texture
  17866. */
  17867. _bindFrameBuffer(faceIndex?: number): void;
  17868. /**
  17869. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17870. * @returns the view count
  17871. */
  17872. getViewCount(): number;
  17873. }
  17874. }
  17875. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17876. import { Camera } from "babylonjs/Cameras/camera";
  17877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17878. import { Nullable } from "babylonjs/types";
  17879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17880. import { Matrix } from "babylonjs/Maths/math";
  17881. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17882. module "babylonjs/Engines/engine" {
  17883. interface Engine {
  17884. /**
  17885. * Creates a new multiview render target
  17886. * @param width defines the width of the texture
  17887. * @param height defines the height of the texture
  17888. * @returns the created multiview texture
  17889. */
  17890. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17891. /**
  17892. * Binds a multiview framebuffer to be drawn to
  17893. * @param multiviewTexture texture to bind
  17894. */
  17895. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17896. }
  17897. }
  17898. module "babylonjs/Cameras/camera" {
  17899. interface Camera {
  17900. /**
  17901. * @hidden
  17902. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  17903. */
  17904. _useMultiviewToSingleView: boolean;
  17905. /**
  17906. * @hidden
  17907. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  17908. */
  17909. _multiviewTexture: Nullable<RenderTargetTexture>;
  17910. /**
  17911. * @hidden
  17912. * ensures the multiview texture of the camera exists and has the specified width/height
  17913. * @param width height to set on the multiview texture
  17914. * @param height width to set on the multiview texture
  17915. */
  17916. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17917. }
  17918. }
  17919. module "babylonjs/scene" {
  17920. interface Scene {
  17921. /** @hidden */
  17922. _transformMatrixR: Matrix;
  17923. /** @hidden */
  17924. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17925. /** @hidden */
  17926. _createMultiviewUbo(): void;
  17927. /** @hidden */
  17928. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17929. /** @hidden */
  17930. _renderMultiviewToSingleView(camera: Camera): void;
  17931. }
  17932. }
  17933. }
  17934. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17935. import { Camera } from "babylonjs/Cameras/camera";
  17936. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17937. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17938. import "babylonjs/Engines/Extensions/engine.multiview";
  17939. /**
  17940. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17941. * This will not be used for webXR as it supports displaying texture arrays directly
  17942. */
  17943. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17944. /**
  17945. * Initializes a VRMultiviewToSingleview
  17946. * @param name name of the post process
  17947. * @param camera camera to be applied to
  17948. * @param scaleFactor scaling factor to the size of the output texture
  17949. */
  17950. constructor(name: string, camera: Camera, scaleFactor: number);
  17951. }
  17952. }
  17953. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17954. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17955. import { Nullable } from "babylonjs/types";
  17956. import { Size } from "babylonjs/Maths/math";
  17957. import { Observable } from "babylonjs/Misc/observable";
  17958. module "babylonjs/Engines/engine" {
  17959. interface Engine {
  17960. /** @hidden */
  17961. _vrDisplay: any;
  17962. /** @hidden */
  17963. _vrSupported: boolean;
  17964. /** @hidden */
  17965. _oldSize: Size;
  17966. /** @hidden */
  17967. _oldHardwareScaleFactor: number;
  17968. /** @hidden */
  17969. _vrExclusivePointerMode: boolean;
  17970. /** @hidden */
  17971. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17972. /** @hidden */
  17973. _onVRDisplayPointerRestricted: () => void;
  17974. /** @hidden */
  17975. _onVRDisplayPointerUnrestricted: () => void;
  17976. /** @hidden */
  17977. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17978. /** @hidden */
  17979. _onVrDisplayDisconnect: Nullable<() => void>;
  17980. /** @hidden */
  17981. _onVrDisplayPresentChange: Nullable<() => void>;
  17982. /**
  17983. * Observable signaled when VR display mode changes
  17984. */
  17985. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17986. /**
  17987. * Observable signaled when VR request present is complete
  17988. */
  17989. onVRRequestPresentComplete: Observable<boolean>;
  17990. /**
  17991. * Observable signaled when VR request present starts
  17992. */
  17993. onVRRequestPresentStart: Observable<Engine>;
  17994. /**
  17995. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17996. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17997. */
  17998. isInVRExclusivePointerMode: boolean;
  17999. /**
  18000. * Gets a boolean indicating if a webVR device was detected
  18001. * @returns true if a webVR device was detected
  18002. */
  18003. isVRDevicePresent(): boolean;
  18004. /**
  18005. * Gets the current webVR device
  18006. * @returns the current webVR device (or null)
  18007. */
  18008. getVRDevice(): any;
  18009. /**
  18010. * Initializes a webVR display and starts listening to display change events
  18011. * The onVRDisplayChangedObservable will be notified upon these changes
  18012. * @returns A promise containing a VRDisplay and if vr is supported
  18013. */
  18014. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18015. /** @hidden */
  18016. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18017. /**
  18018. * Call this function to switch to webVR mode
  18019. * Will do nothing if webVR is not supported or if there is no webVR device
  18020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18021. */
  18022. enableVR(): void;
  18023. /** @hidden */
  18024. _onVRFullScreenTriggered(): void;
  18025. }
  18026. }
  18027. }
  18028. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18029. import { Nullable } from "babylonjs/types";
  18030. import { Observable } from "babylonjs/Misc/observable";
  18031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18032. import { Scene } from "babylonjs/scene";
  18033. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18035. import { Node } from "babylonjs/node";
  18036. import { Ray } from "babylonjs/Culling/ray";
  18037. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18038. import "babylonjs/Engines/Extensions/engine.webVR";
  18039. /**
  18040. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18041. * IMPORTANT!! The data is right-hand data.
  18042. * @export
  18043. * @interface DevicePose
  18044. */
  18045. export interface DevicePose {
  18046. /**
  18047. * The position of the device, values in array are [x,y,z].
  18048. */
  18049. readonly position: Nullable<Float32Array>;
  18050. /**
  18051. * The linearVelocity of the device, values in array are [x,y,z].
  18052. */
  18053. readonly linearVelocity: Nullable<Float32Array>;
  18054. /**
  18055. * The linearAcceleration of the device, values in array are [x,y,z].
  18056. */
  18057. readonly linearAcceleration: Nullable<Float32Array>;
  18058. /**
  18059. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18060. */
  18061. readonly orientation: Nullable<Float32Array>;
  18062. /**
  18063. * The angularVelocity of the device, values in array are [x,y,z].
  18064. */
  18065. readonly angularVelocity: Nullable<Float32Array>;
  18066. /**
  18067. * The angularAcceleration of the device, values in array are [x,y,z].
  18068. */
  18069. readonly angularAcceleration: Nullable<Float32Array>;
  18070. }
  18071. /**
  18072. * Interface representing a pose controlled object in Babylon.
  18073. * A pose controlled object has both regular pose values as well as pose values
  18074. * from an external device such as a VR head mounted display
  18075. */
  18076. export interface PoseControlled {
  18077. /**
  18078. * The position of the object in babylon space.
  18079. */
  18080. position: Vector3;
  18081. /**
  18082. * The rotation quaternion of the object in babylon space.
  18083. */
  18084. rotationQuaternion: Quaternion;
  18085. /**
  18086. * The position of the device in babylon space.
  18087. */
  18088. devicePosition?: Vector3;
  18089. /**
  18090. * The rotation quaternion of the device in babylon space.
  18091. */
  18092. deviceRotationQuaternion: Quaternion;
  18093. /**
  18094. * The raw pose coming from the device.
  18095. */
  18096. rawPose: Nullable<DevicePose>;
  18097. /**
  18098. * The scale of the device to be used when translating from device space to babylon space.
  18099. */
  18100. deviceScaleFactor: number;
  18101. /**
  18102. * Updates the poseControlled values based on the input device pose.
  18103. * @param poseData the pose data to update the object with
  18104. */
  18105. updateFromDevice(poseData: DevicePose): void;
  18106. }
  18107. /**
  18108. * Set of options to customize the webVRCamera
  18109. */
  18110. export interface WebVROptions {
  18111. /**
  18112. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18113. */
  18114. trackPosition?: boolean;
  18115. /**
  18116. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18117. */
  18118. positionScale?: number;
  18119. /**
  18120. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18121. */
  18122. displayName?: string;
  18123. /**
  18124. * Should the native controller meshes be initialized. (default: true)
  18125. */
  18126. controllerMeshes?: boolean;
  18127. /**
  18128. * Creating a default HemiLight only on controllers. (default: true)
  18129. */
  18130. defaultLightingOnControllers?: boolean;
  18131. /**
  18132. * If you don't want to use the default VR button of the helper. (default: false)
  18133. */
  18134. useCustomVRButton?: boolean;
  18135. /**
  18136. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18137. */
  18138. customVRButton?: HTMLButtonElement;
  18139. /**
  18140. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18141. */
  18142. rayLength?: number;
  18143. /**
  18144. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18145. */
  18146. defaultHeight?: number;
  18147. /**
  18148. * If multiview should be used if availible (default: false)
  18149. */
  18150. useMultiview?: boolean;
  18151. }
  18152. /**
  18153. * This represents a WebVR camera.
  18154. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18155. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18156. */
  18157. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18158. private webVROptions;
  18159. /**
  18160. * @hidden
  18161. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18162. */
  18163. _vrDevice: any;
  18164. /**
  18165. * The rawPose of the vrDevice.
  18166. */
  18167. rawPose: Nullable<DevicePose>;
  18168. private _onVREnabled;
  18169. private _specsVersion;
  18170. private _attached;
  18171. private _frameData;
  18172. protected _descendants: Array<Node>;
  18173. private _deviceRoomPosition;
  18174. /** @hidden */
  18175. _deviceRoomRotationQuaternion: Quaternion;
  18176. private _standingMatrix;
  18177. /**
  18178. * Represents device position in babylon space.
  18179. */
  18180. devicePosition: Vector3;
  18181. /**
  18182. * Represents device rotation in babylon space.
  18183. */
  18184. deviceRotationQuaternion: Quaternion;
  18185. /**
  18186. * The scale of the device to be used when translating from device space to babylon space.
  18187. */
  18188. deviceScaleFactor: number;
  18189. private _deviceToWorld;
  18190. private _worldToDevice;
  18191. /**
  18192. * References to the webVR controllers for the vrDevice.
  18193. */
  18194. controllers: Array<WebVRController>;
  18195. /**
  18196. * Emits an event when a controller is attached.
  18197. */
  18198. onControllersAttachedObservable: Observable<WebVRController[]>;
  18199. /**
  18200. * Emits an event when a controller's mesh has been loaded;
  18201. */
  18202. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18203. /**
  18204. * Emits an event when the HMD's pose has been updated.
  18205. */
  18206. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18207. private _poseSet;
  18208. /**
  18209. * If the rig cameras be used as parent instead of this camera.
  18210. */
  18211. rigParenting: boolean;
  18212. private _lightOnControllers;
  18213. private _defaultHeight?;
  18214. /**
  18215. * Instantiates a WebVRFreeCamera.
  18216. * @param name The name of the WebVRFreeCamera
  18217. * @param position The starting anchor position for the camera
  18218. * @param scene The scene the camera belongs to
  18219. * @param webVROptions a set of customizable options for the webVRCamera
  18220. */
  18221. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18222. /**
  18223. * Gets the device distance from the ground in meters.
  18224. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  18225. */
  18226. deviceDistanceToRoomGround(): number;
  18227. /**
  18228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18229. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18230. */
  18231. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18232. /**
  18233. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18234. * @returns A promise with a boolean set to if the standing matrix is supported.
  18235. */
  18236. useStandingMatrixAsync(): Promise<boolean>;
  18237. /**
  18238. * Disposes the camera
  18239. */
  18240. dispose(): void;
  18241. /**
  18242. * Gets a vrController by name.
  18243. * @param name The name of the controller to retreive
  18244. * @returns the controller matching the name specified or null if not found
  18245. */
  18246. getControllerByName(name: string): Nullable<WebVRController>;
  18247. private _leftController;
  18248. /**
  18249. * The controller corresponding to the users left hand.
  18250. */
  18251. readonly leftController: Nullable<WebVRController>;
  18252. private _rightController;
  18253. /**
  18254. * The controller corresponding to the users right hand.
  18255. */
  18256. readonly rightController: Nullable<WebVRController>;
  18257. /**
  18258. * Casts a ray forward from the vrCamera's gaze.
  18259. * @param length Length of the ray (default: 100)
  18260. * @returns the ray corresponding to the gaze
  18261. */
  18262. getForwardRay(length?: number): Ray;
  18263. /**
  18264. * @hidden
  18265. * Updates the camera based on device's frame data
  18266. */
  18267. _checkInputs(): void;
  18268. /**
  18269. * Updates the poseControlled values based on the input device pose.
  18270. * @param poseData Pose coming from the device
  18271. */
  18272. updateFromDevice(poseData: DevicePose): void;
  18273. private _htmlElementAttached;
  18274. private _detachIfAttached;
  18275. /**
  18276. * WebVR's attach control will start broadcasting frames to the device.
  18277. * Note that in certain browsers (chrome for example) this function must be called
  18278. * within a user-interaction callback. Example:
  18279. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18280. *
  18281. * @param element html element to attach the vrDevice to
  18282. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18283. */
  18284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18285. /**
  18286. * Detaches the camera from the html element and disables VR
  18287. *
  18288. * @param element html element to detach from
  18289. */
  18290. detachControl(element: HTMLElement): void;
  18291. /**
  18292. * @returns the name of this class
  18293. */
  18294. getClassName(): string;
  18295. /**
  18296. * Calls resetPose on the vrDisplay
  18297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18298. */
  18299. resetToCurrentRotation(): void;
  18300. /**
  18301. * @hidden
  18302. * Updates the rig cameras (left and right eye)
  18303. */
  18304. _updateRigCameras(): void;
  18305. private _workingVector;
  18306. private _oneVector;
  18307. private _workingMatrix;
  18308. private updateCacheCalled;
  18309. private _correctPositionIfNotTrackPosition;
  18310. /**
  18311. * @hidden
  18312. * Updates the cached values of the camera
  18313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18314. */
  18315. _updateCache(ignoreParentClass?: boolean): void;
  18316. /**
  18317. * @hidden
  18318. * Get current device position in babylon world
  18319. */
  18320. _computeDevicePosition(): void;
  18321. /**
  18322. * Updates the current device position and rotation in the babylon world
  18323. */
  18324. update(): void;
  18325. /**
  18326. * @hidden
  18327. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18328. * @returns an identity matrix
  18329. */
  18330. _getViewMatrix(): Matrix;
  18331. private _tmpMatrix;
  18332. /**
  18333. * This function is called by the two RIG cameras.
  18334. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18335. * @hidden
  18336. */
  18337. _getWebVRViewMatrix(): Matrix;
  18338. /** @hidden */
  18339. _getWebVRProjectionMatrix(): Matrix;
  18340. private _onGamepadConnectedObserver;
  18341. private _onGamepadDisconnectedObserver;
  18342. private _updateCacheWhenTrackingDisabledObserver;
  18343. /**
  18344. * Initializes the controllers and their meshes
  18345. */
  18346. initControllers(): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/PostProcesses/postProcess" {
  18350. import { Nullable } from "babylonjs/types";
  18351. import { SmartArray } from "babylonjs/Misc/smartArray";
  18352. import { Observable } from "babylonjs/Misc/observable";
  18353. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18354. import { Camera } from "babylonjs/Cameras/camera";
  18355. import { Effect } from "babylonjs/Materials/effect";
  18356. import "babylonjs/Shaders/postprocess.vertex";
  18357. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18359. import { Engine } from "babylonjs/Engines/engine";
  18360. /**
  18361. * Size options for a post process
  18362. */
  18363. export type PostProcessOptions = {
  18364. width: number;
  18365. height: number;
  18366. };
  18367. /**
  18368. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18369. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18370. */
  18371. export class PostProcess {
  18372. /** Name of the PostProcess. */
  18373. name: string;
  18374. /**
  18375. * Gets or sets the unique id of the post process
  18376. */
  18377. uniqueId: number;
  18378. /**
  18379. * Width of the texture to apply the post process on
  18380. */
  18381. width: number;
  18382. /**
  18383. * Height of the texture to apply the post process on
  18384. */
  18385. height: number;
  18386. /**
  18387. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18388. * @hidden
  18389. */
  18390. _outputTexture: Nullable<InternalTexture>;
  18391. /**
  18392. * Sampling mode used by the shader
  18393. * See https://doc.babylonjs.com/classes/3.1/texture
  18394. */
  18395. renderTargetSamplingMode: number;
  18396. /**
  18397. * Clear color to use when screen clearing
  18398. */
  18399. clearColor: Color4;
  18400. /**
  18401. * If the buffer needs to be cleared before applying the post process. (default: true)
  18402. * Should be set to false if shader will overwrite all previous pixels.
  18403. */
  18404. autoClear: boolean;
  18405. /**
  18406. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18407. */
  18408. alphaMode: number;
  18409. /**
  18410. * Sets the setAlphaBlendConstants of the babylon engine
  18411. */
  18412. alphaConstants: Color4;
  18413. /**
  18414. * Animations to be used for the post processing
  18415. */
  18416. animations: import("babylonjs/Animations/animation").Animation[];
  18417. /**
  18418. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18419. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18420. */
  18421. enablePixelPerfectMode: boolean;
  18422. /**
  18423. * Force the postprocess to be applied without taking in account viewport
  18424. */
  18425. forceFullscreenViewport: boolean;
  18426. /**
  18427. * List of inspectable custom properties (used by the Inspector)
  18428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18429. */
  18430. inspectableCustomProperties: IInspectable[];
  18431. /**
  18432. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18433. *
  18434. * | Value | Type | Description |
  18435. * | ----- | ----------------------------------- | ----------- |
  18436. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18437. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18438. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18439. *
  18440. */
  18441. scaleMode: number;
  18442. /**
  18443. * Force textures to be a power of two (default: false)
  18444. */
  18445. alwaysForcePOT: boolean;
  18446. private _samples;
  18447. /**
  18448. * Number of sample textures (default: 1)
  18449. */
  18450. samples: number;
  18451. /**
  18452. * Modify the scale of the post process to be the same as the viewport (default: false)
  18453. */
  18454. adaptScaleToCurrentViewport: boolean;
  18455. private _camera;
  18456. private _scene;
  18457. private _engine;
  18458. private _options;
  18459. private _reusable;
  18460. private _textureType;
  18461. /**
  18462. * Smart array of input and output textures for the post process.
  18463. * @hidden
  18464. */
  18465. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18466. /**
  18467. * The index in _textures that corresponds to the output texture.
  18468. * @hidden
  18469. */
  18470. _currentRenderTextureInd: number;
  18471. private _effect;
  18472. private _samplers;
  18473. private _fragmentUrl;
  18474. private _vertexUrl;
  18475. private _parameters;
  18476. private _scaleRatio;
  18477. protected _indexParameters: any;
  18478. private _shareOutputWithPostProcess;
  18479. private _texelSize;
  18480. private _forcedOutputTexture;
  18481. /**
  18482. * Returns the fragment url or shader name used in the post process.
  18483. * @returns the fragment url or name in the shader store.
  18484. */
  18485. getEffectName(): string;
  18486. /**
  18487. * An event triggered when the postprocess is activated.
  18488. */
  18489. onActivateObservable: Observable<Camera>;
  18490. private _onActivateObserver;
  18491. /**
  18492. * A function that is added to the onActivateObservable
  18493. */
  18494. onActivate: Nullable<(camera: Camera) => void>;
  18495. /**
  18496. * An event triggered when the postprocess changes its size.
  18497. */
  18498. onSizeChangedObservable: Observable<PostProcess>;
  18499. private _onSizeChangedObserver;
  18500. /**
  18501. * A function that is added to the onSizeChangedObservable
  18502. */
  18503. onSizeChanged: (postProcess: PostProcess) => void;
  18504. /**
  18505. * An event triggered when the postprocess applies its effect.
  18506. */
  18507. onApplyObservable: Observable<Effect>;
  18508. private _onApplyObserver;
  18509. /**
  18510. * A function that is added to the onApplyObservable
  18511. */
  18512. onApply: (effect: Effect) => void;
  18513. /**
  18514. * An event triggered before rendering the postprocess
  18515. */
  18516. onBeforeRenderObservable: Observable<Effect>;
  18517. private _onBeforeRenderObserver;
  18518. /**
  18519. * A function that is added to the onBeforeRenderObservable
  18520. */
  18521. onBeforeRender: (effect: Effect) => void;
  18522. /**
  18523. * An event triggered after rendering the postprocess
  18524. */
  18525. onAfterRenderObservable: Observable<Effect>;
  18526. private _onAfterRenderObserver;
  18527. /**
  18528. * A function that is added to the onAfterRenderObservable
  18529. */
  18530. onAfterRender: (efect: Effect) => void;
  18531. /**
  18532. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  18533. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18534. */
  18535. inputTexture: InternalTexture;
  18536. /**
  18537. * Gets the camera which post process is applied to.
  18538. * @returns The camera the post process is applied to.
  18539. */
  18540. getCamera(): Camera;
  18541. /**
  18542. * Gets the texel size of the postprocess.
  18543. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18544. */
  18545. readonly texelSize: Vector2;
  18546. /**
  18547. * Creates a new instance PostProcess
  18548. * @param name The name of the PostProcess.
  18549. * @param fragmentUrl The url of the fragment shader to be used.
  18550. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18551. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18552. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18553. * @param camera The camera to apply the render pass to.
  18554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18555. * @param engine The engine which the post process will be applied. (default: current engine)
  18556. * @param reusable If the post process can be reused on the same frame. (default: false)
  18557. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18558. * @param textureType Type of textures used when performing the post process. (default: 0)
  18559. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18560. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  18561. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18562. */
  18563. constructor(
  18564. /** Name of the PostProcess. */
  18565. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  18566. /**
  18567. * Gets a string idenfifying the name of the class
  18568. * @returns "PostProcess" string
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Gets the engine which this post process belongs to.
  18573. * @returns The engine the post process was enabled with.
  18574. */
  18575. getEngine(): Engine;
  18576. /**
  18577. * The effect that is created when initializing the post process.
  18578. * @returns The created effect corresponding the the postprocess.
  18579. */
  18580. getEffect(): Effect;
  18581. /**
  18582. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18583. * @param postProcess The post process to share the output with.
  18584. * @returns This post process.
  18585. */
  18586. shareOutputWith(postProcess: PostProcess): PostProcess;
  18587. /**
  18588. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18589. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18590. */
  18591. useOwnOutput(): void;
  18592. /**
  18593. * Updates the effect with the current post process compile time values and recompiles the shader.
  18594. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18595. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18596. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18597. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  18598. * @param onCompiled Called when the shader has been compiled.
  18599. * @param onError Called if there is an error when compiling a shader.
  18600. */
  18601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18602. /**
  18603. * The post process is reusable if it can be used multiple times within one frame.
  18604. * @returns If the post process is reusable
  18605. */
  18606. isReusable(): boolean;
  18607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18608. markTextureDirty(): void;
  18609. /**
  18610. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18611. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  18612. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18613. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18614. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18615. * @returns The target texture that was bound to be written to.
  18616. */
  18617. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18618. /**
  18619. * If the post process is supported.
  18620. */
  18621. readonly isSupported: boolean;
  18622. /**
  18623. * The aspect ratio of the output texture.
  18624. */
  18625. readonly aspectRatio: number;
  18626. /**
  18627. * Get a value indicating if the post-process is ready to be used
  18628. * @returns true if the post-process is ready (shader is compiled)
  18629. */
  18630. isReady(): boolean;
  18631. /**
  18632. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18633. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18634. */
  18635. apply(): Nullable<Effect>;
  18636. private _disposeTextures;
  18637. /**
  18638. * Disposes the post process.
  18639. * @param camera The camera to dispose the post process on.
  18640. */
  18641. dispose(camera?: Camera): void;
  18642. }
  18643. }
  18644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18645. /** @hidden */
  18646. export var kernelBlurVaryingDeclaration: {
  18647. name: string;
  18648. shader: string;
  18649. };
  18650. }
  18651. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18652. /** @hidden */
  18653. export var kernelBlurFragment: {
  18654. name: string;
  18655. shader: string;
  18656. };
  18657. }
  18658. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18659. /** @hidden */
  18660. export var kernelBlurFragment2: {
  18661. name: string;
  18662. shader: string;
  18663. };
  18664. }
  18665. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18666. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18669. /** @hidden */
  18670. export var kernelBlurPixelShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18676. /** @hidden */
  18677. export var kernelBlurVertex: {
  18678. name: string;
  18679. shader: string;
  18680. };
  18681. }
  18682. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18683. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18684. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18685. /** @hidden */
  18686. export var kernelBlurVertexShader: {
  18687. name: string;
  18688. shader: string;
  18689. };
  18690. }
  18691. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18692. import { Vector2 } from "babylonjs/Maths/math";
  18693. import { Nullable } from "babylonjs/types";
  18694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18695. import { Camera } from "babylonjs/Cameras/camera";
  18696. import { Effect } from "babylonjs/Materials/effect";
  18697. import { Engine } from "babylonjs/Engines/engine";
  18698. import "babylonjs/Shaders/kernelBlur.fragment";
  18699. import "babylonjs/Shaders/kernelBlur.vertex";
  18700. /**
  18701. * The Blur Post Process which blurs an image based on a kernel and direction.
  18702. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18703. */
  18704. export class BlurPostProcess extends PostProcess {
  18705. /** The direction in which to blur the image. */
  18706. direction: Vector2;
  18707. private blockCompilation;
  18708. protected _kernel: number;
  18709. protected _idealKernel: number;
  18710. protected _packedFloat: boolean;
  18711. private _staticDefines;
  18712. /**
  18713. * Sets the length in pixels of the blur sample region
  18714. */
  18715. /**
  18716. * Gets the length in pixels of the blur sample region
  18717. */
  18718. kernel: number;
  18719. /**
  18720. * Sets wether or not the blur needs to unpack/repack floats
  18721. */
  18722. /**
  18723. * Gets wether or not the blur is unpacking/repacking floats
  18724. */
  18725. packedFloat: boolean;
  18726. /**
  18727. * Creates a new instance BlurPostProcess
  18728. * @param name The name of the effect.
  18729. * @param direction The direction in which to blur the image.
  18730. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  18731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18732. * @param camera The camera to apply the render pass to.
  18733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18734. * @param engine The engine which the post process will be applied. (default: current engine)
  18735. * @param reusable If the post process can be reused on the same frame. (default: false)
  18736. * @param textureType Type of textures used when performing the post process. (default: 0)
  18737. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  18738. */
  18739. constructor(name: string,
  18740. /** The direction in which to blur the image. */
  18741. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18742. /**
  18743. * Updates the effect with the current post process compile time values and recompiles the shader.
  18744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18747. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  18748. * @param onCompiled Called when the shader has been compiled.
  18749. * @param onError Called if there is an error when compiling a shader.
  18750. */
  18751. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18752. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18753. /**
  18754. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18755. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18756. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18757. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18758. * The gaps between physical kernels are compensated for in the weighting of the samples
  18759. * @param idealKernel Ideal blur kernel.
  18760. * @return Nearest best kernel.
  18761. */
  18762. protected _nearestBestKernel(idealKernel: number): number;
  18763. /**
  18764. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18765. * @param x The point on the Gaussian distribution to sample.
  18766. * @return the value of the Gaussian function at x.
  18767. */
  18768. protected _gaussianWeight(x: number): number;
  18769. /**
  18770. * Generates a string that can be used as a floating point number in GLSL.
  18771. * @param x Value to print.
  18772. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18773. * @return GLSL float string.
  18774. */
  18775. protected _glslFloat(x: number, decimalFigures?: number): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18779. import { Scene } from "babylonjs/scene";
  18780. import { Plane } from "babylonjs/Maths/math";
  18781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18782. /**
  18783. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18784. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18785. * You can then easily use it as a reflectionTexture on a flat surface.
  18786. * In case the surface is not a plane, please consider relying on reflection probes.
  18787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18788. */
  18789. export class MirrorTexture extends RenderTargetTexture {
  18790. private scene;
  18791. /**
  18792. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18793. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  18794. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18795. */
  18796. mirrorPlane: Plane;
  18797. /**
  18798. * Define the blur ratio used to blur the reflection if needed.
  18799. */
  18800. blurRatio: number;
  18801. /**
  18802. * Define the adaptive blur kernel used to blur the reflection if needed.
  18803. * This will autocompute the closest best match for the `blurKernel`
  18804. */
  18805. adaptiveBlurKernel: number;
  18806. /**
  18807. * Define the blur kernel used to blur the reflection if needed.
  18808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18809. */
  18810. blurKernel: number;
  18811. /**
  18812. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18814. */
  18815. blurKernelX: number;
  18816. /**
  18817. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18819. */
  18820. blurKernelY: number;
  18821. private _autoComputeBlurKernel;
  18822. protected _onRatioRescale(): void;
  18823. private _updateGammaSpace;
  18824. private _imageProcessingConfigChangeObserver;
  18825. private _transformMatrix;
  18826. private _mirrorMatrix;
  18827. private _savedViewMatrix;
  18828. private _blurX;
  18829. private _blurY;
  18830. private _adaptiveBlurKernel;
  18831. private _blurKernelX;
  18832. private _blurKernelY;
  18833. private _blurRatio;
  18834. /**
  18835. * Instantiates a Mirror Texture.
  18836. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18837. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18838. * You can then easily use it as a reflectionTexture on a flat surface.
  18839. * In case the surface is not a plane, please consider relying on reflection probes.
  18840. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18841. * @param name
  18842. * @param size
  18843. * @param scene
  18844. * @param generateMipMaps
  18845. * @param type
  18846. * @param samplingMode
  18847. * @param generateDepthBuffer
  18848. */
  18849. constructor(name: string, size: number | {
  18850. width: number;
  18851. height: number;
  18852. } | {
  18853. ratio: number;
  18854. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18855. private _preparePostProcesses;
  18856. /**
  18857. * Clone the mirror texture.
  18858. * @returns the cloned texture
  18859. */
  18860. clone(): MirrorTexture;
  18861. /**
  18862. * Serialize the texture to a JSON representation you could use in Parse later on
  18863. * @returns the serialized JSON representation
  18864. */
  18865. serialize(): any;
  18866. /**
  18867. * Dispose the texture and release its associated resources.
  18868. */
  18869. dispose(): void;
  18870. }
  18871. }
  18872. declare module "babylonjs/Materials/Textures/texture" {
  18873. import { Observable } from "babylonjs/Misc/observable";
  18874. import { Nullable } from "babylonjs/types";
  18875. import { Scene } from "babylonjs/scene";
  18876. import { Matrix } from "babylonjs/Maths/math";
  18877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18878. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18879. import { Engine } from "babylonjs/Engines/engine";
  18880. /**
  18881. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18882. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18883. */
  18884. export class Texture extends BaseTexture {
  18885. /** @hidden */
  18886. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18887. /** @hidden */
  18888. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18889. /** @hidden */
  18890. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18891. /** nearest is mag = nearest and min = nearest and mip = linear */
  18892. static readonly NEAREST_SAMPLINGMODE: number;
  18893. /** nearest is mag = nearest and min = nearest and mip = linear */
  18894. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18896. static readonly BILINEAR_SAMPLINGMODE: number;
  18897. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18898. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18899. /** Trilinear is mag = linear and min = linear and mip = linear */
  18900. static readonly TRILINEAR_SAMPLINGMODE: number;
  18901. /** Trilinear is mag = linear and min = linear and mip = linear */
  18902. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18903. /** mag = nearest and min = nearest and mip = nearest */
  18904. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18905. /** mag = nearest and min = linear and mip = nearest */
  18906. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18907. /** mag = nearest and min = linear and mip = linear */
  18908. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18909. /** mag = nearest and min = linear and mip = none */
  18910. static readonly NEAREST_LINEAR: number;
  18911. /** mag = nearest and min = nearest and mip = none */
  18912. static readonly NEAREST_NEAREST: number;
  18913. /** mag = linear and min = nearest and mip = nearest */
  18914. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18915. /** mag = linear and min = nearest and mip = linear */
  18916. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18917. /** mag = linear and min = linear and mip = none */
  18918. static readonly LINEAR_LINEAR: number;
  18919. /** mag = linear and min = nearest and mip = none */
  18920. static readonly LINEAR_NEAREST: number;
  18921. /** Explicit coordinates mode */
  18922. static readonly EXPLICIT_MODE: number;
  18923. /** Spherical coordinates mode */
  18924. static readonly SPHERICAL_MODE: number;
  18925. /** Planar coordinates mode */
  18926. static readonly PLANAR_MODE: number;
  18927. /** Cubic coordinates mode */
  18928. static readonly CUBIC_MODE: number;
  18929. /** Projection coordinates mode */
  18930. static readonly PROJECTION_MODE: number;
  18931. /** Inverse Cubic coordinates mode */
  18932. static readonly SKYBOX_MODE: number;
  18933. /** Inverse Cubic coordinates mode */
  18934. static readonly INVCUBIC_MODE: number;
  18935. /** Equirectangular coordinates mode */
  18936. static readonly EQUIRECTANGULAR_MODE: number;
  18937. /** Equirectangular Fixed coordinates mode */
  18938. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18939. /** Equirectangular Fixed Mirrored coordinates mode */
  18940. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18941. /** Texture is not repeating outside of 0..1 UVs */
  18942. static readonly CLAMP_ADDRESSMODE: number;
  18943. /** Texture is repeating outside of 0..1 UVs */
  18944. static readonly WRAP_ADDRESSMODE: number;
  18945. /** Texture is repeating and mirrored */
  18946. static readonly MIRROR_ADDRESSMODE: number;
  18947. /**
  18948. * 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
  18949. */
  18950. static UseSerializedUrlIfAny: boolean;
  18951. /**
  18952. * Define the url of the texture.
  18953. */
  18954. url: Nullable<string>;
  18955. /**
  18956. * Define an offset on the texture to offset the u coordinates of the UVs
  18957. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18958. */
  18959. uOffset: number;
  18960. /**
  18961. * Define an offset on the texture to offset the v coordinates of the UVs
  18962. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18963. */
  18964. vOffset: number;
  18965. /**
  18966. * Define an offset on the texture to scale the u coordinates of the UVs
  18967. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18968. */
  18969. uScale: number;
  18970. /**
  18971. * Define an offset on the texture to scale the v coordinates of the UVs
  18972. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18973. */
  18974. vScale: number;
  18975. /**
  18976. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18977. * @see http://doc.babylonjs.com/how_to/more_materials
  18978. */
  18979. uAng: number;
  18980. /**
  18981. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18982. * @see http://doc.babylonjs.com/how_to/more_materials
  18983. */
  18984. vAng: number;
  18985. /**
  18986. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18987. * @see http://doc.babylonjs.com/how_to/more_materials
  18988. */
  18989. wAng: number;
  18990. /**
  18991. * Defines the center of rotation (U)
  18992. */
  18993. uRotationCenter: number;
  18994. /**
  18995. * Defines the center of rotation (V)
  18996. */
  18997. vRotationCenter: number;
  18998. /**
  18999. * Defines the center of rotation (W)
  19000. */
  19001. wRotationCenter: number;
  19002. /**
  19003. * Are mip maps generated for this texture or not.
  19004. */
  19005. readonly noMipmap: boolean;
  19006. /**
  19007. * List of inspectable custom properties (used by the Inspector)
  19008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19009. */
  19010. inspectableCustomProperties: Nullable<IInspectable[]>;
  19011. private _noMipmap;
  19012. /** @hidden */
  19013. _invertY: boolean;
  19014. private _rowGenerationMatrix;
  19015. private _cachedTextureMatrix;
  19016. private _projectionModeMatrix;
  19017. private _t0;
  19018. private _t1;
  19019. private _t2;
  19020. private _cachedUOffset;
  19021. private _cachedVOffset;
  19022. private _cachedUScale;
  19023. private _cachedVScale;
  19024. private _cachedUAng;
  19025. private _cachedVAng;
  19026. private _cachedWAng;
  19027. private _cachedProjectionMatrixId;
  19028. private _cachedCoordinatesMode;
  19029. /** @hidden */
  19030. protected _initialSamplingMode: number;
  19031. /** @hidden */
  19032. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19033. private _deleteBuffer;
  19034. protected _format: Nullable<number>;
  19035. private _delayedOnLoad;
  19036. private _delayedOnError;
  19037. /**
  19038. * Observable triggered once the texture has been loaded.
  19039. */
  19040. onLoadObservable: Observable<Texture>;
  19041. protected _isBlocking: boolean;
  19042. /**
  19043. * Is the texture preventing material to render while loading.
  19044. * If false, a default texture will be used instead of the loading one during the preparation step.
  19045. */
  19046. isBlocking: boolean;
  19047. /**
  19048. * Get the current sampling mode associated with the texture.
  19049. */
  19050. readonly samplingMode: number;
  19051. /**
  19052. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19053. */
  19054. readonly invertY: boolean;
  19055. /**
  19056. * Instantiates a new texture.
  19057. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19058. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19059. * @param url define the url of the picture to load as a texture
  19060. * @param scene define the scene or engine the texture will belong to
  19061. * @param noMipmap define if the texture will require mip maps or not
  19062. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19063. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19064. * @param onLoad define a callback triggered when the texture has been loaded
  19065. * @param onError define a callback triggered when an error occurred during the loading session
  19066. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19067. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19068. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19069. */
  19070. 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);
  19071. /**
  19072. * Update the url (and optional buffer) of this texture if url was null during construction.
  19073. * @param url the url of the texture
  19074. * @param buffer the buffer of the texture (defaults to null)
  19075. * @param onLoad callback called when the texture is loaded (defaults to null)
  19076. */
  19077. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19078. /**
  19079. * Finish the loading sequence of a texture flagged as delayed load.
  19080. * @hidden
  19081. */
  19082. delayLoad(): void;
  19083. private _prepareRowForTextureGeneration;
  19084. /**
  19085. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19086. * @returns the transform matrix of the texture.
  19087. */
  19088. getTextureMatrix(): Matrix;
  19089. /**
  19090. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19091. * @returns The reflection texture transform
  19092. */
  19093. getReflectionTextureMatrix(): Matrix;
  19094. /**
  19095. * Clones the texture.
  19096. * @returns the cloned texture
  19097. */
  19098. clone(): Texture;
  19099. /**
  19100. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19101. * @returns The JSON representation of the texture
  19102. */
  19103. serialize(): any;
  19104. /**
  19105. * Get the current class name of the texture useful for serialization or dynamic coding.
  19106. * @returns "Texture"
  19107. */
  19108. getClassName(): string;
  19109. /**
  19110. * Dispose the texture and release its associated resources.
  19111. */
  19112. dispose(): void;
  19113. /**
  19114. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19115. * @param parsedTexture Define the JSON representation of the texture
  19116. * @param scene Define the scene the parsed texture should be instantiated in
  19117. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19118. * @returns The parsed texture if successful
  19119. */
  19120. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19121. /**
  19122. * Creates a texture from its base 64 representation.
  19123. * @param data Define the base64 payload without the data: prefix
  19124. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19125. * @param scene Define the scene the texture should belong to
  19126. * @param noMipmap Forces the texture to not create mip map information if true
  19127. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19128. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19129. * @param onLoad define a callback triggered when the texture has been loaded
  19130. * @param onError define a callback triggered when an error occurred during the loading session
  19131. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19132. * @returns the created texture
  19133. */
  19134. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19135. /**
  19136. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19137. * @param data Define the base64 payload without the data: prefix
  19138. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19139. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19140. * @param scene Define the scene the texture should belong to
  19141. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  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 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;
  19151. }
  19152. }
  19153. declare module "babylonjs/PostProcesses/postProcessManager" {
  19154. import { Nullable } from "babylonjs/types";
  19155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19156. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19157. import { Scene } from "babylonjs/scene";
  19158. /**
  19159. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19160. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19161. */
  19162. export class PostProcessManager {
  19163. private _scene;
  19164. private _indexBuffer;
  19165. private _vertexBuffers;
  19166. /**
  19167. * Creates a new instance PostProcess
  19168. * @param scene The scene that the post process is associated with.
  19169. */
  19170. constructor(scene: Scene);
  19171. private _prepareBuffers;
  19172. private _buildIndexBuffer;
  19173. /**
  19174. * Rebuilds the vertex buffers of the manager.
  19175. * @hidden
  19176. */
  19177. _rebuild(): void;
  19178. /**
  19179. * Prepares a frame to be run through a post process.
  19180. * @param sourceTexture The input texture to the post procesess. (default: null)
  19181. * @param postProcesses An array of post processes to be run. (default: null)
  19182. * @returns True if the post processes were able to be run.
  19183. * @hidden
  19184. */
  19185. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19186. /**
  19187. * Manually render a set of post processes to a texture.
  19188. * @param postProcesses An array of post processes to be run.
  19189. * @param targetTexture The target texture to render to.
  19190. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19191. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19192. * @param lodLevel defines which lod of the texture to render to
  19193. */
  19194. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19195. /**
  19196. * Finalize the result of the output of the postprocesses.
  19197. * @param doNotPresent If true the result will not be displayed to the screen.
  19198. * @param targetTexture The target texture to render to.
  19199. * @param faceIndex The index of the face to bind the target texture to.
  19200. * @param postProcesses The array of post processes to render.
  19201. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19202. * @hidden
  19203. */
  19204. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19205. /**
  19206. * Disposes of the post process manager.
  19207. */
  19208. dispose(): void;
  19209. }
  19210. }
  19211. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19212. import { Scene } from "babylonjs/scene";
  19213. import { ISceneComponent } from "babylonjs/sceneComponent";
  19214. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19215. module "babylonjs/abstractScene" {
  19216. interface AbstractScene {
  19217. /**
  19218. * The list of procedural textures added to the scene
  19219. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19220. */
  19221. proceduralTextures: Array<ProceduralTexture>;
  19222. }
  19223. }
  19224. /**
  19225. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19226. * in a given scene.
  19227. */
  19228. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19229. /**
  19230. * The component name helpfull to identify the component in the list of scene components.
  19231. */
  19232. readonly name: string;
  19233. /**
  19234. * The scene the component belongs to.
  19235. */
  19236. scene: Scene;
  19237. /**
  19238. * Creates a new instance of the component for the given scene
  19239. * @param scene Defines the scene to register the component in
  19240. */
  19241. constructor(scene: Scene);
  19242. /**
  19243. * Registers the component in a given scene
  19244. */
  19245. register(): void;
  19246. /**
  19247. * Rebuilds the elements related to this component in case of
  19248. * context lost for instance.
  19249. */
  19250. rebuild(): void;
  19251. /**
  19252. * Disposes the component and the associated ressources.
  19253. */
  19254. dispose(): void;
  19255. private _beforeClear;
  19256. }
  19257. }
  19258. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19260. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19261. module "babylonjs/Engines/engine" {
  19262. interface Engine {
  19263. /**
  19264. * Creates a new render target cube texture
  19265. * @param size defines the size of the texture
  19266. * @param options defines the options used to create the texture
  19267. * @returns a new render target cube texture stored in an InternalTexture
  19268. */
  19269. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19270. }
  19271. }
  19272. }
  19273. declare module "babylonjs/Shaders/procedural.vertex" {
  19274. /** @hidden */
  19275. export var proceduralVertexShader: {
  19276. name: string;
  19277. shader: string;
  19278. };
  19279. }
  19280. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19281. import { Observable } from "babylonjs/Misc/observable";
  19282. import { Nullable } from "babylonjs/types";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19285. import { Effect } from "babylonjs/Materials/effect";
  19286. import { Texture } from "babylonjs/Materials/Textures/texture";
  19287. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19288. import "babylonjs/Shaders/procedural.vertex";
  19289. /**
  19290. * 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.
  19291. * This is the base class of any Procedural texture and contains most of the shareable code.
  19292. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19293. */
  19294. export class ProceduralTexture extends Texture {
  19295. isCube: boolean;
  19296. /**
  19297. * Define if the texture is enabled or not (disabled texture will not render)
  19298. */
  19299. isEnabled: boolean;
  19300. /**
  19301. * Define if the texture must be cleared before rendering (default is true)
  19302. */
  19303. autoClear: boolean;
  19304. /**
  19305. * Callback called when the texture is generated
  19306. */
  19307. onGenerated: () => void;
  19308. /**
  19309. * Event raised when the texture is generated
  19310. */
  19311. onGeneratedObservable: Observable<ProceduralTexture>;
  19312. /** @hidden */
  19313. _generateMipMaps: boolean;
  19314. /** @hidden **/
  19315. _effect: Effect;
  19316. /** @hidden */
  19317. _textures: {
  19318. [key: string]: Texture;
  19319. };
  19320. private _size;
  19321. private _currentRefreshId;
  19322. private _refreshRate;
  19323. private _vertexBuffers;
  19324. private _indexBuffer;
  19325. private _uniforms;
  19326. private _samplers;
  19327. private _fragment;
  19328. private _floats;
  19329. private _ints;
  19330. private _floatsArrays;
  19331. private _colors3;
  19332. private _colors4;
  19333. private _vectors2;
  19334. private _vectors3;
  19335. private _matrices;
  19336. private _fallbackTexture;
  19337. private _fallbackTextureUsed;
  19338. private _engine;
  19339. private _cachedDefines;
  19340. private _contentUpdateId;
  19341. private _contentData;
  19342. /**
  19343. * Instantiates a new procedural texture.
  19344. * 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.
  19345. * This is the base class of any Procedural texture and contains most of the shareable code.
  19346. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19347. * @param name Define the name of the texture
  19348. * @param size Define the size of the texture to create
  19349. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19350. * @param scene Define the scene the texture belongs to
  19351. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19352. * @param generateMipMaps Define if the texture should creates mip maps or not
  19353. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19354. */
  19355. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19356. /**
  19357. * The effect that is created when initializing the post process.
  19358. * @returns The created effect corresponding the the postprocess.
  19359. */
  19360. getEffect(): Effect;
  19361. /**
  19362. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19363. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19364. */
  19365. getContent(): Nullable<ArrayBufferView>;
  19366. private _createIndexBuffer;
  19367. /** @hidden */
  19368. _rebuild(): void;
  19369. /**
  19370. * Resets the texture in order to recreate its associated resources.
  19371. * This can be called in case of context loss
  19372. */
  19373. reset(): void;
  19374. protected _getDefines(): string;
  19375. /**
  19376. * Is the texture ready to be used ? (rendered at least once)
  19377. * @returns true if ready, otherwise, false.
  19378. */
  19379. isReady(): boolean;
  19380. /**
  19381. * Resets the refresh counter of the texture and start bak from scratch.
  19382. * Could be useful to regenerate the texture if it is setup to render only once.
  19383. */
  19384. resetRefreshCounter(): void;
  19385. /**
  19386. * Set the fragment shader to use in order to render the texture.
  19387. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19388. */
  19389. setFragment(fragment: any): void;
  19390. /**
  19391. * Define the refresh rate of the texture or the rendering frequency.
  19392. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19393. */
  19394. refreshRate: number;
  19395. /** @hidden */
  19396. _shouldRender(): boolean;
  19397. /**
  19398. * Get the size the texture is rendering at.
  19399. * @returns the size (texture is always squared)
  19400. */
  19401. getRenderSize(): number;
  19402. /**
  19403. * Resize the texture to new value.
  19404. * @param size Define the new size the texture should have
  19405. * @param generateMipMaps Define whether the new texture should create mip maps
  19406. */
  19407. resize(size: number, generateMipMaps: boolean): void;
  19408. private _checkUniform;
  19409. /**
  19410. * Set a texture in the shader program used to render.
  19411. * @param name Define the name of the uniform samplers as defined in the shader
  19412. * @param texture Define the texture to bind to this sampler
  19413. * @return the texture itself allowing "fluent" like uniform updates
  19414. */
  19415. setTexture(name: string, texture: Texture): ProceduralTexture;
  19416. /**
  19417. * Set a float in the shader.
  19418. * @param name Define the name of the uniform as defined in the shader
  19419. * @param value Define the value to give to the uniform
  19420. * @return the texture itself allowing "fluent" like uniform updates
  19421. */
  19422. setFloat(name: string, value: number): ProceduralTexture;
  19423. /**
  19424. * Set a int in the shader.
  19425. * @param name Define the name of the uniform as defined in the shader
  19426. * @param value Define the value to give to the uniform
  19427. * @return the texture itself allowing "fluent" like uniform updates
  19428. */
  19429. setInt(name: string, value: number): ProceduralTexture;
  19430. /**
  19431. * Set an array of floats in the shader.
  19432. * @param name Define the name of the uniform as defined in the shader
  19433. * @param value Define the value to give to the uniform
  19434. * @return the texture itself allowing "fluent" like uniform updates
  19435. */
  19436. setFloats(name: string, value: number[]): ProceduralTexture;
  19437. /**
  19438. * Set a vec3 in the shader from a Color3.
  19439. * @param name Define the name of the uniform as defined in the shader
  19440. * @param value Define the value to give to the uniform
  19441. * @return the texture itself allowing "fluent" like uniform updates
  19442. */
  19443. setColor3(name: string, value: Color3): ProceduralTexture;
  19444. /**
  19445. * Set a vec4 in the shader from a Color4.
  19446. * @param name Define the name of the uniform as defined in the shader
  19447. * @param value Define the value to give to the uniform
  19448. * @return the texture itself allowing "fluent" like uniform updates
  19449. */
  19450. setColor4(name: string, value: Color4): ProceduralTexture;
  19451. /**
  19452. * Set a vec2 in the shader from a Vector2.
  19453. * @param name Define the name of the uniform as defined in the shader
  19454. * @param value Define the value to give to the uniform
  19455. * @return the texture itself allowing "fluent" like uniform updates
  19456. */
  19457. setVector2(name: string, value: Vector2): ProceduralTexture;
  19458. /**
  19459. * Set a vec3 in the shader from a Vector3.
  19460. * @param name Define the name of the uniform as defined in the shader
  19461. * @param value Define the value to give to the uniform
  19462. * @return the texture itself allowing "fluent" like uniform updates
  19463. */
  19464. setVector3(name: string, value: Vector3): ProceduralTexture;
  19465. /**
  19466. * Set a mat4 in the shader from a MAtrix.
  19467. * @param name Define the name of the uniform as defined in the shader
  19468. * @param value Define the value to give to the uniform
  19469. * @return the texture itself allowing "fluent" like uniform updates
  19470. */
  19471. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19472. /**
  19473. * Render the texture to its associated render target.
  19474. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19475. */
  19476. render(useCameraPostProcess?: boolean): void;
  19477. /**
  19478. * Clone the texture.
  19479. * @returns the cloned texture
  19480. */
  19481. clone(): ProceduralTexture;
  19482. /**
  19483. * Dispose the texture and release its asoociated resources.
  19484. */
  19485. dispose(): void;
  19486. }
  19487. }
  19488. declare module "babylonjs/Particles/baseParticleSystem" {
  19489. import { Nullable } from "babylonjs/types";
  19490. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19492. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19493. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19494. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19495. import { Scene } from "babylonjs/scene";
  19496. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19497. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19498. import { Texture } from "babylonjs/Materials/Textures/texture";
  19499. import { Animation } from "babylonjs/Animations/animation";
  19500. /**
  19501. * This represents the base class for particle system in Babylon.
  19502. * 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.
  19503. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19504. * @example https://doc.babylonjs.com/babylon101/particles
  19505. */
  19506. export class BaseParticleSystem {
  19507. /**
  19508. * Source color is added to the destination color without alpha affecting the result
  19509. */
  19510. static BLENDMODE_ONEONE: number;
  19511. /**
  19512. * Blend current color and particle color using particle’s alpha
  19513. */
  19514. static BLENDMODE_STANDARD: number;
  19515. /**
  19516. * Add current color and particle color multiplied by particle’s alpha
  19517. */
  19518. static BLENDMODE_ADD: number;
  19519. /**
  19520. * Multiply current color with particle color
  19521. */
  19522. static BLENDMODE_MULTIPLY: number;
  19523. /**
  19524. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19525. */
  19526. static BLENDMODE_MULTIPLYADD: number;
  19527. /**
  19528. * List of animations used by the particle system.
  19529. */
  19530. animations: Animation[];
  19531. /**
  19532. * The id of the Particle system.
  19533. */
  19534. id: string;
  19535. /**
  19536. * The friendly name of the Particle system.
  19537. */
  19538. name: string;
  19539. /**
  19540. * The rendering group used by the Particle system to chose when to render.
  19541. */
  19542. renderingGroupId: number;
  19543. /**
  19544. * The emitter represents the Mesh or position we are attaching the particle system to.
  19545. */
  19546. emitter: Nullable<AbstractMesh | Vector3>;
  19547. /**
  19548. * The maximum number of particles to emit per frame
  19549. */
  19550. emitRate: number;
  19551. /**
  19552. * If you want to launch only a few particles at once, that can be done, as well.
  19553. */
  19554. manualEmitCount: number;
  19555. /**
  19556. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19557. */
  19558. updateSpeed: number;
  19559. /**
  19560. * The amount of time the particle system is running (depends of the overall update speed).
  19561. */
  19562. targetStopDuration: number;
  19563. /**
  19564. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19565. */
  19566. disposeOnStop: boolean;
  19567. /**
  19568. * Minimum power of emitting particles.
  19569. */
  19570. minEmitPower: number;
  19571. /**
  19572. * Maximum power of emitting particles.
  19573. */
  19574. maxEmitPower: number;
  19575. /**
  19576. * Minimum life time of emitting particles.
  19577. */
  19578. minLifeTime: number;
  19579. /**
  19580. * Maximum life time of emitting particles.
  19581. */
  19582. maxLifeTime: number;
  19583. /**
  19584. * Minimum Size of emitting particles.
  19585. */
  19586. minSize: number;
  19587. /**
  19588. * Maximum Size of emitting particles.
  19589. */
  19590. maxSize: number;
  19591. /**
  19592. * Minimum scale of emitting particles on X axis.
  19593. */
  19594. minScaleX: number;
  19595. /**
  19596. * Maximum scale of emitting particles on X axis.
  19597. */
  19598. maxScaleX: number;
  19599. /**
  19600. * Minimum scale of emitting particles on Y axis.
  19601. */
  19602. minScaleY: number;
  19603. /**
  19604. * Maximum scale of emitting particles on Y axis.
  19605. */
  19606. maxScaleY: number;
  19607. /**
  19608. * Gets or sets the minimal initial rotation in radians.
  19609. */
  19610. minInitialRotation: number;
  19611. /**
  19612. * Gets or sets the maximal initial rotation in radians.
  19613. */
  19614. maxInitialRotation: number;
  19615. /**
  19616. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19617. */
  19618. minAngularSpeed: number;
  19619. /**
  19620. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19621. */
  19622. maxAngularSpeed: number;
  19623. /**
  19624. * The texture used to render each particle. (this can be a spritesheet)
  19625. */
  19626. particleTexture: Nullable<Texture>;
  19627. /**
  19628. * The layer mask we are rendering the particles through.
  19629. */
  19630. layerMask: number;
  19631. /**
  19632. * This can help using your own shader to render the particle system.
  19633. * The according effect will be created
  19634. */
  19635. customShader: any;
  19636. /**
  19637. * By default particle system starts as soon as they are created. This prevents the
  19638. * automatic start to happen and let you decide when to start emitting particles.
  19639. */
  19640. preventAutoStart: boolean;
  19641. private _noiseTexture;
  19642. /**
  19643. * Gets or sets a texture used to add random noise to particle positions
  19644. */
  19645. noiseTexture: Nullable<ProceduralTexture>;
  19646. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19647. noiseStrength: Vector3;
  19648. /**
  19649. * Callback triggered when the particle animation is ending.
  19650. */
  19651. onAnimationEnd: Nullable<() => void>;
  19652. /**
  19653. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19654. */
  19655. blendMode: number;
  19656. /**
  19657. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19658. * to override the particles.
  19659. */
  19660. forceDepthWrite: boolean;
  19661. /** 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 */
  19662. preWarmCycles: number;
  19663. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19664. preWarmStepOffset: number;
  19665. /**
  19666. * 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)
  19667. */
  19668. spriteCellChangeSpeed: number;
  19669. /**
  19670. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19671. */
  19672. startSpriteCellID: number;
  19673. /**
  19674. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19675. */
  19676. endSpriteCellID: number;
  19677. /**
  19678. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19679. */
  19680. spriteCellWidth: number;
  19681. /**
  19682. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19683. */
  19684. spriteCellHeight: number;
  19685. /**
  19686. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19687. */
  19688. spriteRandomStartCell: boolean;
  19689. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19690. translationPivot: Vector2;
  19691. /** @hidden */
  19692. protected _isAnimationSheetEnabled: boolean;
  19693. /**
  19694. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19695. */
  19696. beginAnimationOnStart: boolean;
  19697. /**
  19698. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19699. */
  19700. beginAnimationFrom: number;
  19701. /**
  19702. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19703. */
  19704. beginAnimationTo: number;
  19705. /**
  19706. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19707. */
  19708. beginAnimationLoop: boolean;
  19709. /**
  19710. * Gets or sets a world offset applied to all particles
  19711. */
  19712. worldOffset: Vector3;
  19713. /**
  19714. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19715. */
  19716. isAnimationSheetEnabled: boolean;
  19717. /**
  19718. * Get hosting scene
  19719. * @returns the scene
  19720. */
  19721. getScene(): Scene;
  19722. /**
  19723. * You can use gravity if you want to give an orientation to your particles.
  19724. */
  19725. gravity: Vector3;
  19726. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19727. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19728. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19729. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19730. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19731. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19732. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19733. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19734. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19735. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19736. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19737. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19738. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19739. /**
  19740. * Defines the delay in milliseconds before starting the system (0 by default)
  19741. */
  19742. startDelay: number;
  19743. /**
  19744. * Gets the current list of drag gradients.
  19745. * You must use addDragGradient and removeDragGradient to udpate this list
  19746. * @returns the list of drag gradients
  19747. */
  19748. getDragGradients(): Nullable<Array<FactorGradient>>;
  19749. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19750. limitVelocityDamping: number;
  19751. /**
  19752. * Gets the current list of limit velocity gradients.
  19753. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19754. * @returns the list of limit velocity gradients
  19755. */
  19756. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19757. /**
  19758. * Gets the current list of color gradients.
  19759. * You must use addColorGradient and removeColorGradient to udpate this list
  19760. * @returns the list of color gradients
  19761. */
  19762. getColorGradients(): Nullable<Array<ColorGradient>>;
  19763. /**
  19764. * Gets the current list of size gradients.
  19765. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19766. * @returns the list of size gradients
  19767. */
  19768. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19769. /**
  19770. * Gets the current list of color remap gradients.
  19771. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19772. * @returns the list of color remap gradients
  19773. */
  19774. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19775. /**
  19776. * Gets the current list of alpha remap gradients.
  19777. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19778. * @returns the list of alpha remap gradients
  19779. */
  19780. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19781. /**
  19782. * Gets the current list of life time gradients.
  19783. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19784. * @returns the list of life time gradients
  19785. */
  19786. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19787. /**
  19788. * Gets the current list of angular speed gradients.
  19789. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19790. * @returns the list of angular speed gradients
  19791. */
  19792. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19793. /**
  19794. * Gets the current list of velocity gradients.
  19795. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19796. * @returns the list of velocity gradients
  19797. */
  19798. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19799. /**
  19800. * Gets the current list of start size gradients.
  19801. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19802. * @returns the list of start size gradients
  19803. */
  19804. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19805. /**
  19806. * Gets the current list of emit rate gradients.
  19807. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19808. * @returns the list of emit rate gradients
  19809. */
  19810. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19811. /**
  19812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19813. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19814. */
  19815. direction1: Vector3;
  19816. /**
  19817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19818. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19819. */
  19820. direction2: Vector3;
  19821. /**
  19822. * 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.
  19823. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19824. */
  19825. minEmitBox: Vector3;
  19826. /**
  19827. * 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.
  19828. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19829. */
  19830. maxEmitBox: Vector3;
  19831. /**
  19832. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19833. */
  19834. color1: Color4;
  19835. /**
  19836. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19837. */
  19838. color2: Color4;
  19839. /**
  19840. * Color the particle will have at the end of its lifetime
  19841. */
  19842. colorDead: Color4;
  19843. /**
  19844. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19845. */
  19846. textureMask: Color4;
  19847. /**
  19848. * The particle emitter type defines the emitter used by the particle system.
  19849. * It can be for example box, sphere, or cone...
  19850. */
  19851. particleEmitterType: IParticleEmitterType;
  19852. /** @hidden */
  19853. _isSubEmitter: boolean;
  19854. /**
  19855. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19856. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19857. */
  19858. billboardMode: number;
  19859. protected _isBillboardBased: boolean;
  19860. /**
  19861. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19862. */
  19863. isBillboardBased: boolean;
  19864. /**
  19865. * The scene the particle system belongs to.
  19866. */
  19867. protected _scene: Scene;
  19868. /**
  19869. * Local cache of defines for image processing.
  19870. */
  19871. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19872. /**
  19873. * Default configuration related to image processing available in the standard Material.
  19874. */
  19875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19876. /**
  19877. * Gets the image processing configuration used either in this material.
  19878. */
  19879. /**
  19880. * Sets the Default image processing configuration used either in the this material.
  19881. *
  19882. * If sets to null, the scene one is in use.
  19883. */
  19884. imageProcessingConfiguration: ImageProcessingConfiguration;
  19885. /**
  19886. * Attaches a new image processing configuration to the Standard Material.
  19887. * @param configuration
  19888. */
  19889. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19890. /** @hidden */
  19891. protected _reset(): void;
  19892. /** @hidden */
  19893. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19894. /**
  19895. * Instantiates a particle system.
  19896. * 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.
  19897. * @param name The name of the particle system
  19898. */
  19899. constructor(name: string);
  19900. /**
  19901. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19902. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19903. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19904. * @returns the emitter
  19905. */
  19906. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19907. /**
  19908. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19909. * @param radius The radius of the hemisphere to emit from
  19910. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19911. * @returns the emitter
  19912. */
  19913. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19914. /**
  19915. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19916. * @param radius The radius of the sphere to emit from
  19917. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19918. * @returns the emitter
  19919. */
  19920. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19921. /**
  19922. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19923. * @param radius The radius of the sphere to emit from
  19924. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19925. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19926. * @returns the emitter
  19927. */
  19928. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19929. /**
  19930. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19931. * @param radius The radius of the emission cylinder
  19932. * @param height The height of the emission cylinder
  19933. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19934. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19935. * @returns the emitter
  19936. */
  19937. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19938. /**
  19939. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19940. * @param radius The radius of the cylinder to emit from
  19941. * @param height The height of the emission cylinder
  19942. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19943. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19944. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19945. * @returns the emitter
  19946. */
  19947. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19948. /**
  19949. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19950. * @param radius The radius of the cone to emit from
  19951. * @param angle The base angle of the cone
  19952. * @returns the emitter
  19953. */
  19954. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19955. /**
  19956. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19959. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19960. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19961. * @returns the emitter
  19962. */
  19963. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19964. }
  19965. }
  19966. declare module "babylonjs/Particles/subEmitter" {
  19967. import { Scene } from "babylonjs/scene";
  19968. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19969. /**
  19970. * Type of sub emitter
  19971. */
  19972. export enum SubEmitterType {
  19973. /**
  19974. * Attached to the particle over it's lifetime
  19975. */
  19976. ATTACHED = 0,
  19977. /**
  19978. * Created when the particle dies
  19979. */
  19980. END = 1
  19981. }
  19982. /**
  19983. * Sub emitter class used to emit particles from an existing particle
  19984. */
  19985. export class SubEmitter {
  19986. /**
  19987. * the particle system to be used by the sub emitter
  19988. */
  19989. particleSystem: ParticleSystem;
  19990. /**
  19991. * Type of the submitter (Default: END)
  19992. */
  19993. type: SubEmitterType;
  19994. /**
  19995. * 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)
  19996. * Note: This only is supported when using an emitter of type Mesh
  19997. */
  19998. inheritDirection: boolean;
  19999. /**
  20000. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20001. */
  20002. inheritedVelocityAmount: number;
  20003. /**
  20004. * Creates a sub emitter
  20005. * @param particleSystem the particle system to be used by the sub emitter
  20006. */
  20007. constructor(
  20008. /**
  20009. * the particle system to be used by the sub emitter
  20010. */
  20011. particleSystem: ParticleSystem);
  20012. /**
  20013. * Clones the sub emitter
  20014. * @returns the cloned sub emitter
  20015. */
  20016. clone(): SubEmitter;
  20017. /**
  20018. * Serialize current object to a JSON object
  20019. * @returns the serialized object
  20020. */
  20021. serialize(): any;
  20022. /** @hidden */
  20023. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20024. /**
  20025. * Creates a new SubEmitter from a serialized JSON version
  20026. * @param serializationObject defines the JSON object to read from
  20027. * @param scene defines the hosting scene
  20028. * @param rootUrl defines the rootUrl for data loading
  20029. * @returns a new SubEmitter
  20030. */
  20031. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20032. /** Release associated resources */
  20033. dispose(): void;
  20034. }
  20035. }
  20036. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20037. /** @hidden */
  20038. export var imageProcessingDeclaration: {
  20039. name: string;
  20040. shader: string;
  20041. };
  20042. }
  20043. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20044. /** @hidden */
  20045. export var imageProcessingFunctions: {
  20046. name: string;
  20047. shader: string;
  20048. };
  20049. }
  20050. declare module "babylonjs/Shaders/particles.fragment" {
  20051. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20054. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20055. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20056. /** @hidden */
  20057. export var particlesPixelShader: {
  20058. name: string;
  20059. shader: string;
  20060. };
  20061. }
  20062. declare module "babylonjs/Shaders/particles.vertex" {
  20063. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20065. /** @hidden */
  20066. export var particlesVertexShader: {
  20067. name: string;
  20068. shader: string;
  20069. };
  20070. }
  20071. declare module "babylonjs/Particles/particleSystem" {
  20072. import { Nullable } from "babylonjs/types";
  20073. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20074. import { Observable } from "babylonjs/Misc/observable";
  20075. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20076. import { Effect } from "babylonjs/Materials/effect";
  20077. import { Scene, IDisposable } from "babylonjs/scene";
  20078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20079. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20080. import { Particle } from "babylonjs/Particles/particle";
  20081. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20082. import "babylonjs/Shaders/particles.fragment";
  20083. import "babylonjs/Shaders/particles.vertex";
  20084. /**
  20085. * This represents a particle system in Babylon.
  20086. * 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.
  20087. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20088. * @example https://doc.babylonjs.com/babylon101/particles
  20089. */
  20090. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20091. /**
  20092. * Billboard mode will only apply to Y axis
  20093. */
  20094. static readonly BILLBOARDMODE_Y: number;
  20095. /**
  20096. * Billboard mode will apply to all axes
  20097. */
  20098. static readonly BILLBOARDMODE_ALL: number;
  20099. /**
  20100. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20101. */
  20102. static readonly BILLBOARDMODE_STRETCHED: number;
  20103. /**
  20104. * This function can be defined to provide custom update for active particles.
  20105. * This function will be called instead of regular update (age, position, color, etc.).
  20106. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20107. */
  20108. updateFunction: (particles: Particle[]) => void;
  20109. private _emitterWorldMatrix;
  20110. /**
  20111. * This function can be defined to specify initial direction for every new particle.
  20112. * It by default use the emitterType defined function
  20113. */
  20114. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20115. /**
  20116. * This function can be defined to specify initial position for every new particle.
  20117. * It by default use the emitterType defined function
  20118. */
  20119. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20120. /**
  20121. * @hidden
  20122. */
  20123. _inheritedVelocityOffset: Vector3;
  20124. /**
  20125. * An event triggered when the system is disposed
  20126. */
  20127. onDisposeObservable: Observable<ParticleSystem>;
  20128. private _onDisposeObserver;
  20129. /**
  20130. * Sets a callback that will be triggered when the system is disposed
  20131. */
  20132. onDispose: () => void;
  20133. private _particles;
  20134. private _epsilon;
  20135. private _capacity;
  20136. private _stockParticles;
  20137. private _newPartsExcess;
  20138. private _vertexData;
  20139. private _vertexBuffer;
  20140. private _vertexBuffers;
  20141. private _spriteBuffer;
  20142. private _indexBuffer;
  20143. private _effect;
  20144. private _customEffect;
  20145. private _cachedDefines;
  20146. private _scaledColorStep;
  20147. private _colorDiff;
  20148. private _scaledDirection;
  20149. private _scaledGravity;
  20150. private _currentRenderId;
  20151. private _alive;
  20152. private _useInstancing;
  20153. private _started;
  20154. private _stopped;
  20155. private _actualFrame;
  20156. private _scaledUpdateSpeed;
  20157. private _vertexBufferSize;
  20158. /** @hidden */
  20159. _currentEmitRateGradient: Nullable<FactorGradient>;
  20160. /** @hidden */
  20161. _currentEmitRate1: number;
  20162. /** @hidden */
  20163. _currentEmitRate2: number;
  20164. /** @hidden */
  20165. _currentStartSizeGradient: Nullable<FactorGradient>;
  20166. /** @hidden */
  20167. _currentStartSize1: number;
  20168. /** @hidden */
  20169. _currentStartSize2: number;
  20170. private readonly _rawTextureWidth;
  20171. private _rampGradientsTexture;
  20172. private _useRampGradients;
  20173. /** Gets or sets a boolean indicating that ramp gradients must be used
  20174. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20175. */
  20176. useRampGradients: boolean;
  20177. /**
  20178. * 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.
  20179. * 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: [])
  20180. */
  20181. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20182. private _subEmitters;
  20183. /**
  20184. * @hidden
  20185. * If the particle systems emitter should be disposed when the particle system is disposed
  20186. */
  20187. _disposeEmitterOnDispose: boolean;
  20188. /**
  20189. * The current active Sub-systems, this property is used by the root particle system only.
  20190. */
  20191. activeSubSystems: Array<ParticleSystem>;
  20192. private _rootParticleSystem;
  20193. /**
  20194. * Gets the current list of active particles
  20195. */
  20196. readonly particles: Particle[];
  20197. /**
  20198. * Returns the string "ParticleSystem"
  20199. * @returns a string containing the class name
  20200. */
  20201. getClassName(): string;
  20202. /**
  20203. * Instantiates a particle system.
  20204. * 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.
  20205. * @param name The name of the particle system
  20206. * @param capacity The max number of particles alive at the same time
  20207. * @param scene The scene the particle system belongs to
  20208. * @param customEffect a custom effect used to change the way particles are rendered by default
  20209. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20210. * @param epsilon Offset used to render the particles
  20211. */
  20212. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20213. private _addFactorGradient;
  20214. private _removeFactorGradient;
  20215. /**
  20216. * Adds a new life time gradient
  20217. * @param gradient defines the gradient to use (between 0 and 1)
  20218. * @param factor defines the life time factor to affect to the specified gradient
  20219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20220. * @returns the current particle system
  20221. */
  20222. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20223. /**
  20224. * Remove a specific life time gradient
  20225. * @param gradient defines the gradient to remove
  20226. * @returns the current particle system
  20227. */
  20228. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20229. /**
  20230. * Adds a new size gradient
  20231. * @param gradient defines the gradient to use (between 0 and 1)
  20232. * @param factor defines the size factor to affect to the specified gradient
  20233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20234. * @returns the current particle system
  20235. */
  20236. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20237. /**
  20238. * Remove a specific size gradient
  20239. * @param gradient defines the gradient to remove
  20240. * @returns the current particle system
  20241. */
  20242. removeSizeGradient(gradient: number): IParticleSystem;
  20243. /**
  20244. * Adds a new color remap gradient
  20245. * @param gradient defines the gradient to use (between 0 and 1)
  20246. * @param min defines the color remap minimal range
  20247. * @param max defines the color remap maximal range
  20248. * @returns the current particle system
  20249. */
  20250. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20251. /**
  20252. * Remove a specific color remap gradient
  20253. * @param gradient defines the gradient to remove
  20254. * @returns the current particle system
  20255. */
  20256. removeColorRemapGradient(gradient: number): IParticleSystem;
  20257. /**
  20258. * Adds a new alpha remap gradient
  20259. * @param gradient defines the gradient to use (between 0 and 1)
  20260. * @param min defines the alpha remap minimal range
  20261. * @param max defines the alpha remap maximal range
  20262. * @returns the current particle system
  20263. */
  20264. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20265. /**
  20266. * Remove a specific alpha remap gradient
  20267. * @param gradient defines the gradient to remove
  20268. * @returns the current particle system
  20269. */
  20270. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20271. /**
  20272. * Adds a new angular speed gradient
  20273. * @param gradient defines the gradient to use (between 0 and 1)
  20274. * @param factor defines the angular speed to affect to the specified gradient
  20275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20276. * @returns the current particle system
  20277. */
  20278. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20279. /**
  20280. * Remove a specific angular speed gradient
  20281. * @param gradient defines the gradient to remove
  20282. * @returns the current particle system
  20283. */
  20284. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20285. /**
  20286. * Adds a new velocity gradient
  20287. * @param gradient defines the gradient to use (between 0 and 1)
  20288. * @param factor defines the velocity to affect to the specified gradient
  20289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20290. * @returns the current particle system
  20291. */
  20292. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20293. /**
  20294. * Remove a specific velocity gradient
  20295. * @param gradient defines the gradient to remove
  20296. * @returns the current particle system
  20297. */
  20298. removeVelocityGradient(gradient: number): IParticleSystem;
  20299. /**
  20300. * Adds a new limit velocity gradient
  20301. * @param gradient defines the gradient to use (between 0 and 1)
  20302. * @param factor defines the limit velocity value to affect to the specified gradient
  20303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20304. * @returns the current particle system
  20305. */
  20306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20307. /**
  20308. * Remove a specific limit velocity gradient
  20309. * @param gradient defines the gradient to remove
  20310. * @returns the current particle system
  20311. */
  20312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20313. /**
  20314. * Adds a new drag gradient
  20315. * @param gradient defines the gradient to use (between 0 and 1)
  20316. * @param factor defines the drag value to affect to the specified gradient
  20317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20318. * @returns the current particle system
  20319. */
  20320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20321. /**
  20322. * Remove a specific drag gradient
  20323. * @param gradient defines the gradient to remove
  20324. * @returns the current particle system
  20325. */
  20326. removeDragGradient(gradient: number): IParticleSystem;
  20327. /**
  20328. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20329. * @param gradient defines the gradient to use (between 0 and 1)
  20330. * @param factor defines the emit rate value to affect to the specified gradient
  20331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20332. * @returns the current particle system
  20333. */
  20334. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20335. /**
  20336. * Remove a specific emit rate gradient
  20337. * @param gradient defines the gradient to remove
  20338. * @returns the current particle system
  20339. */
  20340. removeEmitRateGradient(gradient: number): IParticleSystem;
  20341. /**
  20342. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20343. * @param gradient defines the gradient to use (between 0 and 1)
  20344. * @param factor defines the start size value to affect to the specified gradient
  20345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20346. * @returns the current particle system
  20347. */
  20348. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20349. /**
  20350. * Remove a specific start size gradient
  20351. * @param gradient defines the gradient to remove
  20352. * @returns the current particle system
  20353. */
  20354. removeStartSizeGradient(gradient: number): IParticleSystem;
  20355. private _createRampGradientTexture;
  20356. /**
  20357. * Gets the current list of ramp gradients.
  20358. * You must use addRampGradient and removeRampGradient to udpate this list
  20359. * @returns the list of ramp gradients
  20360. */
  20361. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20362. /**
  20363. * Adds a new ramp gradient used to remap particle colors
  20364. * @param gradient defines the gradient to use (between 0 and 1)
  20365. * @param color defines the color to affect to the specified gradient
  20366. * @returns the current particle system
  20367. */
  20368. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20369. /**
  20370. * Remove a specific ramp gradient
  20371. * @param gradient defines the gradient to remove
  20372. * @returns the current particle system
  20373. */
  20374. removeRampGradient(gradient: number): ParticleSystem;
  20375. /**
  20376. * Adds a new color gradient
  20377. * @param gradient defines the gradient to use (between 0 and 1)
  20378. * @param color1 defines the color to affect to the specified gradient
  20379. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20380. * @returns this particle system
  20381. */
  20382. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20383. /**
  20384. * Remove a specific color gradient
  20385. * @param gradient defines the gradient to remove
  20386. * @returns this particle system
  20387. */
  20388. removeColorGradient(gradient: number): IParticleSystem;
  20389. private _fetchR;
  20390. protected _reset(): void;
  20391. private _resetEffect;
  20392. private _createVertexBuffers;
  20393. private _createIndexBuffer;
  20394. /**
  20395. * Gets the maximum number of particles active at the same time.
  20396. * @returns The max number of active particles.
  20397. */
  20398. getCapacity(): number;
  20399. /**
  20400. * Gets whether there are still active particles in the system.
  20401. * @returns True if it is alive, otherwise false.
  20402. */
  20403. isAlive(): boolean;
  20404. /**
  20405. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20406. * @returns True if it has been started, otherwise false.
  20407. */
  20408. isStarted(): boolean;
  20409. private _prepareSubEmitterInternalArray;
  20410. /**
  20411. * Starts the particle system and begins to emit
  20412. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20413. */
  20414. start(delay?: number): void;
  20415. /**
  20416. * Stops the particle system.
  20417. * @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.
  20418. */
  20419. stop(stopSubEmitters?: boolean): void;
  20420. /**
  20421. * Remove all active particles
  20422. */
  20423. reset(): void;
  20424. /**
  20425. * @hidden (for internal use only)
  20426. */
  20427. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20428. /**
  20429. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20430. * Its lifetime will start back at 0.
  20431. */
  20432. recycleParticle: (particle: Particle) => void;
  20433. private _stopSubEmitters;
  20434. private _createParticle;
  20435. private _removeFromRoot;
  20436. private _emitFromParticle;
  20437. private _update;
  20438. /** @hidden */
  20439. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20440. /** @hidden */
  20441. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20442. /** @hidden */
  20443. private _getEffect;
  20444. /**
  20445. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20446. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20447. */
  20448. animate(preWarmOnly?: boolean): void;
  20449. private _appendParticleVertices;
  20450. /**
  20451. * Rebuilds the particle system.
  20452. */
  20453. rebuild(): void;
  20454. /**
  20455. * Is this system ready to be used/rendered
  20456. * @return true if the system is ready
  20457. */
  20458. isReady(): boolean;
  20459. private _render;
  20460. /**
  20461. * Renders the particle system in its current state.
  20462. * @returns the current number of particles
  20463. */
  20464. render(): number;
  20465. /**
  20466. * Disposes the particle system and free the associated resources
  20467. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20468. */
  20469. dispose(disposeTexture?: boolean): void;
  20470. /**
  20471. * Clones the particle system.
  20472. * @param name The name of the cloned object
  20473. * @param newEmitter The new emitter to use
  20474. * @returns the cloned particle system
  20475. */
  20476. clone(name: string, newEmitter: any): ParticleSystem;
  20477. /**
  20478. * Serializes the particle system to a JSON object.
  20479. * @returns the JSON object
  20480. */
  20481. serialize(): any;
  20482. /** @hidden */
  20483. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20484. /** @hidden */
  20485. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20486. /**
  20487. * Parses a JSON object to create a particle system.
  20488. * @param parsedParticleSystem The JSON object to parse
  20489. * @param scene The scene to create the particle system in
  20490. * @param rootUrl The root url to use to load external dependencies like texture
  20491. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20492. * @returns the Parsed particle system
  20493. */
  20494. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20495. }
  20496. }
  20497. declare module "babylonjs/Particles/particle" {
  20498. import { Nullable } from "babylonjs/types";
  20499. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20500. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20501. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20502. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20503. /**
  20504. * A particle represents one of the element emitted by a particle system.
  20505. * This is mainly define by its coordinates, direction, velocity and age.
  20506. */
  20507. export class Particle {
  20508. /**
  20509. * The particle system the particle belongs to.
  20510. */
  20511. particleSystem: ParticleSystem;
  20512. private static _Count;
  20513. /**
  20514. * Unique ID of the particle
  20515. */
  20516. id: number;
  20517. /**
  20518. * The world position of the particle in the scene.
  20519. */
  20520. position: Vector3;
  20521. /**
  20522. * The world direction of the particle in the scene.
  20523. */
  20524. direction: Vector3;
  20525. /**
  20526. * The color of the particle.
  20527. */
  20528. color: Color4;
  20529. /**
  20530. * The color change of the particle per step.
  20531. */
  20532. colorStep: Color4;
  20533. /**
  20534. * Defines how long will the life of the particle be.
  20535. */
  20536. lifeTime: number;
  20537. /**
  20538. * The current age of the particle.
  20539. */
  20540. age: number;
  20541. /**
  20542. * The current size of the particle.
  20543. */
  20544. size: number;
  20545. /**
  20546. * The current scale of the particle.
  20547. */
  20548. scale: Vector2;
  20549. /**
  20550. * The current angle of the particle.
  20551. */
  20552. angle: number;
  20553. /**
  20554. * Defines how fast is the angle changing.
  20555. */
  20556. angularSpeed: number;
  20557. /**
  20558. * Defines the cell index used by the particle to be rendered from a sprite.
  20559. */
  20560. cellIndex: number;
  20561. /**
  20562. * The information required to support color remapping
  20563. */
  20564. remapData: Vector4;
  20565. /** @hidden */
  20566. _randomCellOffset?: number;
  20567. /** @hidden */
  20568. _initialDirection: Nullable<Vector3>;
  20569. /** @hidden */
  20570. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20571. /** @hidden */
  20572. _initialStartSpriteCellID: number;
  20573. /** @hidden */
  20574. _initialEndSpriteCellID: number;
  20575. /** @hidden */
  20576. _currentColorGradient: Nullable<ColorGradient>;
  20577. /** @hidden */
  20578. _currentColor1: Color4;
  20579. /** @hidden */
  20580. _currentColor2: Color4;
  20581. /** @hidden */
  20582. _currentSizeGradient: Nullable<FactorGradient>;
  20583. /** @hidden */
  20584. _currentSize1: number;
  20585. /** @hidden */
  20586. _currentSize2: number;
  20587. /** @hidden */
  20588. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20589. /** @hidden */
  20590. _currentAngularSpeed1: number;
  20591. /** @hidden */
  20592. _currentAngularSpeed2: number;
  20593. /** @hidden */
  20594. _currentVelocityGradient: Nullable<FactorGradient>;
  20595. /** @hidden */
  20596. _currentVelocity1: number;
  20597. /** @hidden */
  20598. _currentVelocity2: number;
  20599. /** @hidden */
  20600. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20601. /** @hidden */
  20602. _currentLimitVelocity1: number;
  20603. /** @hidden */
  20604. _currentLimitVelocity2: number;
  20605. /** @hidden */
  20606. _currentDragGradient: Nullable<FactorGradient>;
  20607. /** @hidden */
  20608. _currentDrag1: number;
  20609. /** @hidden */
  20610. _currentDrag2: number;
  20611. /** @hidden */
  20612. _randomNoiseCoordinates1: Vector3;
  20613. /** @hidden */
  20614. _randomNoiseCoordinates2: Vector3;
  20615. /**
  20616. * Creates a new instance Particle
  20617. * @param particleSystem the particle system the particle belongs to
  20618. */
  20619. constructor(
  20620. /**
  20621. * The particle system the particle belongs to.
  20622. */
  20623. particleSystem: ParticleSystem);
  20624. private updateCellInfoFromSystem;
  20625. /**
  20626. * Defines how the sprite cell index is updated for the particle
  20627. */
  20628. updateCellIndex(): void;
  20629. /** @hidden */
  20630. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20631. /** @hidden */
  20632. _inheritParticleInfoToSubEmitters(): void;
  20633. /** @hidden */
  20634. _reset(): void;
  20635. /**
  20636. * Copy the properties of particle to another one.
  20637. * @param other the particle to copy the information to.
  20638. */
  20639. copyTo(other: Particle): void;
  20640. }
  20641. }
  20642. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20643. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20644. import { Effect } from "babylonjs/Materials/effect";
  20645. import { Particle } from "babylonjs/Particles/particle";
  20646. /**
  20647. * Particle emitter represents a volume emitting particles.
  20648. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20649. */
  20650. export interface IParticleEmitterType {
  20651. /**
  20652. * Called by the particle System when the direction is computed for the created particle.
  20653. * @param worldMatrix is the world matrix of the particle system
  20654. * @param directionToUpdate is the direction vector to update with the result
  20655. * @param particle is the particle we are computed the direction for
  20656. */
  20657. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20658. /**
  20659. * Called by the particle System when the position is computed for the created particle.
  20660. * @param worldMatrix is the world matrix of the particle system
  20661. * @param positionToUpdate is the position vector to update with the result
  20662. * @param particle is the particle we are computed the position for
  20663. */
  20664. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20665. /**
  20666. * Clones the current emitter and returns a copy of it
  20667. * @returns the new emitter
  20668. */
  20669. clone(): IParticleEmitterType;
  20670. /**
  20671. * Called by the GPUParticleSystem to setup the update shader
  20672. * @param effect defines the update shader
  20673. */
  20674. applyToShader(effect: Effect): void;
  20675. /**
  20676. * Returns a string to use to update the GPU particles update shader
  20677. * @returns the effect defines string
  20678. */
  20679. getEffectDefines(): string;
  20680. /**
  20681. * Returns a string representing the class name
  20682. * @returns a string containing the class name
  20683. */
  20684. getClassName(): string;
  20685. /**
  20686. * Serializes the particle system to a JSON object.
  20687. * @returns the JSON object
  20688. */
  20689. serialize(): any;
  20690. /**
  20691. * Parse properties from a JSON object
  20692. * @param serializationObject defines the JSON object
  20693. */
  20694. parse(serializationObject: any): void;
  20695. }
  20696. }
  20697. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20698. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20699. import { Effect } from "babylonjs/Materials/effect";
  20700. import { Particle } from "babylonjs/Particles/particle";
  20701. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20702. /**
  20703. * Particle emitter emitting particles from the inside of a box.
  20704. * It emits the particles randomly between 2 given directions.
  20705. */
  20706. export class BoxParticleEmitter implements IParticleEmitterType {
  20707. /**
  20708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20709. */
  20710. direction1: Vector3;
  20711. /**
  20712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20713. */
  20714. direction2: Vector3;
  20715. /**
  20716. * 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.
  20717. */
  20718. minEmitBox: Vector3;
  20719. /**
  20720. * 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.
  20721. */
  20722. maxEmitBox: Vector3;
  20723. /**
  20724. * Creates a new instance BoxParticleEmitter
  20725. */
  20726. constructor();
  20727. /**
  20728. * Called by the particle System when the direction is computed for the created particle.
  20729. * @param worldMatrix is the world matrix of the particle system
  20730. * @param directionToUpdate is the direction vector to update with the result
  20731. * @param particle is the particle we are computed the direction for
  20732. */
  20733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20734. /**
  20735. * Called by the particle System when the position is computed for the created particle.
  20736. * @param worldMatrix is the world matrix of the particle system
  20737. * @param positionToUpdate is the position vector to update with the result
  20738. * @param particle is the particle we are computed the position for
  20739. */
  20740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20741. /**
  20742. * Clones the current emitter and returns a copy of it
  20743. * @returns the new emitter
  20744. */
  20745. clone(): BoxParticleEmitter;
  20746. /**
  20747. * Called by the GPUParticleSystem to setup the update shader
  20748. * @param effect defines the update shader
  20749. */
  20750. applyToShader(effect: Effect): void;
  20751. /**
  20752. * Returns a string to use to update the GPU particles update shader
  20753. * @returns a string containng the defines string
  20754. */
  20755. getEffectDefines(): string;
  20756. /**
  20757. * Returns the string "BoxParticleEmitter"
  20758. * @returns a string containing the class name
  20759. */
  20760. getClassName(): string;
  20761. /**
  20762. * Serializes the particle system to a JSON object.
  20763. * @returns the JSON object
  20764. */
  20765. serialize(): any;
  20766. /**
  20767. * Parse properties from a JSON object
  20768. * @param serializationObject defines the JSON object
  20769. */
  20770. parse(serializationObject: any): void;
  20771. }
  20772. }
  20773. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20774. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20775. import { Effect } from "babylonjs/Materials/effect";
  20776. import { Particle } from "babylonjs/Particles/particle";
  20777. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20778. /**
  20779. * Particle emitter emitting particles from the inside of a cone.
  20780. * It emits the particles alongside the cone volume from the base to the particle.
  20781. * The emission direction might be randomized.
  20782. */
  20783. export class ConeParticleEmitter implements IParticleEmitterType {
  20784. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20785. directionRandomizer: number;
  20786. private _radius;
  20787. private _angle;
  20788. private _height;
  20789. /**
  20790. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20791. */
  20792. radiusRange: number;
  20793. /**
  20794. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20795. */
  20796. heightRange: number;
  20797. /**
  20798. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20799. */
  20800. emitFromSpawnPointOnly: boolean;
  20801. /**
  20802. * Gets or sets the radius of the emission cone
  20803. */
  20804. radius: number;
  20805. /**
  20806. * Gets or sets the angle of the emission cone
  20807. */
  20808. angle: number;
  20809. private _buildHeight;
  20810. /**
  20811. * Creates a new instance ConeParticleEmitter
  20812. * @param radius the radius of the emission cone (1 by default)
  20813. * @param angle the cone base angle (PI by default)
  20814. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20815. */
  20816. constructor(radius?: number, angle?: number,
  20817. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20818. directionRandomizer?: number);
  20819. /**
  20820. * Called by the particle System when the direction is computed for the created particle.
  20821. * @param worldMatrix is the world matrix of the particle system
  20822. * @param directionToUpdate is the direction vector to update with the result
  20823. * @param particle is the particle we are computed the direction for
  20824. */
  20825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20826. /**
  20827. * Called by the particle System when the position is computed for the created particle.
  20828. * @param worldMatrix is the world matrix of the particle system
  20829. * @param positionToUpdate is the position vector to update with the result
  20830. * @param particle is the particle we are computed the position for
  20831. */
  20832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20833. /**
  20834. * Clones the current emitter and returns a copy of it
  20835. * @returns the new emitter
  20836. */
  20837. clone(): ConeParticleEmitter;
  20838. /**
  20839. * Called by the GPUParticleSystem to setup the update shader
  20840. * @param effect defines the update shader
  20841. */
  20842. applyToShader(effect: Effect): void;
  20843. /**
  20844. * Returns a string to use to update the GPU particles update shader
  20845. * @returns a string containng the defines string
  20846. */
  20847. getEffectDefines(): string;
  20848. /**
  20849. * Returns the string "ConeParticleEmitter"
  20850. * @returns a string containing the class name
  20851. */
  20852. getClassName(): string;
  20853. /**
  20854. * Serializes the particle system to a JSON object.
  20855. * @returns the JSON object
  20856. */
  20857. serialize(): any;
  20858. /**
  20859. * Parse properties from a JSON object
  20860. * @param serializationObject defines the JSON object
  20861. */
  20862. parse(serializationObject: any): void;
  20863. }
  20864. }
  20865. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20866. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20867. import { Effect } from "babylonjs/Materials/effect";
  20868. import { Particle } from "babylonjs/Particles/particle";
  20869. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20870. /**
  20871. * Particle emitter emitting particles from the inside of a cylinder.
  20872. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20873. */
  20874. export class CylinderParticleEmitter implements IParticleEmitterType {
  20875. /**
  20876. * The radius of the emission cylinder.
  20877. */
  20878. radius: number;
  20879. /**
  20880. * The height of the emission cylinder.
  20881. */
  20882. height: number;
  20883. /**
  20884. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20885. */
  20886. radiusRange: number;
  20887. /**
  20888. * How much to randomize the particle direction [0-1].
  20889. */
  20890. directionRandomizer: number;
  20891. /**
  20892. * Creates a new instance CylinderParticleEmitter
  20893. * @param radius the radius of the emission cylinder (1 by default)
  20894. * @param height the height of the emission cylinder (1 by default)
  20895. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20897. */
  20898. constructor(
  20899. /**
  20900. * The radius of the emission cylinder.
  20901. */
  20902. radius?: number,
  20903. /**
  20904. * The height of the emission cylinder.
  20905. */
  20906. height?: number,
  20907. /**
  20908. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20909. */
  20910. radiusRange?: number,
  20911. /**
  20912. * How much to randomize the particle direction [0-1].
  20913. */
  20914. directionRandomizer?: number);
  20915. /**
  20916. * Called by the particle System when the direction is computed for the created particle.
  20917. * @param worldMatrix is the world matrix of the particle system
  20918. * @param directionToUpdate is the direction vector to update with the result
  20919. * @param particle is the particle we are computed the direction for
  20920. */
  20921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20922. /**
  20923. * Called by the particle System when the position is computed for the created particle.
  20924. * @param worldMatrix is the world matrix of the particle system
  20925. * @param positionToUpdate is the position vector to update with the result
  20926. * @param particle is the particle we are computed the position for
  20927. */
  20928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20929. /**
  20930. * Clones the current emitter and returns a copy of it
  20931. * @returns the new emitter
  20932. */
  20933. clone(): CylinderParticleEmitter;
  20934. /**
  20935. * Called by the GPUParticleSystem to setup the update shader
  20936. * @param effect defines the update shader
  20937. */
  20938. applyToShader(effect: Effect): void;
  20939. /**
  20940. * Returns a string to use to update the GPU particles update shader
  20941. * @returns a string containng the defines string
  20942. */
  20943. getEffectDefines(): string;
  20944. /**
  20945. * Returns the string "CylinderParticleEmitter"
  20946. * @returns a string containing the class name
  20947. */
  20948. getClassName(): string;
  20949. /**
  20950. * Serializes the particle system to a JSON object.
  20951. * @returns the JSON object
  20952. */
  20953. serialize(): any;
  20954. /**
  20955. * Parse properties from a JSON object
  20956. * @param serializationObject defines the JSON object
  20957. */
  20958. parse(serializationObject: any): void;
  20959. }
  20960. /**
  20961. * Particle emitter emitting particles from the inside of a cylinder.
  20962. * It emits the particles randomly between two vectors.
  20963. */
  20964. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20965. /**
  20966. * The min limit of the emission direction.
  20967. */
  20968. direction1: Vector3;
  20969. /**
  20970. * The max limit of the emission direction.
  20971. */
  20972. direction2: Vector3;
  20973. /**
  20974. * Creates a new instance CylinderDirectedParticleEmitter
  20975. * @param radius the radius of the emission cylinder (1 by default)
  20976. * @param height the height of the emission cylinder (1 by default)
  20977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20978. * @param direction1 the min limit of the emission direction (up vector by default)
  20979. * @param direction2 the max limit of the emission direction (up vector by default)
  20980. */
  20981. constructor(radius?: number, height?: number, radiusRange?: number,
  20982. /**
  20983. * The min limit of the emission direction.
  20984. */
  20985. direction1?: Vector3,
  20986. /**
  20987. * The max limit of the emission direction.
  20988. */
  20989. direction2?: Vector3);
  20990. /**
  20991. * Called by the particle System when the direction is computed for the created particle.
  20992. * @param worldMatrix is the world matrix of the particle system
  20993. * @param directionToUpdate is the direction vector to update with the result
  20994. * @param particle is the particle we are computed the direction for
  20995. */
  20996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20997. /**
  20998. * Clones the current emitter and returns a copy of it
  20999. * @returns the new emitter
  21000. */
  21001. clone(): CylinderDirectedParticleEmitter;
  21002. /**
  21003. * Called by the GPUParticleSystem to setup the update shader
  21004. * @param effect defines the update shader
  21005. */
  21006. applyToShader(effect: Effect): void;
  21007. /**
  21008. * Returns a string to use to update the GPU particles update shader
  21009. * @returns a string containng the defines string
  21010. */
  21011. getEffectDefines(): string;
  21012. /**
  21013. * Returns the string "CylinderDirectedParticleEmitter"
  21014. * @returns a string containing the class name
  21015. */
  21016. getClassName(): string;
  21017. /**
  21018. * Serializes the particle system to a JSON object.
  21019. * @returns the JSON object
  21020. */
  21021. serialize(): any;
  21022. /**
  21023. * Parse properties from a JSON object
  21024. * @param serializationObject defines the JSON object
  21025. */
  21026. parse(serializationObject: any): void;
  21027. }
  21028. }
  21029. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21030. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21031. import { Effect } from "babylonjs/Materials/effect";
  21032. import { Particle } from "babylonjs/Particles/particle";
  21033. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21034. /**
  21035. * Particle emitter emitting particles from the inside of a hemisphere.
  21036. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21037. */
  21038. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21039. /**
  21040. * The radius of the emission hemisphere.
  21041. */
  21042. radius: number;
  21043. /**
  21044. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21045. */
  21046. radiusRange: number;
  21047. /**
  21048. * How much to randomize the particle direction [0-1].
  21049. */
  21050. directionRandomizer: number;
  21051. /**
  21052. * Creates a new instance HemisphericParticleEmitter
  21053. * @param radius the radius of the emission hemisphere (1 by default)
  21054. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21055. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21056. */
  21057. constructor(
  21058. /**
  21059. * The radius of the emission hemisphere.
  21060. */
  21061. radius?: number,
  21062. /**
  21063. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21064. */
  21065. radiusRange?: number,
  21066. /**
  21067. * How much to randomize the particle direction [0-1].
  21068. */
  21069. directionRandomizer?: number);
  21070. /**
  21071. * Called by the particle System when the direction is computed for the created particle.
  21072. * @param worldMatrix is the world matrix of the particle system
  21073. * @param directionToUpdate is the direction vector to update with the result
  21074. * @param particle is the particle we are computed the direction for
  21075. */
  21076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21077. /**
  21078. * Called by the particle System when the position is computed for the created particle.
  21079. * @param worldMatrix is the world matrix of the particle system
  21080. * @param positionToUpdate is the position vector to update with the result
  21081. * @param particle is the particle we are computed the position for
  21082. */
  21083. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21084. /**
  21085. * Clones the current emitter and returns a copy of it
  21086. * @returns the new emitter
  21087. */
  21088. clone(): HemisphericParticleEmitter;
  21089. /**
  21090. * Called by the GPUParticleSystem to setup the update shader
  21091. * @param effect defines the update shader
  21092. */
  21093. applyToShader(effect: Effect): void;
  21094. /**
  21095. * Returns a string to use to update the GPU particles update shader
  21096. * @returns a string containng the defines string
  21097. */
  21098. getEffectDefines(): string;
  21099. /**
  21100. * Returns the string "HemisphericParticleEmitter"
  21101. * @returns a string containing the class name
  21102. */
  21103. getClassName(): string;
  21104. /**
  21105. * Serializes the particle system to a JSON object.
  21106. * @returns the JSON object
  21107. */
  21108. serialize(): any;
  21109. /**
  21110. * Parse properties from a JSON object
  21111. * @param serializationObject defines the JSON object
  21112. */
  21113. parse(serializationObject: any): void;
  21114. }
  21115. }
  21116. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21117. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21118. import { Effect } from "babylonjs/Materials/effect";
  21119. import { Particle } from "babylonjs/Particles/particle";
  21120. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21121. /**
  21122. * Particle emitter emitting particles from a point.
  21123. * It emits the particles randomly between 2 given directions.
  21124. */
  21125. export class PointParticleEmitter implements IParticleEmitterType {
  21126. /**
  21127. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21128. */
  21129. direction1: Vector3;
  21130. /**
  21131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21132. */
  21133. direction2: Vector3;
  21134. /**
  21135. * Creates a new instance PointParticleEmitter
  21136. */
  21137. constructor();
  21138. /**
  21139. * Called by the particle System when the direction is computed for the created particle.
  21140. * @param worldMatrix is the world matrix of the particle system
  21141. * @param directionToUpdate is the direction vector to update with the result
  21142. * @param particle is the particle we are computed the direction for
  21143. */
  21144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21145. /**
  21146. * Called by the particle System when the position is computed for the created particle.
  21147. * @param worldMatrix is the world matrix of the particle system
  21148. * @param positionToUpdate is the position vector to update with the result
  21149. * @param particle is the particle we are computed the position for
  21150. */
  21151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21152. /**
  21153. * Clones the current emitter and returns a copy of it
  21154. * @returns the new emitter
  21155. */
  21156. clone(): PointParticleEmitter;
  21157. /**
  21158. * Called by the GPUParticleSystem to setup the update shader
  21159. * @param effect defines the update shader
  21160. */
  21161. applyToShader(effect: Effect): void;
  21162. /**
  21163. * Returns a string to use to update the GPU particles update shader
  21164. * @returns a string containng the defines string
  21165. */
  21166. getEffectDefines(): string;
  21167. /**
  21168. * Returns the string "PointParticleEmitter"
  21169. * @returns a string containing the class name
  21170. */
  21171. getClassName(): string;
  21172. /**
  21173. * Serializes the particle system to a JSON object.
  21174. * @returns the JSON object
  21175. */
  21176. serialize(): any;
  21177. /**
  21178. * Parse properties from a JSON object
  21179. * @param serializationObject defines the JSON object
  21180. */
  21181. parse(serializationObject: any): void;
  21182. }
  21183. }
  21184. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21185. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21186. import { Effect } from "babylonjs/Materials/effect";
  21187. import { Particle } from "babylonjs/Particles/particle";
  21188. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21189. /**
  21190. * Particle emitter emitting particles from the inside of a sphere.
  21191. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21192. */
  21193. export class SphereParticleEmitter implements IParticleEmitterType {
  21194. /**
  21195. * The radius of the emission sphere.
  21196. */
  21197. radius: number;
  21198. /**
  21199. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21200. */
  21201. radiusRange: number;
  21202. /**
  21203. * How much to randomize the particle direction [0-1].
  21204. */
  21205. directionRandomizer: number;
  21206. /**
  21207. * Creates a new instance SphereParticleEmitter
  21208. * @param radius the radius of the emission sphere (1 by default)
  21209. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21210. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21211. */
  21212. constructor(
  21213. /**
  21214. * The radius of the emission sphere.
  21215. */
  21216. radius?: number,
  21217. /**
  21218. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21219. */
  21220. radiusRange?: number,
  21221. /**
  21222. * How much to randomize the particle direction [0-1].
  21223. */
  21224. directionRandomizer?: number);
  21225. /**
  21226. * Called by the particle System when the direction is computed for the created particle.
  21227. * @param worldMatrix is the world matrix of the particle system
  21228. * @param directionToUpdate is the direction vector to update with the result
  21229. * @param particle is the particle we are computed the direction for
  21230. */
  21231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21232. /**
  21233. * Called by the particle System when the position is computed for the created particle.
  21234. * @param worldMatrix is the world matrix of the particle system
  21235. * @param positionToUpdate is the position vector to update with the result
  21236. * @param particle is the particle we are computed the position for
  21237. */
  21238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21239. /**
  21240. * Clones the current emitter and returns a copy of it
  21241. * @returns the new emitter
  21242. */
  21243. clone(): SphereParticleEmitter;
  21244. /**
  21245. * Called by the GPUParticleSystem to setup the update shader
  21246. * @param effect defines the update shader
  21247. */
  21248. applyToShader(effect: Effect): void;
  21249. /**
  21250. * Returns a string to use to update the GPU particles update shader
  21251. * @returns a string containng the defines string
  21252. */
  21253. getEffectDefines(): string;
  21254. /**
  21255. * Returns the string "SphereParticleEmitter"
  21256. * @returns a string containing the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Serializes the particle system to a JSON object.
  21261. * @returns the JSON object
  21262. */
  21263. serialize(): any;
  21264. /**
  21265. * Parse properties from a JSON object
  21266. * @param serializationObject defines the JSON object
  21267. */
  21268. parse(serializationObject: any): void;
  21269. }
  21270. /**
  21271. * Particle emitter emitting particles from the inside of a sphere.
  21272. * It emits the particles randomly between two vectors.
  21273. */
  21274. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21275. /**
  21276. * The min limit of the emission direction.
  21277. */
  21278. direction1: Vector3;
  21279. /**
  21280. * The max limit of the emission direction.
  21281. */
  21282. direction2: Vector3;
  21283. /**
  21284. * Creates a new instance SphereDirectedParticleEmitter
  21285. * @param radius the radius of the emission sphere (1 by default)
  21286. * @param direction1 the min limit of the emission direction (up vector by default)
  21287. * @param direction2 the max limit of the emission direction (up vector by default)
  21288. */
  21289. constructor(radius?: number,
  21290. /**
  21291. * The min limit of the emission direction.
  21292. */
  21293. direction1?: Vector3,
  21294. /**
  21295. * The max limit of the emission direction.
  21296. */
  21297. direction2?: Vector3);
  21298. /**
  21299. * Called by the particle System when the direction is computed for the created particle.
  21300. * @param worldMatrix is the world matrix of the particle system
  21301. * @param directionToUpdate is the direction vector to update with the result
  21302. * @param particle is the particle we are computed the direction for
  21303. */
  21304. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21305. /**
  21306. * Clones the current emitter and returns a copy of it
  21307. * @returns the new emitter
  21308. */
  21309. clone(): SphereDirectedParticleEmitter;
  21310. /**
  21311. * Called by the GPUParticleSystem to setup the update shader
  21312. * @param effect defines the update shader
  21313. */
  21314. applyToShader(effect: Effect): void;
  21315. /**
  21316. * Returns a string to use to update the GPU particles update shader
  21317. * @returns a string containng the defines string
  21318. */
  21319. getEffectDefines(): string;
  21320. /**
  21321. * Returns the string "SphereDirectedParticleEmitter"
  21322. * @returns a string containing the class name
  21323. */
  21324. getClassName(): string;
  21325. /**
  21326. * Serializes the particle system to a JSON object.
  21327. * @returns the JSON object
  21328. */
  21329. serialize(): any;
  21330. /**
  21331. * Parse properties from a JSON object
  21332. * @param serializationObject defines the JSON object
  21333. */
  21334. parse(serializationObject: any): void;
  21335. }
  21336. }
  21337. declare module "babylonjs/Particles/EmitterTypes/index" {
  21338. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21339. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21340. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21341. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21342. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21343. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21344. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21345. }
  21346. declare module "babylonjs/Particles/IParticleSystem" {
  21347. import { Nullable } from "babylonjs/types";
  21348. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21351. import { Texture } from "babylonjs/Materials/Textures/texture";
  21352. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21353. import { Scene } from "babylonjs/scene";
  21354. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21355. import { Animation } from "babylonjs/Animations/animation";
  21356. /**
  21357. * Interface representing a particle system in Babylon.js.
  21358. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21359. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21360. */
  21361. export interface IParticleSystem {
  21362. /**
  21363. * List of animations used by the particle system.
  21364. */
  21365. animations: Animation[];
  21366. /**
  21367. * The id of the Particle system.
  21368. */
  21369. id: string;
  21370. /**
  21371. * The name of the Particle system.
  21372. */
  21373. name: string;
  21374. /**
  21375. * The emitter represents the Mesh or position we are attaching the particle system to.
  21376. */
  21377. emitter: Nullable<AbstractMesh | Vector3>;
  21378. /**
  21379. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21380. */
  21381. isBillboardBased: boolean;
  21382. /**
  21383. * The rendering group used by the Particle system to chose when to render.
  21384. */
  21385. renderingGroupId: number;
  21386. /**
  21387. * The layer mask we are rendering the particles through.
  21388. */
  21389. layerMask: number;
  21390. /**
  21391. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21392. */
  21393. updateSpeed: number;
  21394. /**
  21395. * The amount of time the particle system is running (depends of the overall update speed).
  21396. */
  21397. targetStopDuration: number;
  21398. /**
  21399. * The texture used to render each particle. (this can be a spritesheet)
  21400. */
  21401. particleTexture: Nullable<Texture>;
  21402. /**
  21403. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21404. */
  21405. blendMode: number;
  21406. /**
  21407. * Minimum life time of emitting particles.
  21408. */
  21409. minLifeTime: number;
  21410. /**
  21411. * Maximum life time of emitting particles.
  21412. */
  21413. maxLifeTime: number;
  21414. /**
  21415. * Minimum Size of emitting particles.
  21416. */
  21417. minSize: number;
  21418. /**
  21419. * Maximum Size of emitting particles.
  21420. */
  21421. maxSize: number;
  21422. /**
  21423. * Minimum scale of emitting particles on X axis.
  21424. */
  21425. minScaleX: number;
  21426. /**
  21427. * Maximum scale of emitting particles on X axis.
  21428. */
  21429. maxScaleX: number;
  21430. /**
  21431. * Minimum scale of emitting particles on Y axis.
  21432. */
  21433. minScaleY: number;
  21434. /**
  21435. * Maximum scale of emitting particles on Y axis.
  21436. */
  21437. maxScaleY: number;
  21438. /**
  21439. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21440. */
  21441. color1: Color4;
  21442. /**
  21443. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21444. */
  21445. color2: Color4;
  21446. /**
  21447. * Color the particle will have at the end of its lifetime.
  21448. */
  21449. colorDead: Color4;
  21450. /**
  21451. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21452. */
  21453. emitRate: number;
  21454. /**
  21455. * You can use gravity if you want to give an orientation to your particles.
  21456. */
  21457. gravity: Vector3;
  21458. /**
  21459. * Minimum power of emitting particles.
  21460. */
  21461. minEmitPower: number;
  21462. /**
  21463. * Maximum power of emitting particles.
  21464. */
  21465. maxEmitPower: number;
  21466. /**
  21467. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21468. */
  21469. minAngularSpeed: number;
  21470. /**
  21471. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21472. */
  21473. maxAngularSpeed: number;
  21474. /**
  21475. * Gets or sets the minimal initial rotation in radians.
  21476. */
  21477. minInitialRotation: number;
  21478. /**
  21479. * Gets or sets the maximal initial rotation in radians.
  21480. */
  21481. maxInitialRotation: number;
  21482. /**
  21483. * The particle emitter type defines the emitter used by the particle system.
  21484. * It can be for example box, sphere, or cone...
  21485. */
  21486. particleEmitterType: Nullable<IParticleEmitterType>;
  21487. /**
  21488. * Defines the delay in milliseconds before starting the system (0 by default)
  21489. */
  21490. startDelay: number;
  21491. /**
  21492. * 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
  21493. */
  21494. preWarmCycles: number;
  21495. /**
  21496. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21497. */
  21498. preWarmStepOffset: number;
  21499. /**
  21500. * 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)
  21501. */
  21502. spriteCellChangeSpeed: number;
  21503. /**
  21504. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21505. */
  21506. startSpriteCellID: number;
  21507. /**
  21508. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21509. */
  21510. endSpriteCellID: number;
  21511. /**
  21512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21513. */
  21514. spriteCellWidth: number;
  21515. /**
  21516. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21517. */
  21518. spriteCellHeight: number;
  21519. /**
  21520. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21521. */
  21522. spriteRandomStartCell: boolean;
  21523. /**
  21524. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21525. */
  21526. isAnimationSheetEnabled: boolean;
  21527. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21528. translationPivot: Vector2;
  21529. /**
  21530. * Gets or sets a texture used to add random noise to particle positions
  21531. */
  21532. noiseTexture: Nullable<BaseTexture>;
  21533. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21534. noiseStrength: Vector3;
  21535. /**
  21536. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21537. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21538. */
  21539. billboardMode: number;
  21540. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21541. limitVelocityDamping: number;
  21542. /**
  21543. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21544. */
  21545. beginAnimationOnStart: boolean;
  21546. /**
  21547. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21548. */
  21549. beginAnimationFrom: number;
  21550. /**
  21551. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21552. */
  21553. beginAnimationTo: number;
  21554. /**
  21555. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21556. */
  21557. beginAnimationLoop: boolean;
  21558. /**
  21559. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21560. */
  21561. disposeOnStop: boolean;
  21562. /**
  21563. * Gets the maximum number of particles active at the same time.
  21564. * @returns The max number of active particles.
  21565. */
  21566. getCapacity(): number;
  21567. /**
  21568. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21569. * @returns True if it has been started, otherwise false.
  21570. */
  21571. isStarted(): boolean;
  21572. /**
  21573. * Animates the particle system for this frame.
  21574. */
  21575. animate(): void;
  21576. /**
  21577. * Renders the particle system in its current state.
  21578. * @returns the current number of particles
  21579. */
  21580. render(): number;
  21581. /**
  21582. * Dispose the particle system and frees its associated resources.
  21583. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21584. */
  21585. dispose(disposeTexture?: boolean): void;
  21586. /**
  21587. * Clones the particle system.
  21588. * @param name The name of the cloned object
  21589. * @param newEmitter The new emitter to use
  21590. * @returns the cloned particle system
  21591. */
  21592. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21593. /**
  21594. * Serializes the particle system to a JSON object.
  21595. * @returns the JSON object
  21596. */
  21597. serialize(): any;
  21598. /**
  21599. * Rebuild the particle system
  21600. */
  21601. rebuild(): void;
  21602. /**
  21603. * Starts the particle system and begins to emit
  21604. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21605. */
  21606. start(delay?: number): void;
  21607. /**
  21608. * Stops the particle system.
  21609. */
  21610. stop(): void;
  21611. /**
  21612. * Remove all active particles
  21613. */
  21614. reset(): void;
  21615. /**
  21616. * Is this system ready to be used/rendered
  21617. * @return true if the system is ready
  21618. */
  21619. isReady(): boolean;
  21620. /**
  21621. * Adds a new color gradient
  21622. * @param gradient defines the gradient to use (between 0 and 1)
  21623. * @param color1 defines the color to affect to the specified gradient
  21624. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21625. * @returns the current particle system
  21626. */
  21627. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21628. /**
  21629. * Remove a specific color gradient
  21630. * @param gradient defines the gradient to remove
  21631. * @returns the current particle system
  21632. */
  21633. removeColorGradient(gradient: number): IParticleSystem;
  21634. /**
  21635. * Adds a new size gradient
  21636. * @param gradient defines the gradient to use (between 0 and 1)
  21637. * @param factor defines the size factor to affect to the specified gradient
  21638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21639. * @returns the current particle system
  21640. */
  21641. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21642. /**
  21643. * Remove a specific size gradient
  21644. * @param gradient defines the gradient to remove
  21645. * @returns the current particle system
  21646. */
  21647. removeSizeGradient(gradient: number): IParticleSystem;
  21648. /**
  21649. * Gets the current list of color gradients.
  21650. * You must use addColorGradient and removeColorGradient to udpate this list
  21651. * @returns the list of color gradients
  21652. */
  21653. getColorGradients(): Nullable<Array<ColorGradient>>;
  21654. /**
  21655. * Gets the current list of size gradients.
  21656. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21657. * @returns the list of size gradients
  21658. */
  21659. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21660. /**
  21661. * Gets the current list of angular speed gradients.
  21662. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21663. * @returns the list of angular speed gradients
  21664. */
  21665. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21666. /**
  21667. * Adds a new angular speed gradient
  21668. * @param gradient defines the gradient to use (between 0 and 1)
  21669. * @param factor defines the angular speed to affect to the specified gradient
  21670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21671. * @returns the current particle system
  21672. */
  21673. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21674. /**
  21675. * Remove a specific angular speed gradient
  21676. * @param gradient defines the gradient to remove
  21677. * @returns the current particle system
  21678. */
  21679. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21680. /**
  21681. * Gets the current list of velocity gradients.
  21682. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21683. * @returns the list of velocity gradients
  21684. */
  21685. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21686. /**
  21687. * Adds a new velocity gradient
  21688. * @param gradient defines the gradient to use (between 0 and 1)
  21689. * @param factor defines the velocity to affect to the specified gradient
  21690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21691. * @returns the current particle system
  21692. */
  21693. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21694. /**
  21695. * Remove a specific velocity gradient
  21696. * @param gradient defines the gradient to remove
  21697. * @returns the current particle system
  21698. */
  21699. removeVelocityGradient(gradient: number): IParticleSystem;
  21700. /**
  21701. * Gets the current list of limit velocity gradients.
  21702. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21703. * @returns the list of limit velocity gradients
  21704. */
  21705. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21706. /**
  21707. * Adds a new limit velocity gradient
  21708. * @param gradient defines the gradient to use (between 0 and 1)
  21709. * @param factor defines the limit velocity to affect to the specified gradient
  21710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21711. * @returns the current particle system
  21712. */
  21713. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21714. /**
  21715. * Remove a specific limit velocity gradient
  21716. * @param gradient defines the gradient to remove
  21717. * @returns the current particle system
  21718. */
  21719. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21720. /**
  21721. * Adds a new drag gradient
  21722. * @param gradient defines the gradient to use (between 0 and 1)
  21723. * @param factor defines the drag to affect to the specified gradient
  21724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21725. * @returns the current particle system
  21726. */
  21727. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21728. /**
  21729. * Remove a specific drag gradient
  21730. * @param gradient defines the gradient to remove
  21731. * @returns the current particle system
  21732. */
  21733. removeDragGradient(gradient: number): IParticleSystem;
  21734. /**
  21735. * Gets the current list of drag gradients.
  21736. * You must use addDragGradient and removeDragGradient to udpate this list
  21737. * @returns the list of drag gradients
  21738. */
  21739. getDragGradients(): Nullable<Array<FactorGradient>>;
  21740. /**
  21741. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21742. * @param gradient defines the gradient to use (between 0 and 1)
  21743. * @param factor defines the emit rate to affect to the specified gradient
  21744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21745. * @returns the current particle system
  21746. */
  21747. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21748. /**
  21749. * Remove a specific emit rate gradient
  21750. * @param gradient defines the gradient to remove
  21751. * @returns the current particle system
  21752. */
  21753. removeEmitRateGradient(gradient: number): IParticleSystem;
  21754. /**
  21755. * Gets the current list of emit rate gradients.
  21756. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21757. * @returns the list of emit rate gradients
  21758. */
  21759. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21760. /**
  21761. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21762. * @param gradient defines the gradient to use (between 0 and 1)
  21763. * @param factor defines the start size to affect to the specified gradient
  21764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21765. * @returns the current particle system
  21766. */
  21767. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21768. /**
  21769. * Remove a specific start size gradient
  21770. * @param gradient defines the gradient to remove
  21771. * @returns the current particle system
  21772. */
  21773. removeStartSizeGradient(gradient: number): IParticleSystem;
  21774. /**
  21775. * Gets the current list of start size gradients.
  21776. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21777. * @returns the list of start size gradients
  21778. */
  21779. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21780. /**
  21781. * Adds a new life time gradient
  21782. * @param gradient defines the gradient to use (between 0 and 1)
  21783. * @param factor defines the life time factor to affect to the specified gradient
  21784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21785. * @returns the current particle system
  21786. */
  21787. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21788. /**
  21789. * Remove a specific life time gradient
  21790. * @param gradient defines the gradient to remove
  21791. * @returns the current particle system
  21792. */
  21793. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21794. /**
  21795. * Gets the current list of life time gradients.
  21796. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21797. * @returns the list of life time gradients
  21798. */
  21799. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21800. /**
  21801. * Gets the current list of color gradients.
  21802. * You must use addColorGradient and removeColorGradient to udpate this list
  21803. * @returns the list of color gradients
  21804. */
  21805. getColorGradients(): Nullable<Array<ColorGradient>>;
  21806. /**
  21807. * Adds a new ramp gradient used to remap particle colors
  21808. * @param gradient defines the gradient to use (between 0 and 1)
  21809. * @param color defines the color to affect to the specified gradient
  21810. * @returns the current particle system
  21811. */
  21812. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21813. /**
  21814. * Gets the current list of ramp gradients.
  21815. * You must use addRampGradient and removeRampGradient to udpate this list
  21816. * @returns the list of ramp gradients
  21817. */
  21818. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21819. /** Gets or sets a boolean indicating that ramp gradients must be used
  21820. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21821. */
  21822. useRampGradients: boolean;
  21823. /**
  21824. * Adds a new color remap gradient
  21825. * @param gradient defines the gradient to use (between 0 and 1)
  21826. * @param min defines the color remap minimal range
  21827. * @param max defines the color remap maximal range
  21828. * @returns the current particle system
  21829. */
  21830. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21831. /**
  21832. * Gets the current list of color remap gradients.
  21833. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21834. * @returns the list of color remap gradients
  21835. */
  21836. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21837. /**
  21838. * Adds a new alpha remap gradient
  21839. * @param gradient defines the gradient to use (between 0 and 1)
  21840. * @param min defines the alpha remap minimal range
  21841. * @param max defines the alpha remap maximal range
  21842. * @returns the current particle system
  21843. */
  21844. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21845. /**
  21846. * Gets the current list of alpha remap gradients.
  21847. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21848. * @returns the list of alpha remap gradients
  21849. */
  21850. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21851. /**
  21852. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21855. * @returns the emitter
  21856. */
  21857. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21858. /**
  21859. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21860. * @param radius The radius of the hemisphere to emit from
  21861. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21862. * @returns the emitter
  21863. */
  21864. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21865. /**
  21866. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21867. * @param radius The radius of the sphere to emit from
  21868. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21869. * @returns the emitter
  21870. */
  21871. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21872. /**
  21873. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21874. * @param radius The radius of the sphere to emit from
  21875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21877. * @returns the emitter
  21878. */
  21879. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21880. /**
  21881. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21882. * @param radius The radius of the emission cylinder
  21883. * @param height The height of the emission cylinder
  21884. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21885. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21886. * @returns the emitter
  21887. */
  21888. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21889. /**
  21890. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21891. * @param radius The radius of the cylinder to emit from
  21892. * @param height The height of the emission cylinder
  21893. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21894. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21895. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21896. * @returns the emitter
  21897. */
  21898. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21899. /**
  21900. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21901. * @param radius The radius of the cone to emit from
  21902. * @param angle The base angle of the cone
  21903. * @returns the emitter
  21904. */
  21905. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21906. /**
  21907. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21908. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21909. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21910. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21911. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21912. * @returns the emitter
  21913. */
  21914. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21915. /**
  21916. * Get hosting scene
  21917. * @returns the scene
  21918. */
  21919. getScene(): Scene;
  21920. }
  21921. }
  21922. declare module "babylonjs/Shaders/line.fragment" {
  21923. /** @hidden */
  21924. export var linePixelShader: {
  21925. name: string;
  21926. shader: string;
  21927. };
  21928. }
  21929. declare module "babylonjs/Shaders/line.vertex" {
  21930. /** @hidden */
  21931. export var lineVertexShader: {
  21932. name: string;
  21933. shader: string;
  21934. };
  21935. }
  21936. declare module "babylonjs/Rendering/edgesRenderer" {
  21937. import { Nullable } from "babylonjs/types";
  21938. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21940. import { Vector3 } from "babylonjs/Maths/math";
  21941. import { IDisposable } from "babylonjs/scene";
  21942. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21943. import "babylonjs/Shaders/line.fragment";
  21944. import "babylonjs/Shaders/line.vertex";
  21945. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21946. module "babylonjs/Meshes/abstractMesh" {
  21947. interface AbstractMesh {
  21948. /**
  21949. * Gets the edgesRenderer associated with the mesh
  21950. */
  21951. edgesRenderer: Nullable<EdgesRenderer>;
  21952. }
  21953. }
  21954. module "babylonjs/Meshes/linesMesh" {
  21955. interface LinesMesh {
  21956. /**
  21957. * Enables the edge rendering mode on the mesh.
  21958. * This mode makes the mesh edges visible
  21959. * @param epsilon defines the maximal distance between two angles to detect a face
  21960. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21961. * @returns the currentAbstractMesh
  21962. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21963. */
  21964. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21965. }
  21966. }
  21967. module "babylonjs/Meshes/linesMesh" {
  21968. interface InstancedLinesMesh {
  21969. /**
  21970. * Enables the edge rendering mode on the mesh.
  21971. * This mode makes the mesh edges visible
  21972. * @param epsilon defines the maximal distance between two angles to detect a face
  21973. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21974. * @returns the current InstancedLinesMesh
  21975. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21976. */
  21977. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21978. }
  21979. }
  21980. /**
  21981. * Defines the minimum contract an Edges renderer should follow.
  21982. */
  21983. export interface IEdgesRenderer extends IDisposable {
  21984. /**
  21985. * Gets or sets a boolean indicating if the edgesRenderer is active
  21986. */
  21987. isEnabled: boolean;
  21988. /**
  21989. * Renders the edges of the attached mesh,
  21990. */
  21991. render(): void;
  21992. /**
  21993. * Checks wether or not the edges renderer is ready to render.
  21994. * @return true if ready, otherwise false.
  21995. */
  21996. isReady(): boolean;
  21997. }
  21998. /**
  21999. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  22000. */
  22001. export class EdgesRenderer implements IEdgesRenderer {
  22002. /**
  22003. * Define the size of the edges with an orthographic camera
  22004. */
  22005. edgesWidthScalerForOrthographic: number;
  22006. /**
  22007. * Define the size of the edges with a perspective camera
  22008. */
  22009. edgesWidthScalerForPerspective: number;
  22010. protected _source: AbstractMesh;
  22011. protected _linesPositions: number[];
  22012. protected _linesNormals: number[];
  22013. protected _linesIndices: number[];
  22014. protected _epsilon: number;
  22015. protected _indicesCount: number;
  22016. protected _lineShader: ShaderMaterial;
  22017. protected _ib: DataBuffer;
  22018. protected _buffers: {
  22019. [key: string]: Nullable<VertexBuffer>;
  22020. };
  22021. protected _checkVerticesInsteadOfIndices: boolean;
  22022. private _meshRebuildObserver;
  22023. private _meshDisposeObserver;
  22024. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22025. isEnabled: boolean;
  22026. /**
  22027. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22028. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22029. * @param source Mesh used to create edges
  22030. * @param epsilon sum of angles in adjacency to check for edge
  22031. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22032. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22033. */
  22034. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22035. protected _prepareRessources(): void;
  22036. /** @hidden */
  22037. _rebuild(): void;
  22038. /**
  22039. * Releases the required resources for the edges renderer
  22040. */
  22041. dispose(): void;
  22042. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22043. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22044. /**
  22045. * Checks if the pair of p0 and p1 is en edge
  22046. * @param faceIndex
  22047. * @param edge
  22048. * @param faceNormals
  22049. * @param p0
  22050. * @param p1
  22051. * @private
  22052. */
  22053. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22054. /**
  22055. * push line into the position, normal and index buffer
  22056. * @protected
  22057. */
  22058. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22059. /**
  22060. * Generates lines edges from adjacencjes
  22061. * @private
  22062. */
  22063. _generateEdgesLines(): void;
  22064. /**
  22065. * Checks wether or not the edges renderer is ready to render.
  22066. * @return true if ready, otherwise false.
  22067. */
  22068. isReady(): boolean;
  22069. /**
  22070. * Renders the edges of the attached mesh,
  22071. */
  22072. render(): void;
  22073. }
  22074. /**
  22075. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22076. */
  22077. export class LineEdgesRenderer extends EdgesRenderer {
  22078. /**
  22079. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22080. * @param source LineMesh used to generate edges
  22081. * @param epsilon not important (specified angle for edge detection)
  22082. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22083. */
  22084. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22085. /**
  22086. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22087. */
  22088. _generateEdgesLines(): void;
  22089. }
  22090. }
  22091. declare module "babylonjs/Rendering/renderingGroup" {
  22092. import { SmartArray } from "babylonjs/Misc/smartArray";
  22093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22095. import { Nullable } from "babylonjs/types";
  22096. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22097. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22098. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22099. import { Material } from "babylonjs/Materials/material";
  22100. import { Scene } from "babylonjs/scene";
  22101. /**
  22102. * This represents the object necessary to create a rendering group.
  22103. * This is exclusively used and created by the rendering manager.
  22104. * To modify the behavior, you use the available helpers in your scene or meshes.
  22105. * @hidden
  22106. */
  22107. export class RenderingGroup {
  22108. index: number;
  22109. private static _zeroVector;
  22110. private _scene;
  22111. private _opaqueSubMeshes;
  22112. private _transparentSubMeshes;
  22113. private _alphaTestSubMeshes;
  22114. private _depthOnlySubMeshes;
  22115. private _particleSystems;
  22116. private _spriteManagers;
  22117. private _opaqueSortCompareFn;
  22118. private _alphaTestSortCompareFn;
  22119. private _transparentSortCompareFn;
  22120. private _renderOpaque;
  22121. private _renderAlphaTest;
  22122. private _renderTransparent;
  22123. /** @hidden */
  22124. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22125. onBeforeTransparentRendering: () => void;
  22126. /**
  22127. * Set the opaque sort comparison function.
  22128. * If null the sub meshes will be render in the order they were created
  22129. */
  22130. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22131. /**
  22132. * Set the alpha test sort comparison function.
  22133. * If null the sub meshes will be render in the order they were created
  22134. */
  22135. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22136. /**
  22137. * Set the transparent sort comparison function.
  22138. * If null the sub meshes will be render in the order they were created
  22139. */
  22140. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22141. /**
  22142. * Creates a new rendering group.
  22143. * @param index The rendering group index
  22144. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22145. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22146. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22147. */
  22148. 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>);
  22149. /**
  22150. * Render all the sub meshes contained in the group.
  22151. * @param customRenderFunction Used to override the default render behaviour of the group.
  22152. * @returns true if rendered some submeshes.
  22153. */
  22154. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22155. /**
  22156. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22157. * @param subMeshes The submeshes to render
  22158. */
  22159. private renderOpaqueSorted;
  22160. /**
  22161. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22162. * @param subMeshes The submeshes to render
  22163. */
  22164. private renderAlphaTestSorted;
  22165. /**
  22166. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22167. * @param subMeshes The submeshes to render
  22168. */
  22169. private renderTransparentSorted;
  22170. /**
  22171. * Renders the submeshes in a specified order.
  22172. * @param subMeshes The submeshes to sort before render
  22173. * @param sortCompareFn The comparison function use to sort
  22174. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22175. * @param transparent Specifies to activate blending if true
  22176. */
  22177. private static renderSorted;
  22178. /**
  22179. * Renders the submeshes in the order they were dispatched (no sort applied).
  22180. * @param subMeshes The submeshes to render
  22181. */
  22182. private static renderUnsorted;
  22183. /**
  22184. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22185. * are rendered back to front if in the same alpha index.
  22186. *
  22187. * @param a The first submesh
  22188. * @param b The second submesh
  22189. * @returns The result of the comparison
  22190. */
  22191. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22192. /**
  22193. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22194. * are rendered back to front.
  22195. *
  22196. * @param a The first submesh
  22197. * @param b The second submesh
  22198. * @returns The result of the comparison
  22199. */
  22200. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22201. /**
  22202. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22203. * are rendered front to back (prevent overdraw).
  22204. *
  22205. * @param a The first submesh
  22206. * @param b The second submesh
  22207. * @returns The result of the comparison
  22208. */
  22209. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22210. /**
  22211. * Resets the different lists of submeshes to prepare a new frame.
  22212. */
  22213. prepare(): void;
  22214. dispose(): void;
  22215. /**
  22216. * Inserts the submesh in its correct queue depending on its material.
  22217. * @param subMesh The submesh to dispatch
  22218. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22219. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22220. */
  22221. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22222. dispatchSprites(spriteManager: ISpriteManager): void;
  22223. dispatchParticles(particleSystem: IParticleSystem): void;
  22224. private _renderParticles;
  22225. private _renderSprites;
  22226. }
  22227. }
  22228. declare module "babylonjs/Rendering/renderingManager" {
  22229. import { Nullable } from "babylonjs/types";
  22230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22231. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22232. import { SmartArray } from "babylonjs/Misc/smartArray";
  22233. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22234. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22235. import { Material } from "babylonjs/Materials/material";
  22236. import { Scene } from "babylonjs/scene";
  22237. import { Camera } from "babylonjs/Cameras/camera";
  22238. /**
  22239. * Interface describing the different options available in the rendering manager
  22240. * regarding Auto Clear between groups.
  22241. */
  22242. export interface IRenderingManagerAutoClearSetup {
  22243. /**
  22244. * Defines whether or not autoclear is enable.
  22245. */
  22246. autoClear: boolean;
  22247. /**
  22248. * Defines whether or not to autoclear the depth buffer.
  22249. */
  22250. depth: boolean;
  22251. /**
  22252. * Defines whether or not to autoclear the stencil buffer.
  22253. */
  22254. stencil: boolean;
  22255. }
  22256. /**
  22257. * This class is used by the onRenderingGroupObservable
  22258. */
  22259. export class RenderingGroupInfo {
  22260. /**
  22261. * The Scene that being rendered
  22262. */
  22263. scene: Scene;
  22264. /**
  22265. * The camera currently used for the rendering pass
  22266. */
  22267. camera: Nullable<Camera>;
  22268. /**
  22269. * The ID of the renderingGroup being processed
  22270. */
  22271. renderingGroupId: number;
  22272. }
  22273. /**
  22274. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22275. * It is enable to manage the different groups as well as the different necessary sort functions.
  22276. * This should not be used directly aside of the few static configurations
  22277. */
  22278. export class RenderingManager {
  22279. /**
  22280. * The max id used for rendering groups (not included)
  22281. */
  22282. static MAX_RENDERINGGROUPS: number;
  22283. /**
  22284. * The min id used for rendering groups (included)
  22285. */
  22286. static MIN_RENDERINGGROUPS: number;
  22287. /**
  22288. * Used to globally prevent autoclearing scenes.
  22289. */
  22290. static AUTOCLEAR: boolean;
  22291. /**
  22292. * @hidden
  22293. */
  22294. _useSceneAutoClearSetup: boolean;
  22295. private _scene;
  22296. private _renderingGroups;
  22297. private _depthStencilBufferAlreadyCleaned;
  22298. private _autoClearDepthStencil;
  22299. private _customOpaqueSortCompareFn;
  22300. private _customAlphaTestSortCompareFn;
  22301. private _customTransparentSortCompareFn;
  22302. private _renderingGroupInfo;
  22303. /**
  22304. * Instantiates a new rendering group for a particular scene
  22305. * @param scene Defines the scene the groups belongs to
  22306. */
  22307. constructor(scene: Scene);
  22308. private _clearDepthStencilBuffer;
  22309. /**
  22310. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22311. * @hidden
  22312. */
  22313. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22314. /**
  22315. * Resets the different information of the group to prepare a new frame
  22316. * @hidden
  22317. */
  22318. reset(): void;
  22319. /**
  22320. * Dispose and release the group and its associated resources.
  22321. * @hidden
  22322. */
  22323. dispose(): void;
  22324. /**
  22325. * Clear the info related to rendering groups preventing retention points during dispose.
  22326. */
  22327. freeRenderingGroups(): void;
  22328. private _prepareRenderingGroup;
  22329. /**
  22330. * Add a sprite manager to the rendering manager in order to render it this frame.
  22331. * @param spriteManager Define the sprite manager to render
  22332. */
  22333. dispatchSprites(spriteManager: ISpriteManager): void;
  22334. /**
  22335. * Add a particle system to the rendering manager in order to render it this frame.
  22336. * @param particleSystem Define the particle system to render
  22337. */
  22338. dispatchParticles(particleSystem: IParticleSystem): void;
  22339. /**
  22340. * Add a submesh to the manager in order to render it this frame
  22341. * @param subMesh The submesh to dispatch
  22342. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22343. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22344. */
  22345. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22346. /**
  22347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22348. * This allowed control for front to back rendering or reversly depending of the special needs.
  22349. *
  22350. * @param renderingGroupId The rendering group id corresponding to its index
  22351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22354. */
  22355. 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;
  22356. /**
  22357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22358. *
  22359. * @param renderingGroupId The rendering group id corresponding to its index
  22360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22361. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22362. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22363. */
  22364. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22365. /**
  22366. * Gets the current auto clear configuration for one rendering group of the rendering
  22367. * manager.
  22368. * @param index the rendering group index to get the information for
  22369. * @returns The auto clear setup for the requested rendering group
  22370. */
  22371. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22372. }
  22373. }
  22374. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22375. import { Observable } from "babylonjs/Misc/observable";
  22376. import { SmartArray } from "babylonjs/Misc/smartArray";
  22377. import { Nullable } from "babylonjs/types";
  22378. import { Camera } from "babylonjs/Cameras/camera";
  22379. import { Scene } from "babylonjs/scene";
  22380. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22381. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22385. import { Texture } from "babylonjs/Materials/Textures/texture";
  22386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22387. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22388. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22389. import { Engine } from "babylonjs/Engines/engine";
  22390. /**
  22391. * This Helps creating a texture that will be created from a camera in your scene.
  22392. * It is basically a dynamic texture that could be used to create special effects for instance.
  22393. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22394. */
  22395. export class RenderTargetTexture extends Texture {
  22396. isCube: boolean;
  22397. /**
  22398. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22399. */
  22400. static readonly REFRESHRATE_RENDER_ONCE: number;
  22401. /**
  22402. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22403. */
  22404. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22405. /**
  22406. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22407. * the central point of your effect and can save a lot of performances.
  22408. */
  22409. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22410. /**
  22411. * Use this predicate to dynamically define the list of mesh you want to render.
  22412. * If set, the renderList property will be overwritten.
  22413. */
  22414. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22415. private _renderList;
  22416. /**
  22417. * Use this list to define the list of mesh you want to render.
  22418. */
  22419. renderList: Nullable<Array<AbstractMesh>>;
  22420. private _hookArray;
  22421. /**
  22422. * Define if particles should be rendered in your texture.
  22423. */
  22424. renderParticles: boolean;
  22425. /**
  22426. * Define if sprites should be rendered in your texture.
  22427. */
  22428. renderSprites: boolean;
  22429. /**
  22430. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22431. */
  22432. coordinatesMode: number;
  22433. /**
  22434. * Define the camera used to render the texture.
  22435. */
  22436. activeCamera: Nullable<Camera>;
  22437. /**
  22438. * Override the render function of the texture with your own one.
  22439. */
  22440. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22441. /**
  22442. * Define if camera post processes should be use while rendering the texture.
  22443. */
  22444. useCameraPostProcesses: boolean;
  22445. /**
  22446. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22447. */
  22448. ignoreCameraViewport: boolean;
  22449. private _postProcessManager;
  22450. private _postProcesses;
  22451. private _resizeObserver;
  22452. /**
  22453. * An event triggered when the texture is unbind.
  22454. */
  22455. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22456. /**
  22457. * An event triggered when the texture is unbind.
  22458. */
  22459. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22460. private _onAfterUnbindObserver;
  22461. /**
  22462. * Set a after unbind callback in the texture.
  22463. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22464. */
  22465. onAfterUnbind: () => void;
  22466. /**
  22467. * An event triggered before rendering the texture
  22468. */
  22469. onBeforeRenderObservable: Observable<number>;
  22470. private _onBeforeRenderObserver;
  22471. /**
  22472. * Set a before render callback in the texture.
  22473. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22474. */
  22475. onBeforeRender: (faceIndex: number) => void;
  22476. /**
  22477. * An event triggered after rendering the texture
  22478. */
  22479. onAfterRenderObservable: Observable<number>;
  22480. private _onAfterRenderObserver;
  22481. /**
  22482. * Set a after render callback in the texture.
  22483. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22484. */
  22485. onAfterRender: (faceIndex: number) => void;
  22486. /**
  22487. * An event triggered after the texture clear
  22488. */
  22489. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22490. private _onClearObserver;
  22491. /**
  22492. * Set a clear callback in the texture.
  22493. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22494. */
  22495. onClear: (Engine: Engine) => void;
  22496. /**
  22497. * Define the clear color of the Render Target if it should be different from the scene.
  22498. */
  22499. clearColor: Color4;
  22500. protected _size: number | {
  22501. width: number;
  22502. height: number;
  22503. };
  22504. protected _initialSizeParameter: number | {
  22505. width: number;
  22506. height: number;
  22507. } | {
  22508. ratio: number;
  22509. };
  22510. protected _sizeRatio: Nullable<number>;
  22511. /** @hidden */
  22512. _generateMipMaps: boolean;
  22513. protected _renderingManager: RenderingManager;
  22514. /** @hidden */
  22515. _waitingRenderList: string[];
  22516. protected _doNotChangeAspectRatio: boolean;
  22517. protected _currentRefreshId: number;
  22518. protected _refreshRate: number;
  22519. protected _textureMatrix: Matrix;
  22520. protected _samples: number;
  22521. protected _renderTargetOptions: RenderTargetCreationOptions;
  22522. /**
  22523. * Gets render target creation options that were used.
  22524. */
  22525. readonly renderTargetOptions: RenderTargetCreationOptions;
  22526. protected _engine: Engine;
  22527. protected _onRatioRescale(): void;
  22528. /**
  22529. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22530. * It must define where the camera used to render the texture is set
  22531. */
  22532. boundingBoxPosition: Vector3;
  22533. private _boundingBoxSize;
  22534. /**
  22535. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22536. * When defined, the cubemap will switch to local mode
  22537. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22538. * @example https://www.babylonjs-playground.com/#RNASML
  22539. */
  22540. boundingBoxSize: Vector3;
  22541. /**
  22542. * In case the RTT has been created with a depth texture, get the associated
  22543. * depth texture.
  22544. * Otherwise, return null.
  22545. */
  22546. depthStencilTexture: Nullable<InternalTexture>;
  22547. /**
  22548. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22549. * or used a shadow, depth texture...
  22550. * @param name The friendly name of the texture
  22551. * @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)
  22552. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22553. * @param generateMipMaps True if mip maps need to be generated after render.
  22554. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22555. * @param type The type of the buffer in the RTT (int, half float, float...)
  22556. * @param isCube True if a cube texture needs to be created
  22557. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22558. * @param generateDepthBuffer True to generate a depth buffer
  22559. * @param generateStencilBuffer True to generate a stencil buffer
  22560. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22561. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22562. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22563. */
  22564. constructor(name: string, size: number | {
  22565. width: number;
  22566. height: number;
  22567. } | {
  22568. ratio: number;
  22569. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22570. /**
  22571. * Creates a depth stencil texture.
  22572. * This is only available in WebGL 2 or with the depth texture extension available.
  22573. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22574. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22575. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22576. */
  22577. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22578. private _processSizeParameter;
  22579. /**
  22580. * Define the number of samples to use in case of MSAA.
  22581. * It defaults to one meaning no MSAA has been enabled.
  22582. */
  22583. samples: number;
  22584. /**
  22585. * Resets the refresh counter of the texture and start bak from scratch.
  22586. * Could be useful to regenerate the texture if it is setup to render only once.
  22587. */
  22588. resetRefreshCounter(): void;
  22589. /**
  22590. * Define the refresh rate of the texture or the rendering frequency.
  22591. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22592. */
  22593. refreshRate: number;
  22594. /**
  22595. * Adds a post process to the render target rendering passes.
  22596. * @param postProcess define the post process to add
  22597. */
  22598. addPostProcess(postProcess: PostProcess): void;
  22599. /**
  22600. * Clear all the post processes attached to the render target
  22601. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22602. */
  22603. clearPostProcesses(dispose?: boolean): void;
  22604. /**
  22605. * Remove one of the post process from the list of attached post processes to the texture
  22606. * @param postProcess define the post process to remove from the list
  22607. */
  22608. removePostProcess(postProcess: PostProcess): void;
  22609. /** @hidden */
  22610. _shouldRender(): boolean;
  22611. /**
  22612. * Gets the actual render size of the texture.
  22613. * @returns the width of the render size
  22614. */
  22615. getRenderSize(): number;
  22616. /**
  22617. * Gets the actual render width of the texture.
  22618. * @returns the width of the render size
  22619. */
  22620. getRenderWidth(): number;
  22621. /**
  22622. * Gets the actual render height of the texture.
  22623. * @returns the height of the render size
  22624. */
  22625. getRenderHeight(): number;
  22626. /**
  22627. * Get if the texture can be rescaled or not.
  22628. */
  22629. readonly canRescale: boolean;
  22630. /**
  22631. * Resize the texture using a ratio.
  22632. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22633. */
  22634. scale(ratio: number): void;
  22635. /**
  22636. * Get the texture reflection matrix used to rotate/transform the reflection.
  22637. * @returns the reflection matrix
  22638. */
  22639. getReflectionTextureMatrix(): Matrix;
  22640. /**
  22641. * Resize the texture to a new desired size.
  22642. * Be carrefull as it will recreate all the data in the new texture.
  22643. * @param size Define the new size. It can be:
  22644. * - a number for squared texture,
  22645. * - an object containing { width: number, height: number }
  22646. * - or an object containing a ratio { ratio: number }
  22647. */
  22648. resize(size: number | {
  22649. width: number;
  22650. height: number;
  22651. } | {
  22652. ratio: number;
  22653. }): void;
  22654. /**
  22655. * Renders all the objects from the render list into the texture.
  22656. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22657. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22658. */
  22659. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22660. private _bestReflectionRenderTargetDimension;
  22661. /**
  22662. * @hidden
  22663. * @param faceIndex face index to bind to if this is a cubetexture
  22664. */
  22665. _bindFrameBuffer(faceIndex?: number): void;
  22666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22667. private renderToTarget;
  22668. /**
  22669. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22670. * This allowed control for front to back rendering or reversly depending of the special needs.
  22671. *
  22672. * @param renderingGroupId The rendering group id corresponding to its index
  22673. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22674. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22675. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22676. */
  22677. 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;
  22678. /**
  22679. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22680. *
  22681. * @param renderingGroupId The rendering group id corresponding to its index
  22682. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22683. */
  22684. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22685. /**
  22686. * Clones the texture.
  22687. * @returns the cloned texture
  22688. */
  22689. clone(): RenderTargetTexture;
  22690. /**
  22691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22692. * @returns The JSON representation of the texture
  22693. */
  22694. serialize(): any;
  22695. /**
  22696. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22697. */
  22698. disposeFramebufferObjects(): void;
  22699. /**
  22700. * Dispose the texture and release its associated resources.
  22701. */
  22702. dispose(): void;
  22703. /** @hidden */
  22704. _rebuild(): void;
  22705. /**
  22706. * Clear the info related to rendering groups preventing retention point in material dispose.
  22707. */
  22708. freeRenderingGroups(): void;
  22709. /**
  22710. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22711. * @returns the view count
  22712. */
  22713. getViewCount(): number;
  22714. }
  22715. }
  22716. declare module "babylonjs/Materials/material" {
  22717. import { IAnimatable } from "babylonjs/Misc/tools";
  22718. import { SmartArray } from "babylonjs/Misc/smartArray";
  22719. import { Observable } from "babylonjs/Misc/observable";
  22720. import { Nullable } from "babylonjs/types";
  22721. import { Scene } from "babylonjs/scene";
  22722. import { Matrix } from "babylonjs/Maths/math";
  22723. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22725. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22726. import { Effect } from "babylonjs/Materials/effect";
  22727. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22729. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22730. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22731. import { Mesh } from "babylonjs/Meshes/mesh";
  22732. import { Animation } from "babylonjs/Animations/animation";
  22733. /**
  22734. * Base class for the main features of a material in Babylon.js
  22735. */
  22736. export class Material implements IAnimatable {
  22737. /**
  22738. * Returns the triangle fill mode
  22739. */
  22740. static readonly TriangleFillMode: number;
  22741. /**
  22742. * Returns the wireframe mode
  22743. */
  22744. static readonly WireFrameFillMode: number;
  22745. /**
  22746. * Returns the point fill mode
  22747. */
  22748. static readonly PointFillMode: number;
  22749. /**
  22750. * Returns the point list draw mode
  22751. */
  22752. static readonly PointListDrawMode: number;
  22753. /**
  22754. * Returns the line list draw mode
  22755. */
  22756. static readonly LineListDrawMode: number;
  22757. /**
  22758. * Returns the line loop draw mode
  22759. */
  22760. static readonly LineLoopDrawMode: number;
  22761. /**
  22762. * Returns the line strip draw mode
  22763. */
  22764. static readonly LineStripDrawMode: number;
  22765. /**
  22766. * Returns the triangle strip draw mode
  22767. */
  22768. static readonly TriangleStripDrawMode: number;
  22769. /**
  22770. * Returns the triangle fan draw mode
  22771. */
  22772. static readonly TriangleFanDrawMode: number;
  22773. /**
  22774. * Stores the clock-wise side orientation
  22775. */
  22776. static readonly ClockWiseSideOrientation: number;
  22777. /**
  22778. * Stores the counter clock-wise side orientation
  22779. */
  22780. static readonly CounterClockWiseSideOrientation: number;
  22781. /**
  22782. * The dirty texture flag value
  22783. */
  22784. static readonly TextureDirtyFlag: number;
  22785. /**
  22786. * The dirty light flag value
  22787. */
  22788. static readonly LightDirtyFlag: number;
  22789. /**
  22790. * The dirty fresnel flag value
  22791. */
  22792. static readonly FresnelDirtyFlag: number;
  22793. /**
  22794. * The dirty attribute flag value
  22795. */
  22796. static readonly AttributesDirtyFlag: number;
  22797. /**
  22798. * The dirty misc flag value
  22799. */
  22800. static readonly MiscDirtyFlag: number;
  22801. /**
  22802. * The all dirty flag value
  22803. */
  22804. static readonly AllDirtyFlag: number;
  22805. /**
  22806. * The ID of the material
  22807. */
  22808. id: string;
  22809. /**
  22810. * Gets or sets the unique id of the material
  22811. */
  22812. uniqueId: number;
  22813. /**
  22814. * The name of the material
  22815. */
  22816. name: string;
  22817. /**
  22818. * Gets or sets user defined metadata
  22819. */
  22820. metadata: any;
  22821. /**
  22822. * For internal use only. Please do not use.
  22823. */
  22824. reservedDataStore: any;
  22825. /**
  22826. * Specifies if the ready state should be checked on each call
  22827. */
  22828. checkReadyOnEveryCall: boolean;
  22829. /**
  22830. * Specifies if the ready state should be checked once
  22831. */
  22832. checkReadyOnlyOnce: boolean;
  22833. /**
  22834. * The state of the material
  22835. */
  22836. state: string;
  22837. /**
  22838. * The alpha value of the material
  22839. */
  22840. protected _alpha: number;
  22841. /**
  22842. * List of inspectable custom properties (used by the Inspector)
  22843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22844. */
  22845. inspectableCustomProperties: IInspectable[];
  22846. /**
  22847. * Sets the alpha value of the material
  22848. */
  22849. /**
  22850. * Gets the alpha value of the material
  22851. */
  22852. alpha: number;
  22853. /**
  22854. * Specifies if back face culling is enabled
  22855. */
  22856. protected _backFaceCulling: boolean;
  22857. /**
  22858. * Sets the back-face culling state
  22859. */
  22860. /**
  22861. * Gets the back-face culling state
  22862. */
  22863. backFaceCulling: boolean;
  22864. /**
  22865. * Stores the value for side orientation
  22866. */
  22867. sideOrientation: number;
  22868. /**
  22869. * Callback triggered when the material is compiled
  22870. */
  22871. onCompiled: Nullable<(effect: Effect) => void>;
  22872. /**
  22873. * Callback triggered when an error occurs
  22874. */
  22875. onError: Nullable<(effect: Effect, errors: string) => void>;
  22876. /**
  22877. * Callback triggered to get the render target textures
  22878. */
  22879. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22880. /**
  22881. * Gets a boolean indicating that current material needs to register RTT
  22882. */
  22883. readonly hasRenderTargetTextures: boolean;
  22884. /**
  22885. * Specifies if the material should be serialized
  22886. */
  22887. doNotSerialize: boolean;
  22888. /**
  22889. * @hidden
  22890. */
  22891. _storeEffectOnSubMeshes: boolean;
  22892. /**
  22893. * Stores the animations for the material
  22894. */
  22895. animations: Nullable<Array<Animation>>;
  22896. /**
  22897. * An event triggered when the material is disposed
  22898. */
  22899. onDisposeObservable: Observable<Material>;
  22900. /**
  22901. * An observer which watches for dispose events
  22902. */
  22903. private _onDisposeObserver;
  22904. private _onUnBindObservable;
  22905. /**
  22906. * Called during a dispose event
  22907. */
  22908. onDispose: () => void;
  22909. private _onBindObservable;
  22910. /**
  22911. * An event triggered when the material is bound
  22912. */
  22913. readonly onBindObservable: Observable<AbstractMesh>;
  22914. /**
  22915. * An observer which watches for bind events
  22916. */
  22917. private _onBindObserver;
  22918. /**
  22919. * Called during a bind event
  22920. */
  22921. onBind: (Mesh: AbstractMesh) => void;
  22922. /**
  22923. * An event triggered when the material is unbound
  22924. */
  22925. readonly onUnBindObservable: Observable<Material>;
  22926. /**
  22927. * Stores the value of the alpha mode
  22928. */
  22929. private _alphaMode;
  22930. /**
  22931. * Sets the value of the alpha mode.
  22932. *
  22933. * | Value | Type | Description |
  22934. * | --- | --- | --- |
  22935. * | 0 | ALPHA_DISABLE | |
  22936. * | 1 | ALPHA_ADD | |
  22937. * | 2 | ALPHA_COMBINE | |
  22938. * | 3 | ALPHA_SUBTRACT | |
  22939. * | 4 | ALPHA_MULTIPLY | |
  22940. * | 5 | ALPHA_MAXIMIZED | |
  22941. * | 6 | ALPHA_ONEONE | |
  22942. * | 7 | ALPHA_PREMULTIPLIED | |
  22943. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22944. * | 9 | ALPHA_INTERPOLATE | |
  22945. * | 10 | ALPHA_SCREENMODE | |
  22946. *
  22947. */
  22948. /**
  22949. * Gets the value of the alpha mode
  22950. */
  22951. alphaMode: number;
  22952. /**
  22953. * Stores the state of the need depth pre-pass value
  22954. */
  22955. private _needDepthPrePass;
  22956. /**
  22957. * Sets the need depth pre-pass value
  22958. */
  22959. /**
  22960. * Gets the depth pre-pass value
  22961. */
  22962. needDepthPrePass: boolean;
  22963. /**
  22964. * Specifies if depth writing should be disabled
  22965. */
  22966. disableDepthWrite: boolean;
  22967. /**
  22968. * Specifies if depth writing should be forced
  22969. */
  22970. forceDepthWrite: boolean;
  22971. /**
  22972. * Specifies if there should be a separate pass for culling
  22973. */
  22974. separateCullingPass: boolean;
  22975. /**
  22976. * Stores the state specifing if fog should be enabled
  22977. */
  22978. private _fogEnabled;
  22979. /**
  22980. * Sets the state for enabling fog
  22981. */
  22982. /**
  22983. * Gets the value of the fog enabled state
  22984. */
  22985. fogEnabled: boolean;
  22986. /**
  22987. * Stores the size of points
  22988. */
  22989. pointSize: number;
  22990. /**
  22991. * Stores the z offset value
  22992. */
  22993. zOffset: number;
  22994. /**
  22995. * Gets a value specifying if wireframe mode is enabled
  22996. */
  22997. /**
  22998. * Sets the state of wireframe mode
  22999. */
  23000. wireframe: boolean;
  23001. /**
  23002. * Gets the value specifying if point clouds are enabled
  23003. */
  23004. /**
  23005. * Sets the state of point cloud mode
  23006. */
  23007. pointsCloud: boolean;
  23008. /**
  23009. * Gets the material fill mode
  23010. */
  23011. /**
  23012. * Sets the material fill mode
  23013. */
  23014. fillMode: number;
  23015. /**
  23016. * @hidden
  23017. * Stores the effects for the material
  23018. */
  23019. _effect: Nullable<Effect>;
  23020. /**
  23021. * @hidden
  23022. * Specifies if the material was previously ready
  23023. */
  23024. _wasPreviouslyReady: boolean;
  23025. /**
  23026. * Specifies if uniform buffers should be used
  23027. */
  23028. private _useUBO;
  23029. /**
  23030. * Stores a reference to the scene
  23031. */
  23032. private _scene;
  23033. /**
  23034. * Stores the fill mode state
  23035. */
  23036. private _fillMode;
  23037. /**
  23038. * Specifies if the depth write state should be cached
  23039. */
  23040. private _cachedDepthWriteState;
  23041. /**
  23042. * Stores the uniform buffer
  23043. */
  23044. protected _uniformBuffer: UniformBuffer;
  23045. /** @hidden */
  23046. _indexInSceneMaterialArray: number;
  23047. /** @hidden */
  23048. meshMap: Nullable<{
  23049. [id: string]: AbstractMesh | undefined;
  23050. }>;
  23051. /**
  23052. * Creates a material instance
  23053. * @param name defines the name of the material
  23054. * @param scene defines the scene to reference
  23055. * @param doNotAdd specifies if the material should be added to the scene
  23056. */
  23057. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23058. /**
  23059. * Returns a string representation of the current material
  23060. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23061. * @returns a string with material information
  23062. */
  23063. toString(fullDetails?: boolean): string;
  23064. /**
  23065. * Gets the class name of the material
  23066. * @returns a string with the class name of the material
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Specifies if updates for the material been locked
  23071. */
  23072. readonly isFrozen: boolean;
  23073. /**
  23074. * Locks updates for the material
  23075. */
  23076. freeze(): void;
  23077. /**
  23078. * Unlocks updates for the material
  23079. */
  23080. unfreeze(): void;
  23081. /**
  23082. * Specifies if the material is ready to be used
  23083. * @param mesh defines the mesh to check
  23084. * @param useInstances specifies if instances should be used
  23085. * @returns a boolean indicating if the material is ready to be used
  23086. */
  23087. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23088. /**
  23089. * Specifies that the submesh is ready to be used
  23090. * @param mesh defines the mesh to check
  23091. * @param subMesh defines which submesh to check
  23092. * @param useInstances specifies that instances should be used
  23093. * @returns a boolean indicating that the submesh is ready or not
  23094. */
  23095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23096. /**
  23097. * Returns the material effect
  23098. * @returns the effect associated with the material
  23099. */
  23100. getEffect(): Nullable<Effect>;
  23101. /**
  23102. * Returns the current scene
  23103. * @returns a Scene
  23104. */
  23105. getScene(): Scene;
  23106. /**
  23107. * Specifies if the material will require alpha blending
  23108. * @returns a boolean specifying if alpha blending is needed
  23109. */
  23110. needAlphaBlending(): boolean;
  23111. /**
  23112. * Specifies if the mesh will require alpha blending
  23113. * @param mesh defines the mesh to check
  23114. * @returns a boolean specifying if alpha blending is needed for the mesh
  23115. */
  23116. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23117. /**
  23118. * Specifies if this material should be rendered in alpha test mode
  23119. * @returns a boolean specifying if an alpha test is needed.
  23120. */
  23121. needAlphaTesting(): boolean;
  23122. /**
  23123. * Gets the texture used for the alpha test
  23124. * @returns the texture to use for alpha testing
  23125. */
  23126. getAlphaTestTexture(): Nullable<BaseTexture>;
  23127. /**
  23128. * Marks the material to indicate that it needs to be re-calculated
  23129. */
  23130. markDirty(): void;
  23131. /** @hidden */
  23132. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23133. /**
  23134. * Binds the material to the mesh
  23135. * @param world defines the world transformation matrix
  23136. * @param mesh defines the mesh to bind the material to
  23137. */
  23138. bind(world: Matrix, mesh?: Mesh): void;
  23139. /**
  23140. * Binds the submesh to the material
  23141. * @param world defines the world transformation matrix
  23142. * @param mesh defines the mesh containing the submesh
  23143. * @param subMesh defines the submesh to bind the material to
  23144. */
  23145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23146. /**
  23147. * Binds the world matrix to the material
  23148. * @param world defines the world transformation matrix
  23149. */
  23150. bindOnlyWorldMatrix(world: Matrix): void;
  23151. /**
  23152. * Binds the scene's uniform buffer to the effect.
  23153. * @param effect defines the effect to bind to the scene uniform buffer
  23154. * @param sceneUbo defines the uniform buffer storing scene data
  23155. */
  23156. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23157. /**
  23158. * Binds the view matrix to the effect
  23159. * @param effect defines the effect to bind the view matrix to
  23160. */
  23161. bindView(effect: Effect): void;
  23162. /**
  23163. * Binds the view projection matrix to the effect
  23164. * @param effect defines the effect to bind the view projection matrix to
  23165. */
  23166. bindViewProjection(effect: Effect): void;
  23167. /**
  23168. * Specifies if material alpha testing should be turned on for the mesh
  23169. * @param mesh defines the mesh to check
  23170. */
  23171. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23172. /**
  23173. * Processes to execute after binding the material to a mesh
  23174. * @param mesh defines the rendered mesh
  23175. */
  23176. protected _afterBind(mesh?: Mesh): void;
  23177. /**
  23178. * Unbinds the material from the mesh
  23179. */
  23180. unbind(): void;
  23181. /**
  23182. * Gets the active textures from the material
  23183. * @returns an array of textures
  23184. */
  23185. getActiveTextures(): BaseTexture[];
  23186. /**
  23187. * Specifies if the material uses a texture
  23188. * @param texture defines the texture to check against the material
  23189. * @returns a boolean specifying if the material uses the texture
  23190. */
  23191. hasTexture(texture: BaseTexture): boolean;
  23192. /**
  23193. * Makes a duplicate of the material, and gives it a new name
  23194. * @param name defines the new name for the duplicated material
  23195. * @returns the cloned material
  23196. */
  23197. clone(name: string): Nullable<Material>;
  23198. /**
  23199. * Gets the meshes bound to the material
  23200. * @returns an array of meshes bound to the material
  23201. */
  23202. getBindedMeshes(): AbstractMesh[];
  23203. /**
  23204. * Force shader compilation
  23205. * @param mesh defines the mesh associated with this material
  23206. * @param onCompiled defines a function to execute once the material is compiled
  23207. * @param options defines the options to configure the compilation
  23208. */
  23209. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23210. clipPlane: boolean;
  23211. }>): void;
  23212. /**
  23213. * Force shader compilation
  23214. * @param mesh defines the mesh that will use this material
  23215. * @param options defines additional options for compiling the shaders
  23216. * @returns a promise that resolves when the compilation completes
  23217. */
  23218. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23219. clipPlane: boolean;
  23220. }>): Promise<void>;
  23221. private static readonly _AllDirtyCallBack;
  23222. private static readonly _ImageProcessingDirtyCallBack;
  23223. private static readonly _TextureDirtyCallBack;
  23224. private static readonly _FresnelDirtyCallBack;
  23225. private static readonly _MiscDirtyCallBack;
  23226. private static readonly _LightsDirtyCallBack;
  23227. private static readonly _AttributeDirtyCallBack;
  23228. private static _FresnelAndMiscDirtyCallBack;
  23229. private static _TextureAndMiscDirtyCallBack;
  23230. private static readonly _DirtyCallbackArray;
  23231. private static readonly _RunDirtyCallBacks;
  23232. /**
  23233. * Marks a define in the material to indicate that it needs to be re-computed
  23234. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23235. */
  23236. markAsDirty(flag: number): void;
  23237. /**
  23238. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23239. * @param func defines a function which checks material defines against the submeshes
  23240. */
  23241. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23242. /**
  23243. * Indicates that we need to re-calculated for all submeshes
  23244. */
  23245. protected _markAllSubMeshesAsAllDirty(): void;
  23246. /**
  23247. * Indicates that image processing needs to be re-calculated for all submeshes
  23248. */
  23249. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23250. /**
  23251. * Indicates that textures need to be re-calculated for all submeshes
  23252. */
  23253. protected _markAllSubMeshesAsTexturesDirty(): void;
  23254. /**
  23255. * Indicates that fresnel needs to be re-calculated for all submeshes
  23256. */
  23257. protected _markAllSubMeshesAsFresnelDirty(): void;
  23258. /**
  23259. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23260. */
  23261. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23262. /**
  23263. * Indicates that lights need to be re-calculated for all submeshes
  23264. */
  23265. protected _markAllSubMeshesAsLightsDirty(): void;
  23266. /**
  23267. * Indicates that attributes need to be re-calculated for all submeshes
  23268. */
  23269. protected _markAllSubMeshesAsAttributesDirty(): void;
  23270. /**
  23271. * Indicates that misc needs to be re-calculated for all submeshes
  23272. */
  23273. protected _markAllSubMeshesAsMiscDirty(): void;
  23274. /**
  23275. * Indicates that textures and misc need to be re-calculated for all submeshes
  23276. */
  23277. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23278. /**
  23279. * Disposes the material
  23280. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23281. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23282. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23283. */
  23284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23285. /** @hidden */
  23286. private releaseVertexArrayObject;
  23287. /**
  23288. * Serializes this material
  23289. * @returns the serialized material object
  23290. */
  23291. serialize(): any;
  23292. /**
  23293. * Creates a material from parsed material data
  23294. * @param parsedMaterial defines parsed material data
  23295. * @param scene defines the hosting scene
  23296. * @param rootUrl defines the root URL to use to load textures
  23297. * @returns a new material
  23298. */
  23299. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23300. }
  23301. }
  23302. declare module "babylonjs/Meshes/subMesh" {
  23303. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23304. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23305. import { Engine } from "babylonjs/Engines/engine";
  23306. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23307. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23308. import { Effect } from "babylonjs/Materials/effect";
  23309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23310. import { Collider } from "babylonjs/Collisions/collider";
  23311. import { Material } from "babylonjs/Materials/material";
  23312. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23314. import { Mesh } from "babylonjs/Meshes/mesh";
  23315. import { Ray } from "babylonjs/Culling/ray";
  23316. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23317. /**
  23318. * Base class for submeshes
  23319. */
  23320. export class BaseSubMesh {
  23321. /** @hidden */
  23322. _materialDefines: Nullable<MaterialDefines>;
  23323. /** @hidden */
  23324. _materialEffect: Nullable<Effect>;
  23325. /**
  23326. * Gets associated effect
  23327. */
  23328. readonly effect: Nullable<Effect>;
  23329. /**
  23330. * Sets associated effect (effect used to render this submesh)
  23331. * @param effect defines the effect to associate with
  23332. * @param defines defines the set of defines used to compile this effect
  23333. */
  23334. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23335. }
  23336. /**
  23337. * Defines a subdivision inside a mesh
  23338. */
  23339. export class SubMesh extends BaseSubMesh implements ICullable {
  23340. /** the material index to use */
  23341. materialIndex: number;
  23342. /** vertex index start */
  23343. verticesStart: number;
  23344. /** vertices count */
  23345. verticesCount: number;
  23346. /** index start */
  23347. indexStart: number;
  23348. /** indices count */
  23349. indexCount: number;
  23350. /** @hidden */
  23351. _linesIndexCount: number;
  23352. private _mesh;
  23353. private _renderingMesh;
  23354. private _boundingInfo;
  23355. private _linesIndexBuffer;
  23356. /** @hidden */
  23357. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23358. /** @hidden */
  23359. _trianglePlanes: Plane[];
  23360. /** @hidden */
  23361. _lastColliderTransformMatrix: Nullable<Matrix>;
  23362. /** @hidden */
  23363. _renderId: number;
  23364. /** @hidden */
  23365. _alphaIndex: number;
  23366. /** @hidden */
  23367. _distanceToCamera: number;
  23368. /** @hidden */
  23369. _id: number;
  23370. private _currentMaterial;
  23371. /**
  23372. * Add a new submesh to a mesh
  23373. * @param materialIndex defines the material index to use
  23374. * @param verticesStart defines vertex index start
  23375. * @param verticesCount defines vertices count
  23376. * @param indexStart defines index start
  23377. * @param indexCount defines indices count
  23378. * @param mesh defines the parent mesh
  23379. * @param renderingMesh defines an optional rendering mesh
  23380. * @param createBoundingBox defines if bounding box should be created for this submesh
  23381. * @returns the new submesh
  23382. */
  23383. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23384. /**
  23385. * Creates a new submesh
  23386. * @param materialIndex defines the material index to use
  23387. * @param verticesStart defines vertex index start
  23388. * @param verticesCount defines vertices count
  23389. * @param indexStart defines index start
  23390. * @param indexCount defines indices count
  23391. * @param mesh defines the parent mesh
  23392. * @param renderingMesh defines an optional rendering mesh
  23393. * @param createBoundingBox defines if bounding box should be created for this submesh
  23394. */
  23395. constructor(
  23396. /** the material index to use */
  23397. materialIndex: number,
  23398. /** vertex index start */
  23399. verticesStart: number,
  23400. /** vertices count */
  23401. verticesCount: number,
  23402. /** index start */
  23403. indexStart: number,
  23404. /** indices count */
  23405. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23406. /**
  23407. * Returns true if this submesh covers the entire parent mesh
  23408. * @ignorenaming
  23409. */
  23410. readonly IsGlobal: boolean;
  23411. /**
  23412. * Returns the submesh BoudingInfo object
  23413. * @returns current bounding info (or mesh's one if the submesh is global)
  23414. */
  23415. getBoundingInfo(): BoundingInfo;
  23416. /**
  23417. * Sets the submesh BoundingInfo
  23418. * @param boundingInfo defines the new bounding info to use
  23419. * @returns the SubMesh
  23420. */
  23421. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23422. /**
  23423. * Returns the mesh of the current submesh
  23424. * @return the parent mesh
  23425. */
  23426. getMesh(): AbstractMesh;
  23427. /**
  23428. * Returns the rendering mesh of the submesh
  23429. * @returns the rendering mesh (could be different from parent mesh)
  23430. */
  23431. getRenderingMesh(): Mesh;
  23432. /**
  23433. * Returns the submesh material
  23434. * @returns null or the current material
  23435. */
  23436. getMaterial(): Nullable<Material>;
  23437. /**
  23438. * Sets a new updated BoundingInfo object to the submesh
  23439. * @param data defines an optional position array to use to determine the bounding info
  23440. * @returns the SubMesh
  23441. */
  23442. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23443. /** @hidden */
  23444. _checkCollision(collider: Collider): boolean;
  23445. /**
  23446. * Updates the submesh BoundingInfo
  23447. * @param world defines the world matrix to use to update the bounding info
  23448. * @returns the submesh
  23449. */
  23450. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23451. /**
  23452. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23453. * @param frustumPlanes defines the frustum planes
  23454. * @returns true if the submesh is intersecting with the frustum
  23455. */
  23456. isInFrustum(frustumPlanes: Plane[]): boolean;
  23457. /**
  23458. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23459. * @param frustumPlanes defines the frustum planes
  23460. * @returns true if the submesh is inside the frustum
  23461. */
  23462. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23463. /**
  23464. * Renders the submesh
  23465. * @param enableAlphaMode defines if alpha needs to be used
  23466. * @returns the submesh
  23467. */
  23468. render(enableAlphaMode: boolean): SubMesh;
  23469. /**
  23470. * @hidden
  23471. */
  23472. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23473. /**
  23474. * Checks if the submesh intersects with a ray
  23475. * @param ray defines the ray to test
  23476. * @returns true is the passed ray intersects the submesh bounding box
  23477. */
  23478. canIntersects(ray: Ray): boolean;
  23479. /**
  23480. * Intersects current submesh with a ray
  23481. * @param ray defines the ray to test
  23482. * @param positions defines mesh's positions array
  23483. * @param indices defines mesh's indices array
  23484. * @param fastCheck defines if only bounding info should be used
  23485. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23486. * @returns intersection info or null if no intersection
  23487. */
  23488. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23489. /** @hidden */
  23490. private _intersectLines;
  23491. /** @hidden */
  23492. private _intersectUnIndexedLines;
  23493. /** @hidden */
  23494. private _intersectTriangles;
  23495. /** @hidden */
  23496. private _intersectUnIndexedTriangles;
  23497. /** @hidden */
  23498. _rebuild(): void;
  23499. /**
  23500. * Creates a new submesh from the passed mesh
  23501. * @param newMesh defines the new hosting mesh
  23502. * @param newRenderingMesh defines an optional rendering mesh
  23503. * @returns the new submesh
  23504. */
  23505. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23506. /**
  23507. * Release associated resources
  23508. */
  23509. dispose(): void;
  23510. /**
  23511. * Gets the class name
  23512. * @returns the string "SubMesh".
  23513. */
  23514. getClassName(): string;
  23515. /**
  23516. * Creates a new submesh from indices data
  23517. * @param materialIndex the index of the main mesh material
  23518. * @param startIndex the index where to start the copy in the mesh indices array
  23519. * @param indexCount the number of indices to copy then from the startIndex
  23520. * @param mesh the main mesh to create the submesh from
  23521. * @param renderingMesh the optional rendering mesh
  23522. * @returns a new submesh
  23523. */
  23524. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23525. }
  23526. }
  23527. declare module "babylonjs/Meshes/geometry" {
  23528. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23529. import { Scene } from "babylonjs/scene";
  23530. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23531. import { Engine } from "babylonjs/Engines/engine";
  23532. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23533. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23534. import { Effect } from "babylonjs/Materials/effect";
  23535. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23536. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23537. import { Mesh } from "babylonjs/Meshes/mesh";
  23538. /**
  23539. * Class used to store geometry data (vertex buffers + index buffer)
  23540. */
  23541. export class Geometry implements IGetSetVerticesData {
  23542. /**
  23543. * Gets or sets the ID of the geometry
  23544. */
  23545. id: string;
  23546. /**
  23547. * Gets or sets the unique ID of the geometry
  23548. */
  23549. uniqueId: number;
  23550. /**
  23551. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23552. */
  23553. delayLoadState: number;
  23554. /**
  23555. * Gets the file containing the data to load when running in delay load state
  23556. */
  23557. delayLoadingFile: Nullable<string>;
  23558. /**
  23559. * Callback called when the geometry is updated
  23560. */
  23561. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23562. private _scene;
  23563. private _engine;
  23564. private _meshes;
  23565. private _totalVertices;
  23566. /** @hidden */
  23567. _indices: IndicesArray;
  23568. /** @hidden */
  23569. _vertexBuffers: {
  23570. [key: string]: VertexBuffer;
  23571. };
  23572. private _isDisposed;
  23573. private _extend;
  23574. private _boundingBias;
  23575. /** @hidden */
  23576. _delayInfo: Array<string>;
  23577. private _indexBuffer;
  23578. private _indexBufferIsUpdatable;
  23579. /** @hidden */
  23580. _boundingInfo: Nullable<BoundingInfo>;
  23581. /** @hidden */
  23582. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23583. /** @hidden */
  23584. _softwareSkinningFrameId: number;
  23585. private _vertexArrayObjects;
  23586. private _updatable;
  23587. /** @hidden */
  23588. _positions: Nullable<Vector3[]>;
  23589. /**
  23590. * 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
  23591. */
  23592. /**
  23593. * 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
  23594. */
  23595. boundingBias: Vector2;
  23596. /**
  23597. * Static function used to attach a new empty geometry to a mesh
  23598. * @param mesh defines the mesh to attach the geometry to
  23599. * @returns the new Geometry
  23600. */
  23601. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23602. /**
  23603. * Creates a new geometry
  23604. * @param id defines the unique ID
  23605. * @param scene defines the hosting scene
  23606. * @param vertexData defines the VertexData used to get geometry data
  23607. * @param updatable defines if geometry must be updatable (false by default)
  23608. * @param mesh defines the mesh that will be associated with the geometry
  23609. */
  23610. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23611. /**
  23612. * Gets the current extend of the geometry
  23613. */
  23614. readonly extend: {
  23615. minimum: Vector3;
  23616. maximum: Vector3;
  23617. };
  23618. /**
  23619. * Gets the hosting scene
  23620. * @returns the hosting Scene
  23621. */
  23622. getScene(): Scene;
  23623. /**
  23624. * Gets the hosting engine
  23625. * @returns the hosting Engine
  23626. */
  23627. getEngine(): Engine;
  23628. /**
  23629. * Defines if the geometry is ready to use
  23630. * @returns true if the geometry is ready to be used
  23631. */
  23632. isReady(): boolean;
  23633. /**
  23634. * Gets a value indicating that the geometry should not be serialized
  23635. */
  23636. readonly doNotSerialize: boolean;
  23637. /** @hidden */
  23638. _rebuild(): void;
  23639. /**
  23640. * Affects all geometry data in one call
  23641. * @param vertexData defines the geometry data
  23642. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23643. */
  23644. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23645. /**
  23646. * Set specific vertex data
  23647. * @param kind defines the data kind (Position, normal, etc...)
  23648. * @param data defines the vertex data to use
  23649. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23650. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23651. */
  23652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23653. /**
  23654. * Removes a specific vertex data
  23655. * @param kind defines the data kind (Position, normal, etc...)
  23656. */
  23657. removeVerticesData(kind: string): void;
  23658. /**
  23659. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23660. * @param buffer defines the vertex buffer to use
  23661. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23662. */
  23663. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23664. /**
  23665. * Update a specific vertex buffer
  23666. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23667. * It will do nothing if the buffer is not updatable
  23668. * @param kind defines the data kind (Position, normal, etc...)
  23669. * @param data defines the data to use
  23670. * @param offset defines the offset in the target buffer where to store the data
  23671. * @param useBytes set to true if the offset is in bytes
  23672. */
  23673. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23674. /**
  23675. * Update a specific vertex buffer
  23676. * This function will create a new buffer if the current one is not updatable
  23677. * @param kind defines the data kind (Position, normal, etc...)
  23678. * @param data defines the data to use
  23679. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23680. */
  23681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23682. private _updateBoundingInfo;
  23683. /** @hidden */
  23684. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23685. /**
  23686. * Gets total number of vertices
  23687. * @returns the total number of vertices
  23688. */
  23689. getTotalVertices(): number;
  23690. /**
  23691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23692. * @param kind defines the data kind (Position, normal, etc...)
  23693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23695. * @returns a float array containing vertex data
  23696. */
  23697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23698. /**
  23699. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23700. * @param kind defines the data kind (Position, normal, etc...)
  23701. * @returns true if the vertex buffer with the specified kind is updatable
  23702. */
  23703. isVertexBufferUpdatable(kind: string): boolean;
  23704. /**
  23705. * Gets a specific vertex buffer
  23706. * @param kind defines the data kind (Position, normal, etc...)
  23707. * @returns a VertexBuffer
  23708. */
  23709. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23710. /**
  23711. * Returns all vertex buffers
  23712. * @return an object holding all vertex buffers indexed by kind
  23713. */
  23714. getVertexBuffers(): Nullable<{
  23715. [key: string]: VertexBuffer;
  23716. }>;
  23717. /**
  23718. * Gets a boolean indicating if specific vertex buffer is present
  23719. * @param kind defines the data kind (Position, normal, etc...)
  23720. * @returns true if data is present
  23721. */
  23722. isVerticesDataPresent(kind: string): boolean;
  23723. /**
  23724. * Gets a list of all attached data kinds (Position, normal, etc...)
  23725. * @returns a list of string containing all kinds
  23726. */
  23727. getVerticesDataKinds(): string[];
  23728. /**
  23729. * Update index buffer
  23730. * @param indices defines the indices to store in the index buffer
  23731. * @param offset defines the offset in the target buffer where to store the data
  23732. * @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)
  23733. */
  23734. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23735. /**
  23736. * Creates a new index buffer
  23737. * @param indices defines the indices to store in the index buffer
  23738. * @param totalVertices defines the total number of vertices (could be null)
  23739. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23740. */
  23741. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23742. /**
  23743. * Return the total number of indices
  23744. * @returns the total number of indices
  23745. */
  23746. getTotalIndices(): number;
  23747. /**
  23748. * Gets the index buffer array
  23749. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23750. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23751. * @returns the index buffer array
  23752. */
  23753. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23754. /**
  23755. * Gets the index buffer
  23756. * @return the index buffer
  23757. */
  23758. getIndexBuffer(): Nullable<DataBuffer>;
  23759. /** @hidden */
  23760. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23761. /**
  23762. * Release the associated resources for a specific mesh
  23763. * @param mesh defines the source mesh
  23764. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23765. */
  23766. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23767. /**
  23768. * Apply current geometry to a given mesh
  23769. * @param mesh defines the mesh to apply geometry to
  23770. */
  23771. applyToMesh(mesh: Mesh): void;
  23772. private _updateExtend;
  23773. private _applyToMesh;
  23774. private notifyUpdate;
  23775. /**
  23776. * Load the geometry if it was flagged as delay loaded
  23777. * @param scene defines the hosting scene
  23778. * @param onLoaded defines a callback called when the geometry is loaded
  23779. */
  23780. load(scene: Scene, onLoaded?: () => void): void;
  23781. private _queueLoad;
  23782. /**
  23783. * Invert the geometry to move from a right handed system to a left handed one.
  23784. */
  23785. toLeftHanded(): void;
  23786. /** @hidden */
  23787. _resetPointsArrayCache(): void;
  23788. /** @hidden */
  23789. _generatePointsArray(): boolean;
  23790. /**
  23791. * Gets a value indicating if the geometry is disposed
  23792. * @returns true if the geometry was disposed
  23793. */
  23794. isDisposed(): boolean;
  23795. private _disposeVertexArrayObjects;
  23796. /**
  23797. * Free all associated resources
  23798. */
  23799. dispose(): void;
  23800. /**
  23801. * Clone the current geometry into a new geometry
  23802. * @param id defines the unique ID of the new geometry
  23803. * @returns a new geometry object
  23804. */
  23805. copy(id: string): Geometry;
  23806. /**
  23807. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23808. * @return a JSON representation of the current geometry data (without the vertices data)
  23809. */
  23810. serialize(): any;
  23811. private toNumberArray;
  23812. /**
  23813. * Serialize all vertices data into a JSON oject
  23814. * @returns a JSON representation of the current geometry data
  23815. */
  23816. serializeVerticeData(): any;
  23817. /**
  23818. * Extracts a clone of a mesh geometry
  23819. * @param mesh defines the source mesh
  23820. * @param id defines the unique ID of the new geometry object
  23821. * @returns the new geometry object
  23822. */
  23823. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23824. /**
  23825. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23827. * Be aware Math.random() could cause collisions, but:
  23828. * "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"
  23829. * @returns a string containing a new GUID
  23830. */
  23831. static RandomId(): string;
  23832. /** @hidden */
  23833. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23834. private static _CleanMatricesWeights;
  23835. /**
  23836. * Create a new geometry from persisted data (Using .babylon file format)
  23837. * @param parsedVertexData defines the persisted data
  23838. * @param scene defines the hosting scene
  23839. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23840. * @returns the new geometry object
  23841. */
  23842. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23843. }
  23844. }
  23845. declare module "babylonjs/Meshes/mesh.vertexData" {
  23846. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23847. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23848. import { Geometry } from "babylonjs/Meshes/geometry";
  23849. import { Mesh } from "babylonjs/Meshes/mesh";
  23850. /**
  23851. * Define an interface for all classes that will get and set the data on vertices
  23852. */
  23853. export interface IGetSetVerticesData {
  23854. /**
  23855. * Gets a boolean indicating if specific vertex data is present
  23856. * @param kind defines the vertex data kind to use
  23857. * @returns true is data kind is present
  23858. */
  23859. isVerticesDataPresent(kind: string): boolean;
  23860. /**
  23861. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23862. * @param kind defines the data kind (Position, normal, etc...)
  23863. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23865. * @returns a float array containing vertex data
  23866. */
  23867. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23868. /**
  23869. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23870. * @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.
  23871. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23872. * @returns the indices array or an empty array if the mesh has no geometry
  23873. */
  23874. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23875. /**
  23876. * Set specific vertex data
  23877. * @param kind defines the data kind (Position, normal, etc...)
  23878. * @param data defines the vertex data to use
  23879. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23880. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23881. */
  23882. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23883. /**
  23884. * Update a specific associated vertex buffer
  23885. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23886. * - VertexBuffer.PositionKind
  23887. * - VertexBuffer.UVKind
  23888. * - VertexBuffer.UV2Kind
  23889. * - VertexBuffer.UV3Kind
  23890. * - VertexBuffer.UV4Kind
  23891. * - VertexBuffer.UV5Kind
  23892. * - VertexBuffer.UV6Kind
  23893. * - VertexBuffer.ColorKind
  23894. * - VertexBuffer.MatricesIndicesKind
  23895. * - VertexBuffer.MatricesIndicesExtraKind
  23896. * - VertexBuffer.MatricesWeightsKind
  23897. * - VertexBuffer.MatricesWeightsExtraKind
  23898. * @param data defines the data source
  23899. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23900. * @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)
  23901. */
  23902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23903. /**
  23904. * Creates a new index buffer
  23905. * @param indices defines the indices to store in the index buffer
  23906. * @param totalVertices defines the total number of vertices (could be null)
  23907. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23908. */
  23909. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23910. }
  23911. /**
  23912. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23913. */
  23914. export class VertexData {
  23915. /**
  23916. * Mesh side orientation : usually the external or front surface
  23917. */
  23918. static readonly FRONTSIDE: number;
  23919. /**
  23920. * Mesh side orientation : usually the internal or back surface
  23921. */
  23922. static readonly BACKSIDE: number;
  23923. /**
  23924. * Mesh side orientation : both internal and external or front and back surfaces
  23925. */
  23926. static readonly DOUBLESIDE: number;
  23927. /**
  23928. * Mesh side orientation : by default, `FRONTSIDE`
  23929. */
  23930. static readonly DEFAULTSIDE: number;
  23931. /**
  23932. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23933. */
  23934. positions: Nullable<FloatArray>;
  23935. /**
  23936. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23937. */
  23938. normals: Nullable<FloatArray>;
  23939. /**
  23940. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23941. */
  23942. tangents: Nullable<FloatArray>;
  23943. /**
  23944. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23945. */
  23946. uvs: Nullable<FloatArray>;
  23947. /**
  23948. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23949. */
  23950. uvs2: Nullable<FloatArray>;
  23951. /**
  23952. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23953. */
  23954. uvs3: Nullable<FloatArray>;
  23955. /**
  23956. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23957. */
  23958. uvs4: Nullable<FloatArray>;
  23959. /**
  23960. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23961. */
  23962. uvs5: Nullable<FloatArray>;
  23963. /**
  23964. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23965. */
  23966. uvs6: Nullable<FloatArray>;
  23967. /**
  23968. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23969. */
  23970. colors: Nullable<FloatArray>;
  23971. /**
  23972. * 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).
  23973. */
  23974. matricesIndices: Nullable<FloatArray>;
  23975. /**
  23976. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23977. */
  23978. matricesWeights: Nullable<FloatArray>;
  23979. /**
  23980. * An array extending the number of possible indices
  23981. */
  23982. matricesIndicesExtra: Nullable<FloatArray>;
  23983. /**
  23984. * An array extending the number of possible weights when the number of indices is extended
  23985. */
  23986. matricesWeightsExtra: Nullable<FloatArray>;
  23987. /**
  23988. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23989. */
  23990. indices: Nullable<IndicesArray>;
  23991. /**
  23992. * Uses the passed data array to set the set the values for the specified kind of data
  23993. * @param data a linear array of floating numbers
  23994. * @param kind the type of data that is being set, eg positions, colors etc
  23995. */
  23996. set(data: FloatArray, kind: string): void;
  23997. /**
  23998. * Associates the vertexData to the passed Mesh.
  23999. * Sets it as updatable or not (default `false`)
  24000. * @param mesh the mesh the vertexData is applied to
  24001. * @param updatable when used and having the value true allows new data to update the vertexData
  24002. * @returns the VertexData
  24003. */
  24004. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24005. /**
  24006. * Associates the vertexData to the passed Geometry.
  24007. * Sets it as updatable or not (default `false`)
  24008. * @param geometry the geometry the vertexData is applied to
  24009. * @param updatable when used and having the value true allows new data to update the vertexData
  24010. * @returns VertexData
  24011. */
  24012. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24013. /**
  24014. * Updates the associated mesh
  24015. * @param mesh the mesh to be updated
  24016. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24017. * @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
  24018. * @returns VertexData
  24019. */
  24020. updateMesh(mesh: Mesh): VertexData;
  24021. /**
  24022. * Updates the associated geometry
  24023. * @param geometry the geometry to be updated
  24024. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24025. * @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
  24026. * @returns VertexData.
  24027. */
  24028. updateGeometry(geometry: Geometry): VertexData;
  24029. private _applyTo;
  24030. private _update;
  24031. /**
  24032. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24033. * @param matrix the transforming matrix
  24034. * @returns the VertexData
  24035. */
  24036. transform(matrix: Matrix): VertexData;
  24037. /**
  24038. * Merges the passed VertexData into the current one
  24039. * @param other the VertexData to be merged into the current one
  24040. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24041. * @returns the modified VertexData
  24042. */
  24043. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24044. private _mergeElement;
  24045. private _validate;
  24046. /**
  24047. * Serializes the VertexData
  24048. * @returns a serialized object
  24049. */
  24050. serialize(): any;
  24051. /**
  24052. * Extracts the vertexData from a mesh
  24053. * @param mesh the mesh from which to extract the VertexData
  24054. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24055. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24056. * @returns the object VertexData associated to the passed mesh
  24057. */
  24058. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24059. /**
  24060. * Extracts the vertexData from the geometry
  24061. * @param geometry the geometry from which to extract the VertexData
  24062. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24063. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24064. * @returns the object VertexData associated to the passed mesh
  24065. */
  24066. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24067. private static _ExtractFrom;
  24068. /**
  24069. * Creates the VertexData for a Ribbon
  24070. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24071. * * pathArray array of paths, each of which an array of successive Vector3
  24072. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24073. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24074. * * 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
  24075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24076. * * 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)
  24077. * * 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)
  24078. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24079. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24080. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24081. * @returns the VertexData of the ribbon
  24082. */
  24083. static CreateRibbon(options: {
  24084. pathArray: Vector3[][];
  24085. closeArray?: boolean;
  24086. closePath?: boolean;
  24087. offset?: number;
  24088. sideOrientation?: number;
  24089. frontUVs?: Vector4;
  24090. backUVs?: Vector4;
  24091. invertUV?: boolean;
  24092. uvs?: Vector2[];
  24093. colors?: Color4[];
  24094. }): VertexData;
  24095. /**
  24096. * Creates the VertexData for a box
  24097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24098. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24099. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24100. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24101. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24102. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24103. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24104. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24105. * * 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)
  24106. * * 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)
  24107. * @returns the VertexData of the box
  24108. */
  24109. static CreateBox(options: {
  24110. size?: number;
  24111. width?: number;
  24112. height?: number;
  24113. depth?: number;
  24114. faceUV?: Vector4[];
  24115. faceColors?: Color4[];
  24116. sideOrientation?: number;
  24117. frontUVs?: Vector4;
  24118. backUVs?: Vector4;
  24119. }): VertexData;
  24120. /**
  24121. * Creates the VertexData for a tiled box
  24122. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24123. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24124. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24125. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24127. * @returns the VertexData of the box
  24128. */
  24129. static CreateTiledBox(options: {
  24130. pattern?: number;
  24131. width?: number;
  24132. height?: number;
  24133. depth?: number;
  24134. tileSize?: number;
  24135. tileWidth?: number;
  24136. tileHeight?: number;
  24137. alignHorizontal?: number;
  24138. alignVertical?: number;
  24139. faceUV?: Vector4[];
  24140. faceColors?: Color4[];
  24141. sideOrientation?: number;
  24142. }): VertexData;
  24143. /**
  24144. * Creates the VertexData for a tiled plane
  24145. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24146. * * pattern a limited pattern arrangement depending on the number
  24147. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24148. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24149. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24151. * * 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)
  24152. * * 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)
  24153. * @returns the VertexData of the tiled plane
  24154. */
  24155. static CreateTiledPlane(options: {
  24156. pattern?: number;
  24157. tileSize?: number;
  24158. tileWidth?: number;
  24159. tileHeight?: number;
  24160. size?: number;
  24161. width?: number;
  24162. height?: number;
  24163. alignHorizontal?: number;
  24164. alignVertical?: number;
  24165. sideOrientation?: number;
  24166. frontUVs?: Vector4;
  24167. backUVs?: Vector4;
  24168. }): VertexData;
  24169. /**
  24170. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24172. * * segments sets the number of horizontal strips optional, default 32
  24173. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24174. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24175. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24176. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24177. * * 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
  24178. * * 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
  24179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24180. * * 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)
  24181. * * 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)
  24182. * @returns the VertexData of the ellipsoid
  24183. */
  24184. static CreateSphere(options: {
  24185. segments?: number;
  24186. diameter?: number;
  24187. diameterX?: number;
  24188. diameterY?: number;
  24189. diameterZ?: number;
  24190. arc?: number;
  24191. slice?: number;
  24192. sideOrientation?: number;
  24193. frontUVs?: Vector4;
  24194. backUVs?: Vector4;
  24195. }): VertexData;
  24196. /**
  24197. * Creates the VertexData for a cylinder, cone or prism
  24198. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24199. * * height sets the height (y direction) of the cylinder, optional, default 2
  24200. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24201. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24202. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24204. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24205. * * 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
  24206. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24207. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24208. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24209. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24211. * * 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)
  24212. * * 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)
  24213. * @returns the VertexData of the cylinder, cone or prism
  24214. */
  24215. static CreateCylinder(options: {
  24216. height?: number;
  24217. diameterTop?: number;
  24218. diameterBottom?: number;
  24219. diameter?: number;
  24220. tessellation?: number;
  24221. subdivisions?: number;
  24222. arc?: number;
  24223. faceColors?: Color4[];
  24224. faceUV?: Vector4[];
  24225. hasRings?: boolean;
  24226. enclose?: boolean;
  24227. sideOrientation?: number;
  24228. frontUVs?: Vector4;
  24229. backUVs?: Vector4;
  24230. }): VertexData;
  24231. /**
  24232. * Creates the VertexData for a torus
  24233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24234. * * diameter the diameter of the torus, optional default 1
  24235. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24236. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24238. * * 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)
  24239. * * 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)
  24240. * @returns the VertexData of the torus
  24241. */
  24242. static CreateTorus(options: {
  24243. diameter?: number;
  24244. thickness?: number;
  24245. tessellation?: number;
  24246. sideOrientation?: number;
  24247. frontUVs?: Vector4;
  24248. backUVs?: Vector4;
  24249. }): VertexData;
  24250. /**
  24251. * Creates the VertexData of the LineSystem
  24252. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24253. * - lines an array of lines, each line being an array of successive Vector3
  24254. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24255. * @returns the VertexData of the LineSystem
  24256. */
  24257. static CreateLineSystem(options: {
  24258. lines: Vector3[][];
  24259. colors?: Nullable<Color4[][]>;
  24260. }): VertexData;
  24261. /**
  24262. * Create the VertexData for a DashedLines
  24263. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24264. * - points an array successive Vector3
  24265. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24266. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24267. * - dashNb the intended total number of dashes, optional, default 200
  24268. * @returns the VertexData for the DashedLines
  24269. */
  24270. static CreateDashedLines(options: {
  24271. points: Vector3[];
  24272. dashSize?: number;
  24273. gapSize?: number;
  24274. dashNb?: number;
  24275. }): VertexData;
  24276. /**
  24277. * Creates the VertexData for a Ground
  24278. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24279. * - width the width (x direction) of the ground, optional, default 1
  24280. * - height the height (z direction) of the ground, optional, default 1
  24281. * - subdivisions the number of subdivisions per side, optional, default 1
  24282. * @returns the VertexData of the Ground
  24283. */
  24284. static CreateGround(options: {
  24285. width?: number;
  24286. height?: number;
  24287. subdivisions?: number;
  24288. subdivisionsX?: number;
  24289. subdivisionsY?: number;
  24290. }): VertexData;
  24291. /**
  24292. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24293. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24294. * * xmin the ground minimum X coordinate, optional, default -1
  24295. * * zmin the ground minimum Z coordinate, optional, default -1
  24296. * * xmax the ground maximum X coordinate, optional, default 1
  24297. * * zmax the ground maximum Z coordinate, optional, default 1
  24298. * * 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}
  24299. * * 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}
  24300. * @returns the VertexData of the TiledGround
  24301. */
  24302. static CreateTiledGround(options: {
  24303. xmin: number;
  24304. zmin: number;
  24305. xmax: number;
  24306. zmax: number;
  24307. subdivisions?: {
  24308. w: number;
  24309. h: number;
  24310. };
  24311. precision?: {
  24312. w: number;
  24313. h: number;
  24314. };
  24315. }): VertexData;
  24316. /**
  24317. * Creates the VertexData of the Ground designed from a heightmap
  24318. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24319. * * width the width (x direction) of the ground
  24320. * * height the height (z direction) of the ground
  24321. * * subdivisions the number of subdivisions per side
  24322. * * minHeight the minimum altitude on the ground, optional, default 0
  24323. * * maxHeight the maximum altitude on the ground, optional default 1
  24324. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24325. * * buffer the array holding the image color data
  24326. * * bufferWidth the width of image
  24327. * * bufferHeight the height of image
  24328. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24329. * @returns the VertexData of the Ground designed from a heightmap
  24330. */
  24331. static CreateGroundFromHeightMap(options: {
  24332. width: number;
  24333. height: number;
  24334. subdivisions: number;
  24335. minHeight: number;
  24336. maxHeight: number;
  24337. colorFilter: Color3;
  24338. buffer: Uint8Array;
  24339. bufferWidth: number;
  24340. bufferHeight: number;
  24341. alphaFilter: number;
  24342. }): VertexData;
  24343. /**
  24344. * Creates the VertexData for a Plane
  24345. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24346. * * size sets the width and height of the plane to the value of size, optional default 1
  24347. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24348. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24350. * * 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)
  24351. * * 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)
  24352. * @returns the VertexData of the box
  24353. */
  24354. static CreatePlane(options: {
  24355. size?: number;
  24356. width?: number;
  24357. height?: number;
  24358. sideOrientation?: number;
  24359. frontUVs?: Vector4;
  24360. backUVs?: Vector4;
  24361. }): VertexData;
  24362. /**
  24363. * Creates the VertexData of the Disc or regular Polygon
  24364. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24365. * * radius the radius of the disc, optional default 0.5
  24366. * * tessellation the number of polygon sides, optional, default 64
  24367. * * 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
  24368. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * * 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)
  24370. * * 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)
  24371. * @returns the VertexData of the box
  24372. */
  24373. static CreateDisc(options: {
  24374. radius?: number;
  24375. tessellation?: number;
  24376. arc?: number;
  24377. sideOrientation?: number;
  24378. frontUVs?: Vector4;
  24379. backUVs?: Vector4;
  24380. }): VertexData;
  24381. /**
  24382. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24383. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24384. * @param polygon a mesh built from polygonTriangulation.build()
  24385. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24386. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24387. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24388. * @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)
  24389. * @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)
  24390. * @returns the VertexData of the Polygon
  24391. */
  24392. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24393. /**
  24394. * Creates the VertexData of the IcoSphere
  24395. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24396. * * radius the radius of the IcoSphere, optional default 1
  24397. * * radiusX allows stretching in the x direction, optional, default radius
  24398. * * radiusY allows stretching in the y direction, optional, default radius
  24399. * * radiusZ allows stretching in the z direction, optional, default radius
  24400. * * flat when true creates a flat shaded mesh, optional, default true
  24401. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24403. * * 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)
  24404. * * 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)
  24405. * @returns the VertexData of the IcoSphere
  24406. */
  24407. static CreateIcoSphere(options: {
  24408. radius?: number;
  24409. radiusX?: number;
  24410. radiusY?: number;
  24411. radiusZ?: number;
  24412. flat?: boolean;
  24413. subdivisions?: number;
  24414. sideOrientation?: number;
  24415. frontUVs?: Vector4;
  24416. backUVs?: Vector4;
  24417. }): VertexData;
  24418. /**
  24419. * Creates the VertexData for a Polyhedron
  24420. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24421. * * type provided types are:
  24422. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24423. * * 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)
  24424. * * size the size of the IcoSphere, optional default 1
  24425. * * sizeX allows stretching in the x direction, optional, default size
  24426. * * sizeY allows stretching in the y direction, optional, default size
  24427. * * sizeZ allows stretching in the z direction, optional, default size
  24428. * * 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
  24429. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24430. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24431. * * flat when true creates a flat shaded mesh, optional, default true
  24432. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24434. * * 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)
  24435. * * 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)
  24436. * @returns the VertexData of the Polyhedron
  24437. */
  24438. static CreatePolyhedron(options: {
  24439. type?: number;
  24440. size?: number;
  24441. sizeX?: number;
  24442. sizeY?: number;
  24443. sizeZ?: number;
  24444. custom?: any;
  24445. faceUV?: Vector4[];
  24446. faceColors?: Color4[];
  24447. flat?: boolean;
  24448. sideOrientation?: number;
  24449. frontUVs?: Vector4;
  24450. backUVs?: Vector4;
  24451. }): VertexData;
  24452. /**
  24453. * Creates the VertexData for a TorusKnot
  24454. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24455. * * radius the radius of the torus knot, optional, default 2
  24456. * * tube the thickness of the tube, optional, default 0.5
  24457. * * radialSegments the number of sides on each tube segments, optional, default 32
  24458. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24459. * * p the number of windings around the z axis, optional, default 2
  24460. * * q the number of windings around the x axis, optional, default 3
  24461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24462. * * 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)
  24463. * * 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)
  24464. * @returns the VertexData of the Torus Knot
  24465. */
  24466. static CreateTorusKnot(options: {
  24467. radius?: number;
  24468. tube?: number;
  24469. radialSegments?: number;
  24470. tubularSegments?: number;
  24471. p?: number;
  24472. q?: number;
  24473. sideOrientation?: number;
  24474. frontUVs?: Vector4;
  24475. backUVs?: Vector4;
  24476. }): VertexData;
  24477. /**
  24478. * Compute normals for given positions and indices
  24479. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24480. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24481. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24482. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24483. * * facetNormals : optional array of facet normals (vector3)
  24484. * * facetPositions : optional array of facet positions (vector3)
  24485. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24486. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24487. * * bInfo : optional bounding info, required for facetPartitioning computation
  24488. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24489. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24490. * * useRightHandedSystem: optional boolean to for right handed system computation
  24491. * * depthSort : optional boolean to enable the facet depth sort computation
  24492. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24493. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24494. */
  24495. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24496. facetNormals?: any;
  24497. facetPositions?: any;
  24498. facetPartitioning?: any;
  24499. ratio?: number;
  24500. bInfo?: any;
  24501. bbSize?: Vector3;
  24502. subDiv?: any;
  24503. useRightHandedSystem?: boolean;
  24504. depthSort?: boolean;
  24505. distanceTo?: Vector3;
  24506. depthSortedFacets?: any;
  24507. }): void;
  24508. /** @hidden */
  24509. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24510. /**
  24511. * Applies VertexData created from the imported parameters to the geometry
  24512. * @param parsedVertexData the parsed data from an imported file
  24513. * @param geometry the geometry to apply the VertexData to
  24514. */
  24515. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24516. }
  24517. }
  24518. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24519. import { Nullable } from "babylonjs/types";
  24520. import { Scene } from "babylonjs/scene";
  24521. import { Vector4 } from "babylonjs/Maths/math";
  24522. import { Mesh } from "babylonjs/Meshes/mesh";
  24523. /**
  24524. * Class containing static functions to help procedurally build meshes
  24525. */
  24526. export class DiscBuilder {
  24527. /**
  24528. * Creates a plane polygonal mesh. By default, this is a disc
  24529. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24530. * * 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
  24531. * * 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
  24532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24535. * @param name defines the name of the mesh
  24536. * @param options defines the options used to create the mesh
  24537. * @param scene defines the hosting scene
  24538. * @returns the plane polygonal mesh
  24539. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24540. */
  24541. static CreateDisc(name: string, options: {
  24542. radius?: number;
  24543. tessellation?: number;
  24544. arc?: number;
  24545. updatable?: boolean;
  24546. sideOrientation?: number;
  24547. frontUVs?: Vector4;
  24548. backUVs?: Vector4;
  24549. }, scene?: Nullable<Scene>): Mesh;
  24550. }
  24551. }
  24552. declare module "babylonjs/Particles/solidParticleSystem" {
  24553. import { Vector3 } from "babylonjs/Maths/math";
  24554. import { Mesh } from "babylonjs/Meshes/mesh";
  24555. import { Scene, IDisposable } from "babylonjs/scene";
  24556. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24557. /**
  24558. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24559. *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.
  24560. * The SPS is also a particle system. It provides some methods to manage the particles.
  24561. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24562. *
  24563. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24564. */
  24565. export class SolidParticleSystem implements IDisposable {
  24566. /**
  24567. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24568. * Example : var p = SPS.particles[i];
  24569. */
  24570. particles: SolidParticle[];
  24571. /**
  24572. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24573. */
  24574. nbParticles: number;
  24575. /**
  24576. * If the particles must ever face the camera (default false). Useful for planar particles.
  24577. */
  24578. billboard: boolean;
  24579. /**
  24580. * Recompute normals when adding a shape
  24581. */
  24582. recomputeNormals: boolean;
  24583. /**
  24584. * This a counter ofr your own usage. It's not set by any SPS functions.
  24585. */
  24586. counter: number;
  24587. /**
  24588. * The SPS name. This name is also given to the underlying mesh.
  24589. */
  24590. name: string;
  24591. /**
  24592. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24593. */
  24594. mesh: Mesh;
  24595. /**
  24596. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24597. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24598. */
  24599. vars: any;
  24600. /**
  24601. * This array is populated when the SPS is set as 'pickable'.
  24602. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24603. * Each element of this array is an object `{idx: int, faceId: int}`.
  24604. * `idx` is the picked particle index in the `SPS.particles` array
  24605. * `faceId` is the picked face index counted within this particle.
  24606. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24607. */
  24608. pickedParticles: {
  24609. idx: number;
  24610. faceId: number;
  24611. }[];
  24612. /**
  24613. * This array is populated when `enableDepthSort` is set to true.
  24614. * Each element of this array is an instance of the class DepthSortedParticle.
  24615. */
  24616. depthSortedParticles: DepthSortedParticle[];
  24617. /**
  24618. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24619. * @hidden
  24620. */
  24621. _bSphereOnly: boolean;
  24622. /**
  24623. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24624. * @hidden
  24625. */
  24626. _bSphereRadiusFactor: number;
  24627. private _scene;
  24628. private _positions;
  24629. private _indices;
  24630. private _normals;
  24631. private _colors;
  24632. private _uvs;
  24633. private _indices32;
  24634. private _positions32;
  24635. private _normals32;
  24636. private _fixedNormal32;
  24637. private _colors32;
  24638. private _uvs32;
  24639. private _index;
  24640. private _updatable;
  24641. private _pickable;
  24642. private _isVisibilityBoxLocked;
  24643. private _alwaysVisible;
  24644. private _depthSort;
  24645. private _shapeCounter;
  24646. private _copy;
  24647. private _color;
  24648. private _computeParticleColor;
  24649. private _computeParticleTexture;
  24650. private _computeParticleRotation;
  24651. private _computeParticleVertex;
  24652. private _computeBoundingBox;
  24653. private _depthSortParticles;
  24654. private _camera;
  24655. private _mustUnrotateFixedNormals;
  24656. private _particlesIntersect;
  24657. private _needs32Bits;
  24658. /**
  24659. * Creates a SPS (Solid Particle System) object.
  24660. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24661. * @param scene (Scene) is the scene in which the SPS is added.
  24662. * @param options defines the options of the sps e.g.
  24663. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24664. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24665. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24666. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24667. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24668. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24669. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24670. */
  24671. constructor(name: string, scene: Scene, options?: {
  24672. updatable?: boolean;
  24673. isPickable?: boolean;
  24674. enableDepthSort?: boolean;
  24675. particleIntersection?: boolean;
  24676. boundingSphereOnly?: boolean;
  24677. bSphereRadiusFactor?: number;
  24678. });
  24679. /**
  24680. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24681. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24682. * @returns the created mesh
  24683. */
  24684. buildMesh(): Mesh;
  24685. /**
  24686. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24687. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24688. * Thus the particles generated from `digest()` have their property `position` set yet.
  24689. * @param mesh ( Mesh ) is the mesh to be digested
  24690. * @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
  24691. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24692. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24693. * @returns the current SPS
  24694. */
  24695. digest(mesh: Mesh, options?: {
  24696. facetNb?: number;
  24697. number?: number;
  24698. delta?: number;
  24699. }): SolidParticleSystem;
  24700. private _unrotateFixedNormals;
  24701. private _resetCopy;
  24702. private _meshBuilder;
  24703. private _posToShape;
  24704. private _uvsToShapeUV;
  24705. private _addParticle;
  24706. /**
  24707. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24708. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24709. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24710. * @param nb (positive integer) the number of particles to be created from this model
  24711. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24712. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24713. * @returns the number of shapes in the system
  24714. */
  24715. addShape(mesh: Mesh, nb: number, options?: {
  24716. positionFunction?: any;
  24717. vertexFunction?: any;
  24718. }): number;
  24719. private _rebuildParticle;
  24720. /**
  24721. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24722. * @returns the SPS.
  24723. */
  24724. rebuildMesh(): SolidParticleSystem;
  24725. /**
  24726. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24727. * This method calls `updateParticle()` for each particle of the SPS.
  24728. * For an animated SPS, it is usually called within the render loop.
  24729. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24730. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24731. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24732. * @returns the SPS.
  24733. */
  24734. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24735. /**
  24736. * Disposes the SPS.
  24737. */
  24738. dispose(): void;
  24739. /**
  24740. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24742. * @returns the SPS.
  24743. */
  24744. refreshVisibleSize(): SolidParticleSystem;
  24745. /**
  24746. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24747. * @param size the size (float) of the visibility box
  24748. * note : this doesn't lock the SPS mesh bounding box.
  24749. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24750. */
  24751. setVisibilityBox(size: number): void;
  24752. /**
  24753. * Gets whether the SPS as always visible or not
  24754. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24755. */
  24756. /**
  24757. * Sets the SPS as always visible or not
  24758. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24759. */
  24760. isAlwaysVisible: boolean;
  24761. /**
  24762. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24763. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24764. */
  24765. /**
  24766. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24767. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24768. */
  24769. isVisibilityBoxLocked: boolean;
  24770. /**
  24771. * Tells to `setParticles()` to compute the particle rotations or not.
  24772. * Default value : true. The SPS is faster when it's set to false.
  24773. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24774. */
  24775. /**
  24776. * Gets if `setParticles()` computes the particle rotations or not.
  24777. * Default value : true. The SPS is faster when it's set to false.
  24778. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24779. */
  24780. computeParticleRotation: boolean;
  24781. /**
  24782. * Tells to `setParticles()` to compute the particle colors or not.
  24783. * Default value : true. The SPS is faster when it's set to false.
  24784. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24785. */
  24786. /**
  24787. * Gets if `setParticles()` computes the particle colors or not.
  24788. * Default value : true. The SPS is faster when it's set to false.
  24789. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24790. */
  24791. computeParticleColor: boolean;
  24792. /**
  24793. * Gets if `setParticles()` computes the particle textures or not.
  24794. * Default value : true. The SPS is faster when it's set to false.
  24795. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24796. */
  24797. computeParticleTexture: boolean;
  24798. /**
  24799. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24800. * Default value : false. The SPS is faster when it's set to false.
  24801. * Note : the particle custom vertex positions aren't stored values.
  24802. */
  24803. /**
  24804. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24805. * Default value : false. The SPS is faster when it's set to false.
  24806. * Note : the particle custom vertex positions aren't stored values.
  24807. */
  24808. computeParticleVertex: boolean;
  24809. /**
  24810. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24811. */
  24812. /**
  24813. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24814. */
  24815. computeBoundingBox: boolean;
  24816. /**
  24817. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24818. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24819. * Default : `true`
  24820. */
  24821. /**
  24822. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24823. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24824. * Default : `true`
  24825. */
  24826. depthSortParticles: boolean;
  24827. /**
  24828. * This function does nothing. It may be overwritten to set all the particle first values.
  24829. * The SPS doesn't call this function, you may have to call it by your own.
  24830. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24831. */
  24832. initParticles(): void;
  24833. /**
  24834. * This function does nothing. It may be overwritten to recycle a particle.
  24835. * The SPS doesn't call this function, you may have to call it by your own.
  24836. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24837. * @param particle The particle to recycle
  24838. * @returns the recycled particle
  24839. */
  24840. recycleParticle(particle: SolidParticle): SolidParticle;
  24841. /**
  24842. * Updates a particle : this function should be overwritten by the user.
  24843. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24844. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24845. * @example : just set a particle position or velocity and recycle conditions
  24846. * @param particle The particle to update
  24847. * @returns the updated particle
  24848. */
  24849. updateParticle(particle: SolidParticle): SolidParticle;
  24850. /**
  24851. * Updates a vertex of a particle : it can be overwritten by the user.
  24852. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24853. * @param particle the current particle
  24854. * @param vertex the current index of the current particle
  24855. * @param pt the index of the current vertex in the particle shape
  24856. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24857. * @example : just set a vertex particle position
  24858. * @returns the updated vertex
  24859. */
  24860. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24861. /**
  24862. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24863. * This does nothing and may be overwritten by the user.
  24864. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24865. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24866. * @param update the boolean update value actually passed to setParticles()
  24867. */
  24868. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24869. /**
  24870. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24871. * This will be passed three parameters.
  24872. * This does nothing and may be overwritten by the user.
  24873. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24874. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24875. * @param update the boolean update value actually passed to setParticles()
  24876. */
  24877. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24878. }
  24879. }
  24880. declare module "babylonjs/Particles/solidParticle" {
  24881. import { Nullable } from "babylonjs/types";
  24882. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24883. import { Mesh } from "babylonjs/Meshes/mesh";
  24884. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24885. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24886. /**
  24887. * Represents one particle of a solid particle system.
  24888. */
  24889. export class SolidParticle {
  24890. /**
  24891. * particle global index
  24892. */
  24893. idx: number;
  24894. /**
  24895. * The color of the particle
  24896. */
  24897. color: Nullable<Color4>;
  24898. /**
  24899. * The world space position of the particle.
  24900. */
  24901. position: Vector3;
  24902. /**
  24903. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24904. */
  24905. rotation: Vector3;
  24906. /**
  24907. * The world space rotation quaternion of the particle.
  24908. */
  24909. rotationQuaternion: Nullable<Quaternion>;
  24910. /**
  24911. * The scaling of the particle.
  24912. */
  24913. scaling: Vector3;
  24914. /**
  24915. * The uvs of the particle.
  24916. */
  24917. uvs: Vector4;
  24918. /**
  24919. * The current speed of the particle.
  24920. */
  24921. velocity: Vector3;
  24922. /**
  24923. * The pivot point in the particle local space.
  24924. */
  24925. pivot: Vector3;
  24926. /**
  24927. * Must the particle be translated from its pivot point in its local space ?
  24928. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24929. * Default : false
  24930. */
  24931. translateFromPivot: boolean;
  24932. /**
  24933. * Is the particle active or not ?
  24934. */
  24935. alive: boolean;
  24936. /**
  24937. * Is the particle visible or not ?
  24938. */
  24939. isVisible: boolean;
  24940. /**
  24941. * Index of this particle in the global "positions" array (Internal use)
  24942. * @hidden
  24943. */
  24944. _pos: number;
  24945. /**
  24946. * @hidden Index of this particle in the global "indices" array (Internal use)
  24947. */
  24948. _ind: number;
  24949. /**
  24950. * @hidden ModelShape of this particle (Internal use)
  24951. */
  24952. _model: ModelShape;
  24953. /**
  24954. * ModelShape id of this particle
  24955. */
  24956. shapeId: number;
  24957. /**
  24958. * Index of the particle in its shape id (Internal use)
  24959. */
  24960. idxInShape: number;
  24961. /**
  24962. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24963. */
  24964. _modelBoundingInfo: BoundingInfo;
  24965. /**
  24966. * @hidden Particle BoundingInfo object (Internal use)
  24967. */
  24968. _boundingInfo: BoundingInfo;
  24969. /**
  24970. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24971. */
  24972. _sps: SolidParticleSystem;
  24973. /**
  24974. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24975. */
  24976. _stillInvisible: boolean;
  24977. /**
  24978. * @hidden Last computed particle rotation matrix
  24979. */
  24980. _rotationMatrix: number[];
  24981. /**
  24982. * Parent particle Id, if any.
  24983. * Default null.
  24984. */
  24985. parentId: Nullable<number>;
  24986. /**
  24987. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24988. * The possible values are :
  24989. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24990. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24992. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24993. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24994. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24995. * */
  24996. cullingStrategy: number;
  24997. /**
  24998. * @hidden Internal global position in the SPS.
  24999. */
  25000. _globalPosition: Vector3;
  25001. /**
  25002. * Creates a Solid Particle object.
  25003. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25004. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25005. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25006. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25007. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25008. * @param shapeId (integer) is the model shape identifier in the SPS.
  25009. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25010. * @param sps defines the sps it is associated to
  25011. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25012. */
  25013. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25014. /**
  25015. * Legacy support, changed scale to scaling
  25016. */
  25017. /**
  25018. * Legacy support, changed scale to scaling
  25019. */
  25020. scale: Vector3;
  25021. /**
  25022. * Legacy support, changed quaternion to rotationQuaternion
  25023. */
  25024. /**
  25025. * Legacy support, changed quaternion to rotationQuaternion
  25026. */
  25027. quaternion: Nullable<Quaternion>;
  25028. /**
  25029. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25030. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25031. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25032. * @returns true if it intersects
  25033. */
  25034. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25035. /**
  25036. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25037. * A particle is in the frustum if its bounding box intersects the frustum
  25038. * @param frustumPlanes defines the frustum to test
  25039. * @returns true if the particle is in the frustum planes
  25040. */
  25041. isInFrustum(frustumPlanes: Plane[]): boolean;
  25042. /**
  25043. * get the rotation matrix of the particle
  25044. * @hidden
  25045. */
  25046. getRotationMatrix(m: Matrix): void;
  25047. }
  25048. /**
  25049. * Represents the shape of the model used by one particle of a solid particle system.
  25050. * SPS internal tool, don't use it manually.
  25051. */
  25052. export class ModelShape {
  25053. /**
  25054. * The shape id
  25055. * @hidden
  25056. */
  25057. shapeID: number;
  25058. /**
  25059. * flat array of model positions (internal use)
  25060. * @hidden
  25061. */
  25062. _shape: Vector3[];
  25063. /**
  25064. * flat array of model UVs (internal use)
  25065. * @hidden
  25066. */
  25067. _shapeUV: number[];
  25068. /**
  25069. * length of the shape in the model indices array (internal use)
  25070. * @hidden
  25071. */
  25072. _indicesLength: number;
  25073. /**
  25074. * Custom position function (internal use)
  25075. * @hidden
  25076. */
  25077. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25078. /**
  25079. * Custom vertex function (internal use)
  25080. * @hidden
  25081. */
  25082. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25083. /**
  25084. * 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.
  25085. * SPS internal tool, don't use it manually.
  25086. * @hidden
  25087. */
  25088. 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>);
  25089. }
  25090. /**
  25091. * Represents a Depth Sorted Particle in the solid particle system.
  25092. */
  25093. export class DepthSortedParticle {
  25094. /**
  25095. * Index of the particle in the "indices" array
  25096. */
  25097. ind: number;
  25098. /**
  25099. * Length of the particle shape in the "indices" array
  25100. */
  25101. indicesLength: number;
  25102. /**
  25103. * Squared distance from the particle to the camera
  25104. */
  25105. sqDistance: number;
  25106. }
  25107. }
  25108. declare module "babylonjs/Collisions/meshCollisionData" {
  25109. import { Collider } from "babylonjs/Collisions/collider";
  25110. import { Vector3 } from "babylonjs/Maths/math";
  25111. import { Nullable } from "babylonjs/types";
  25112. import { Observer } from "babylonjs/Misc/observable";
  25113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25114. /**
  25115. * @hidden
  25116. */
  25117. export class _MeshCollisionData {
  25118. _checkCollisions: boolean;
  25119. _collisionMask: number;
  25120. _collisionGroup: number;
  25121. _collider: Nullable<Collider>;
  25122. _oldPositionForCollisions: Vector3;
  25123. _diffPositionForCollisions: Vector3;
  25124. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25125. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25126. }
  25127. }
  25128. declare module "babylonjs/Meshes/abstractMesh" {
  25129. import { Observable } from "babylonjs/Misc/observable";
  25130. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25131. import { Camera } from "babylonjs/Cameras/camera";
  25132. import { Scene, IDisposable } from "babylonjs/scene";
  25133. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25134. import { Node } from "babylonjs/node";
  25135. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25136. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25138. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25139. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25140. import { Material } from "babylonjs/Materials/material";
  25141. import { Light } from "babylonjs/Lights/light";
  25142. import { Skeleton } from "babylonjs/Bones/skeleton";
  25143. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25144. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25146. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25147. import { Ray } from "babylonjs/Culling/ray";
  25148. import { Collider } from "babylonjs/Collisions/collider";
  25149. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25150. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25151. /** @hidden */
  25152. class _FacetDataStorage {
  25153. facetPositions: Vector3[];
  25154. facetNormals: Vector3[];
  25155. facetPartitioning: number[][];
  25156. facetNb: number;
  25157. partitioningSubdivisions: number;
  25158. partitioningBBoxRatio: number;
  25159. facetDataEnabled: boolean;
  25160. facetParameters: any;
  25161. bbSize: Vector3;
  25162. subDiv: {
  25163. max: number;
  25164. X: number;
  25165. Y: number;
  25166. Z: number;
  25167. };
  25168. facetDepthSort: boolean;
  25169. facetDepthSortEnabled: boolean;
  25170. depthSortedIndices: IndicesArray;
  25171. depthSortedFacets: {
  25172. ind: number;
  25173. sqDistance: number;
  25174. }[];
  25175. facetDepthSortFunction: (f1: {
  25176. ind: number;
  25177. sqDistance: number;
  25178. }, f2: {
  25179. ind: number;
  25180. sqDistance: number;
  25181. }) => number;
  25182. facetDepthSortFrom: Vector3;
  25183. facetDepthSortOrigin: Vector3;
  25184. invertedMatrix: Matrix;
  25185. }
  25186. /**
  25187. * @hidden
  25188. **/
  25189. class _InternalAbstractMeshDataInfo {
  25190. _hasVertexAlpha: boolean;
  25191. _useVertexColors: boolean;
  25192. _numBoneInfluencers: number;
  25193. _applyFog: boolean;
  25194. _receiveShadows: boolean;
  25195. _facetData: _FacetDataStorage;
  25196. _visibility: number;
  25197. _skeleton: Nullable<Skeleton>;
  25198. _layerMask: number;
  25199. _computeBonesUsingShaders: boolean;
  25200. _isActive: boolean;
  25201. _onlyForInstances: boolean;
  25202. _isActiveIntermediate: boolean;
  25203. _onlyForInstancesIntermediate: boolean;
  25204. }
  25205. /**
  25206. * Class used to store all common mesh properties
  25207. */
  25208. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25209. /** No occlusion */
  25210. static OCCLUSION_TYPE_NONE: number;
  25211. /** Occlusion set to optimisitic */
  25212. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25213. /** Occlusion set to strict */
  25214. static OCCLUSION_TYPE_STRICT: number;
  25215. /** Use an accurante occlusion algorithm */
  25216. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25217. /** Use a conservative occlusion algorithm */
  25218. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25219. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25220. * Test order :
  25221. * Is the bounding sphere outside the frustum ?
  25222. * If not, are the bounding box vertices outside the frustum ?
  25223. * It not, then the cullable object is in the frustum.
  25224. */
  25225. static readonly CULLINGSTRATEGY_STANDARD: number;
  25226. /** Culling strategy : Bounding Sphere Only.
  25227. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25228. * It's also less accurate than the standard because some not visible objects can still be selected.
  25229. * Test : is the bounding sphere outside the frustum ?
  25230. * If not, then the cullable object is in the frustum.
  25231. */
  25232. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25233. /** Culling strategy : Optimistic Inclusion.
  25234. * This in an inclusion test first, then the standard exclusion test.
  25235. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25236. * 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.
  25237. * Anyway, it's as accurate as the standard strategy.
  25238. * Test :
  25239. * Is the cullable object bounding sphere center in the frustum ?
  25240. * If not, apply the default culling strategy.
  25241. */
  25242. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25243. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25244. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25245. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25246. * 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.
  25247. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25248. * Test :
  25249. * Is the cullable object bounding sphere center in the frustum ?
  25250. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25251. */
  25252. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25253. /**
  25254. * No billboard
  25255. */
  25256. static readonly BILLBOARDMODE_NONE: number;
  25257. /** Billboard on X axis */
  25258. static readonly BILLBOARDMODE_X: number;
  25259. /** Billboard on Y axis */
  25260. static readonly BILLBOARDMODE_Y: number;
  25261. /** Billboard on Z axis */
  25262. static readonly BILLBOARDMODE_Z: number;
  25263. /** Billboard on all axes */
  25264. static readonly BILLBOARDMODE_ALL: number;
  25265. /** @hidden */
  25266. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25267. /**
  25268. * The culling strategy to use to check whether the mesh must be rendered or not.
  25269. * This value can be changed at any time and will be used on the next render mesh selection.
  25270. * The possible values are :
  25271. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25272. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25273. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25274. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25275. * Please read each static variable documentation to get details about the culling process.
  25276. * */
  25277. cullingStrategy: number;
  25278. /**
  25279. * Gets the number of facets in the mesh
  25280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25281. */
  25282. readonly facetNb: number;
  25283. /**
  25284. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25286. */
  25287. partitioningSubdivisions: number;
  25288. /**
  25289. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25290. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25292. */
  25293. partitioningBBoxRatio: number;
  25294. /**
  25295. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25296. * Works only for updatable meshes.
  25297. * Doesn't work with multi-materials
  25298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25299. */
  25300. mustDepthSortFacets: boolean;
  25301. /**
  25302. * The location (Vector3) where the facet depth sort must be computed from.
  25303. * By default, the active camera position.
  25304. * Used only when facet depth sort is enabled
  25305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25306. */
  25307. facetDepthSortFrom: Vector3;
  25308. /**
  25309. * gets a boolean indicating if facetData is enabled
  25310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25311. */
  25312. readonly isFacetDataEnabled: boolean;
  25313. /** @hidden */
  25314. _updateNonUniformScalingState(value: boolean): boolean;
  25315. /**
  25316. * An event triggered when this mesh collides with another one
  25317. */
  25318. onCollideObservable: Observable<AbstractMesh>;
  25319. /** Set a function to call when this mesh collides with another one */
  25320. onCollide: () => void;
  25321. /**
  25322. * An event triggered when the collision's position changes
  25323. */
  25324. onCollisionPositionChangeObservable: Observable<Vector3>;
  25325. /** Set a function to call when the collision's position changes */
  25326. onCollisionPositionChange: () => void;
  25327. /**
  25328. * An event triggered when material is changed
  25329. */
  25330. onMaterialChangedObservable: Observable<AbstractMesh>;
  25331. /**
  25332. * Gets or sets the orientation for POV movement & rotation
  25333. */
  25334. definedFacingForward: boolean;
  25335. /** @hidden */
  25336. _occlusionQuery: Nullable<WebGLQuery>;
  25337. /** @hidden */
  25338. _renderingGroup: Nullable<RenderingGroup>;
  25339. /**
  25340. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25341. */
  25342. /**
  25343. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25344. */
  25345. visibility: number;
  25346. /** Gets or sets the alpha index used to sort transparent meshes
  25347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25348. */
  25349. alphaIndex: number;
  25350. /**
  25351. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25352. */
  25353. isVisible: boolean;
  25354. /**
  25355. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25356. */
  25357. isPickable: boolean;
  25358. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25359. showSubMeshesBoundingBox: boolean;
  25360. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25361. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25362. */
  25363. isBlocker: boolean;
  25364. /**
  25365. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25366. */
  25367. enablePointerMoveEvents: boolean;
  25368. /**
  25369. * Specifies the rendering group id for this mesh (0 by default)
  25370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25371. */
  25372. renderingGroupId: number;
  25373. private _material;
  25374. /** Gets or sets current material */
  25375. material: Nullable<Material>;
  25376. /**
  25377. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25378. * @see http://doc.babylonjs.com/babylon101/shadows
  25379. */
  25380. receiveShadows: boolean;
  25381. /** Defines color to use when rendering outline */
  25382. outlineColor: Color3;
  25383. /** Define width to use when rendering outline */
  25384. outlineWidth: number;
  25385. /** Defines color to use when rendering overlay */
  25386. overlayColor: Color3;
  25387. /** Defines alpha to use when rendering overlay */
  25388. overlayAlpha: number;
  25389. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25390. hasVertexAlpha: boolean;
  25391. /** 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) */
  25392. useVertexColors: boolean;
  25393. /**
  25394. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25395. */
  25396. computeBonesUsingShaders: boolean;
  25397. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25398. numBoneInfluencers: number;
  25399. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25400. applyFog: boolean;
  25401. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25402. useOctreeForRenderingSelection: boolean;
  25403. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25404. useOctreeForPicking: boolean;
  25405. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25406. useOctreeForCollisions: boolean;
  25407. /**
  25408. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25409. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25410. */
  25411. layerMask: number;
  25412. /**
  25413. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25414. */
  25415. alwaysSelectAsActiveMesh: boolean;
  25416. /**
  25417. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25418. */
  25419. doNotSyncBoundingInfo: boolean;
  25420. /**
  25421. * Gets or sets the current action manager
  25422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25423. */
  25424. actionManager: Nullable<AbstractActionManager>;
  25425. private _meshCollisionData;
  25426. /**
  25427. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25429. */
  25430. ellipsoid: Vector3;
  25431. /**
  25432. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25434. */
  25435. ellipsoidOffset: Vector3;
  25436. /**
  25437. * Gets or sets a collision mask used to mask collisions (default is -1).
  25438. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25439. */
  25440. collisionMask: number;
  25441. /**
  25442. * Gets or sets the current collision group mask (-1 by default).
  25443. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25444. */
  25445. collisionGroup: number;
  25446. /**
  25447. * Defines edge width used when edgesRenderer is enabled
  25448. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25449. */
  25450. edgesWidth: number;
  25451. /**
  25452. * Defines edge color used when edgesRenderer is enabled
  25453. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25454. */
  25455. edgesColor: Color4;
  25456. /** @hidden */
  25457. _edgesRenderer: Nullable<IEdgesRenderer>;
  25458. /** @hidden */
  25459. _masterMesh: Nullable<AbstractMesh>;
  25460. /** @hidden */
  25461. _boundingInfo: Nullable<BoundingInfo>;
  25462. /** @hidden */
  25463. _renderId: number;
  25464. /**
  25465. * Gets or sets the list of subMeshes
  25466. * @see http://doc.babylonjs.com/how_to/multi_materials
  25467. */
  25468. subMeshes: SubMesh[];
  25469. /** @hidden */
  25470. _intersectionsInProgress: AbstractMesh[];
  25471. /** @hidden */
  25472. _unIndexed: boolean;
  25473. /** @hidden */
  25474. _lightSources: Light[];
  25475. /** Gets the list of lights affecting that mesh */
  25476. readonly lightSources: Light[];
  25477. /** @hidden */
  25478. readonly _positions: Nullable<Vector3[]>;
  25479. /** @hidden */
  25480. _waitingData: {
  25481. lods: Nullable<any>;
  25482. actions: Nullable<any>;
  25483. freezeWorldMatrix: Nullable<boolean>;
  25484. };
  25485. /** @hidden */
  25486. _bonesTransformMatrices: Nullable<Float32Array>;
  25487. /** @hidden */
  25488. _transformMatrixTexture: Nullable<RawTexture>;
  25489. /**
  25490. * Gets or sets a skeleton to apply skining transformations
  25491. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25492. */
  25493. skeleton: Nullable<Skeleton>;
  25494. /**
  25495. * An event triggered when the mesh is rebuilt.
  25496. */
  25497. onRebuildObservable: Observable<AbstractMesh>;
  25498. /**
  25499. * Creates a new AbstractMesh
  25500. * @param name defines the name of the mesh
  25501. * @param scene defines the hosting scene
  25502. */
  25503. constructor(name: string, scene?: Nullable<Scene>);
  25504. /**
  25505. * Returns the string "AbstractMesh"
  25506. * @returns "AbstractMesh"
  25507. */
  25508. getClassName(): string;
  25509. /**
  25510. * Gets a string representation of the current mesh
  25511. * @param fullDetails defines a boolean indicating if full details must be included
  25512. * @returns a string representation of the current mesh
  25513. */
  25514. toString(fullDetails?: boolean): string;
  25515. /**
  25516. * @hidden
  25517. */
  25518. protected _getEffectiveParent(): Nullable<Node>;
  25519. /** @hidden */
  25520. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25521. /** @hidden */
  25522. _rebuild(): void;
  25523. /** @hidden */
  25524. _resyncLightSources(): void;
  25525. /** @hidden */
  25526. _resyncLighSource(light: Light): void;
  25527. /** @hidden */
  25528. _unBindEffect(): void;
  25529. /** @hidden */
  25530. _removeLightSource(light: Light): void;
  25531. private _markSubMeshesAsDirty;
  25532. /** @hidden */
  25533. _markSubMeshesAsLightDirty(): void;
  25534. /** @hidden */
  25535. _markSubMeshesAsAttributesDirty(): void;
  25536. /** @hidden */
  25537. _markSubMeshesAsMiscDirty(): void;
  25538. /**
  25539. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25540. */
  25541. scaling: Vector3;
  25542. /**
  25543. * Returns true if the mesh is blocked. Implemented by child classes
  25544. */
  25545. readonly isBlocked: boolean;
  25546. /**
  25547. * Returns the mesh itself by default. Implemented by child classes
  25548. * @param camera defines the camera to use to pick the right LOD level
  25549. * @returns the currentAbstractMesh
  25550. */
  25551. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25552. /**
  25553. * Returns 0 by default. Implemented by child classes
  25554. * @returns an integer
  25555. */
  25556. getTotalVertices(): number;
  25557. /**
  25558. * Returns a positive integer : the total number of indices in this mesh geometry.
  25559. * @returns the numner of indices or zero if the mesh has no geometry.
  25560. */
  25561. getTotalIndices(): number;
  25562. /**
  25563. * Returns null by default. Implemented by child classes
  25564. * @returns null
  25565. */
  25566. getIndices(): Nullable<IndicesArray>;
  25567. /**
  25568. * Returns the array of the requested vertex data kind. Implemented by child classes
  25569. * @param kind defines the vertex data kind to use
  25570. * @returns null
  25571. */
  25572. getVerticesData(kind: string): Nullable<FloatArray>;
  25573. /**
  25574. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25575. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25576. * Note that a new underlying VertexBuffer object is created each call.
  25577. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25578. * @param kind defines vertex data kind:
  25579. * * VertexBuffer.PositionKind
  25580. * * VertexBuffer.UVKind
  25581. * * VertexBuffer.UV2Kind
  25582. * * VertexBuffer.UV3Kind
  25583. * * VertexBuffer.UV4Kind
  25584. * * VertexBuffer.UV5Kind
  25585. * * VertexBuffer.UV6Kind
  25586. * * VertexBuffer.ColorKind
  25587. * * VertexBuffer.MatricesIndicesKind
  25588. * * VertexBuffer.MatricesIndicesExtraKind
  25589. * * VertexBuffer.MatricesWeightsKind
  25590. * * VertexBuffer.MatricesWeightsExtraKind
  25591. * @param data defines the data source
  25592. * @param updatable defines if the data must be flagged as updatable (or static)
  25593. * @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
  25594. * @returns the current mesh
  25595. */
  25596. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25597. /**
  25598. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25599. * If the mesh has no geometry, it is simply returned as it is.
  25600. * @param kind defines vertex data kind:
  25601. * * VertexBuffer.PositionKind
  25602. * * VertexBuffer.UVKind
  25603. * * VertexBuffer.UV2Kind
  25604. * * VertexBuffer.UV3Kind
  25605. * * VertexBuffer.UV4Kind
  25606. * * VertexBuffer.UV5Kind
  25607. * * VertexBuffer.UV6Kind
  25608. * * VertexBuffer.ColorKind
  25609. * * VertexBuffer.MatricesIndicesKind
  25610. * * VertexBuffer.MatricesIndicesExtraKind
  25611. * * VertexBuffer.MatricesWeightsKind
  25612. * * VertexBuffer.MatricesWeightsExtraKind
  25613. * @param data defines the data source
  25614. * @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
  25615. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25616. * @returns the current mesh
  25617. */
  25618. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25619. /**
  25620. * Sets the mesh indices,
  25621. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25622. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25623. * @param totalVertices Defines the total number of vertices
  25624. * @returns the current mesh
  25625. */
  25626. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25627. /**
  25628. * Gets a boolean indicating if specific vertex data is present
  25629. * @param kind defines the vertex data kind to use
  25630. * @returns true is data kind is present
  25631. */
  25632. isVerticesDataPresent(kind: string): boolean;
  25633. /**
  25634. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25635. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25636. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25637. * @returns a BoundingInfo
  25638. */
  25639. getBoundingInfo(): BoundingInfo;
  25640. /**
  25641. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25642. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25643. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25644. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25645. * @returns the current mesh
  25646. */
  25647. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25648. /**
  25649. * Overwrite the current bounding info
  25650. * @param boundingInfo defines the new bounding info
  25651. * @returns the current mesh
  25652. */
  25653. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25654. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25655. readonly useBones: boolean;
  25656. /** @hidden */
  25657. _preActivate(): void;
  25658. /** @hidden */
  25659. _preActivateForIntermediateRendering(renderId: number): void;
  25660. /** @hidden */
  25661. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25662. /** @hidden */
  25663. _postActivate(): void;
  25664. /** @hidden */
  25665. _freeze(): void;
  25666. /** @hidden */
  25667. _unFreeze(): void;
  25668. /**
  25669. * Gets the current world matrix
  25670. * @returns a Matrix
  25671. */
  25672. getWorldMatrix(): Matrix;
  25673. /** @hidden */
  25674. _getWorldMatrixDeterminant(): number;
  25675. /**
  25676. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25677. */
  25678. readonly isAnInstance: boolean;
  25679. /**
  25680. * Perform relative position change from the point of view of behind the front of the mesh.
  25681. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25682. * Supports definition of mesh facing forward or backward
  25683. * @param amountRight defines the distance on the right axis
  25684. * @param amountUp defines the distance on the up axis
  25685. * @param amountForward defines the distance on the forward axis
  25686. * @returns the current mesh
  25687. */
  25688. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25689. /**
  25690. * Calculate relative position change from the point of view of behind the front of the mesh.
  25691. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25692. * Supports definition of mesh facing forward or backward
  25693. * @param amountRight defines the distance on the right axis
  25694. * @param amountUp defines the distance on the up axis
  25695. * @param amountForward defines the distance on the forward axis
  25696. * @returns the new displacement vector
  25697. */
  25698. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25699. /**
  25700. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25701. * Supports definition of mesh facing forward or backward
  25702. * @param flipBack defines the flip
  25703. * @param twirlClockwise defines the twirl
  25704. * @param tiltRight defines the tilt
  25705. * @returns the current mesh
  25706. */
  25707. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25708. /**
  25709. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25710. * Supports definition of mesh facing forward or backward.
  25711. * @param flipBack defines the flip
  25712. * @param twirlClockwise defines the twirl
  25713. * @param tiltRight defines the tilt
  25714. * @returns the new rotation vector
  25715. */
  25716. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25717. /**
  25718. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25719. * This means the mesh underlying bounding box and sphere are recomputed.
  25720. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25721. * @returns the current mesh
  25722. */
  25723. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25724. /** @hidden */
  25725. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25726. /** @hidden */
  25727. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25728. /** @hidden */
  25729. _updateBoundingInfo(): AbstractMesh;
  25730. /** @hidden */
  25731. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25732. /** @hidden */
  25733. protected _afterComputeWorldMatrix(): void;
  25734. /** @hidden */
  25735. readonly _effectiveMesh: AbstractMesh;
  25736. /**
  25737. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25738. * A mesh is in the frustum if its bounding box intersects the frustum
  25739. * @param frustumPlanes defines the frustum to test
  25740. * @returns true if the mesh is in the frustum planes
  25741. */
  25742. isInFrustum(frustumPlanes: Plane[]): boolean;
  25743. /**
  25744. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25745. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25746. * @param frustumPlanes defines the frustum to test
  25747. * @returns true if the mesh is completely in the frustum planes
  25748. */
  25749. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25750. /**
  25751. * True if the mesh intersects another mesh or a SolidParticle object
  25752. * @param mesh defines a target mesh or SolidParticle to test
  25753. * @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)
  25754. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25755. * @returns true if there is an intersection
  25756. */
  25757. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25758. /**
  25759. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25760. * @param point defines the point to test
  25761. * @returns true if there is an intersection
  25762. */
  25763. intersectsPoint(point: Vector3): boolean;
  25764. /**
  25765. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25767. */
  25768. checkCollisions: boolean;
  25769. /**
  25770. * Gets Collider object used to compute collisions (not physics)
  25771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25772. */
  25773. readonly collider: Nullable<Collider>;
  25774. /**
  25775. * Move the mesh using collision engine
  25776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25777. * @param displacement defines the requested displacement vector
  25778. * @returns the current mesh
  25779. */
  25780. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25781. private _onCollisionPositionChange;
  25782. /** @hidden */
  25783. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25784. /** @hidden */
  25785. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25786. /** @hidden */
  25787. _checkCollision(collider: Collider): AbstractMesh;
  25788. /** @hidden */
  25789. _generatePointsArray(): boolean;
  25790. /**
  25791. * Checks if the passed Ray intersects with the mesh
  25792. * @param ray defines the ray to use
  25793. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25795. * @returns the picking info
  25796. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25797. */
  25798. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25799. /**
  25800. * Clones the current mesh
  25801. * @param name defines the mesh name
  25802. * @param newParent defines the new mesh parent
  25803. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25804. * @returns the new mesh
  25805. */
  25806. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25807. /**
  25808. * Disposes all the submeshes of the current meshnp
  25809. * @returns the current mesh
  25810. */
  25811. releaseSubMeshes(): AbstractMesh;
  25812. /**
  25813. * Releases resources associated with this abstract mesh.
  25814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25816. */
  25817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25818. /**
  25819. * Adds the passed mesh as a child to the current mesh
  25820. * @param mesh defines the child mesh
  25821. * @returns the current mesh
  25822. */
  25823. addChild(mesh: AbstractMesh): AbstractMesh;
  25824. /**
  25825. * Removes the passed mesh from the current mesh children list
  25826. * @param mesh defines the child mesh
  25827. * @returns the current mesh
  25828. */
  25829. removeChild(mesh: AbstractMesh): AbstractMesh;
  25830. /** @hidden */
  25831. private _initFacetData;
  25832. /**
  25833. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25834. * This method can be called within the render loop.
  25835. * 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
  25836. * @returns the current mesh
  25837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25838. */
  25839. updateFacetData(): AbstractMesh;
  25840. /**
  25841. * Returns the facetLocalNormals array.
  25842. * The normals are expressed in the mesh local spac
  25843. * @returns an array of Vector3
  25844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25845. */
  25846. getFacetLocalNormals(): Vector3[];
  25847. /**
  25848. * Returns the facetLocalPositions array.
  25849. * The facet positions are expressed in the mesh local space
  25850. * @returns an array of Vector3
  25851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25852. */
  25853. getFacetLocalPositions(): Vector3[];
  25854. /**
  25855. * Returns the facetLocalPartioning array
  25856. * @returns an array of array of numbers
  25857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25858. */
  25859. getFacetLocalPartitioning(): number[][];
  25860. /**
  25861. * Returns the i-th facet position in the world system.
  25862. * This method allocates a new Vector3 per call
  25863. * @param i defines the facet index
  25864. * @returns a new Vector3
  25865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25866. */
  25867. getFacetPosition(i: number): Vector3;
  25868. /**
  25869. * Sets the reference Vector3 with the i-th facet position in the world system
  25870. * @param i defines the facet index
  25871. * @param ref defines the target vector
  25872. * @returns the current mesh
  25873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25874. */
  25875. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25876. /**
  25877. * Returns the i-th facet normal 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. getFacetNormal(i: number): Vector3;
  25884. /**
  25885. * Sets the reference Vector3 with the i-th facet normal 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. getFacetNormalToRef(i: number, ref: Vector3): this;
  25892. /**
  25893. * 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)
  25894. * @param x defines x coordinate
  25895. * @param y defines y coordinate
  25896. * @param z defines z coordinate
  25897. * @returns the array of facet indexes
  25898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25899. */
  25900. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25901. /**
  25902. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25903. * @param projected sets as the (x,y,z) world projection on the facet
  25904. * @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
  25905. * @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
  25906. * @param x defines x coordinate
  25907. * @param y defines y coordinate
  25908. * @param z defines z coordinate
  25909. * @returns the face index if found (or null instead)
  25910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25911. */
  25912. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25913. /**
  25914. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25915. * @param projected sets as the (x,y,z) local projection on the facet
  25916. * @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
  25917. * @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
  25918. * @param x defines x coordinate
  25919. * @param y defines y coordinate
  25920. * @param z defines z coordinate
  25921. * @returns the face index if found (or null instead)
  25922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25923. */
  25924. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25925. /**
  25926. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25927. * @returns the parameters
  25928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25929. */
  25930. getFacetDataParameters(): any;
  25931. /**
  25932. * Disables the feature FacetData and frees the related memory
  25933. * @returns the current mesh
  25934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25935. */
  25936. disableFacetData(): AbstractMesh;
  25937. /**
  25938. * Updates the AbstractMesh indices array
  25939. * @param indices defines the data source
  25940. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25941. * @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)
  25942. * @returns the current mesh
  25943. */
  25944. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25945. /**
  25946. * Creates new normals data for the mesh
  25947. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25948. * @returns the current mesh
  25949. */
  25950. createNormals(updatable: boolean): AbstractMesh;
  25951. /**
  25952. * Align the mesh with a normal
  25953. * @param normal defines the normal to use
  25954. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25955. * @returns the current mesh
  25956. */
  25957. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25958. /** @hidden */
  25959. _checkOcclusionQuery(): boolean;
  25960. /**
  25961. * Disables the mesh edge rendering mode
  25962. * @returns the currentAbstractMesh
  25963. */
  25964. disableEdgesRendering(): AbstractMesh;
  25965. /**
  25966. * Enables the edge rendering mode on the mesh.
  25967. * This mode makes the mesh edges visible
  25968. * @param epsilon defines the maximal distance between two angles to detect a face
  25969. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25970. * @returns the currentAbstractMesh
  25971. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25972. */
  25973. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25974. }
  25975. }
  25976. declare module "babylonjs/Actions/actionEvent" {
  25977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25978. import { Nullable } from "babylonjs/types";
  25979. import { Sprite } from "babylonjs/Sprites/sprite";
  25980. import { Scene } from "babylonjs/scene";
  25981. import { Vector2 } from "babylonjs/Maths/math";
  25982. /**
  25983. * Interface used to define ActionEvent
  25984. */
  25985. export interface IActionEvent {
  25986. /** The mesh or sprite that triggered the action */
  25987. source: any;
  25988. /** The X mouse cursor position at the time of the event */
  25989. pointerX: number;
  25990. /** The Y mouse cursor position at the time of the event */
  25991. pointerY: number;
  25992. /** The mesh that is currently pointed at (can be null) */
  25993. meshUnderPointer: Nullable<AbstractMesh>;
  25994. /** the original (browser) event that triggered the ActionEvent */
  25995. sourceEvent?: any;
  25996. /** additional data for the event */
  25997. additionalData?: any;
  25998. }
  25999. /**
  26000. * ActionEvent is the event being sent when an action is triggered.
  26001. */
  26002. export class ActionEvent implements IActionEvent {
  26003. /** The mesh or sprite that triggered the action */
  26004. source: any;
  26005. /** The X mouse cursor position at the time of the event */
  26006. pointerX: number;
  26007. /** The Y mouse cursor position at the time of the event */
  26008. pointerY: number;
  26009. /** The mesh that is currently pointed at (can be null) */
  26010. meshUnderPointer: Nullable<AbstractMesh>;
  26011. /** the original (browser) event that triggered the ActionEvent */
  26012. sourceEvent?: any;
  26013. /** additional data for the event */
  26014. additionalData?: any;
  26015. /**
  26016. * Creates a new ActionEvent
  26017. * @param source The mesh or sprite that triggered the action
  26018. * @param pointerX The X mouse cursor position at the time of the event
  26019. * @param pointerY The Y mouse cursor position at the time of the event
  26020. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26021. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26022. * @param additionalData additional data for the event
  26023. */
  26024. constructor(
  26025. /** The mesh or sprite that triggered the action */
  26026. source: any,
  26027. /** The X mouse cursor position at the time of the event */
  26028. pointerX: number,
  26029. /** The Y mouse cursor position at the time of the event */
  26030. pointerY: number,
  26031. /** The mesh that is currently pointed at (can be null) */
  26032. meshUnderPointer: Nullable<AbstractMesh>,
  26033. /** the original (browser) event that triggered the ActionEvent */
  26034. sourceEvent?: any,
  26035. /** additional data for the event */
  26036. additionalData?: any);
  26037. /**
  26038. * Helper function to auto-create an ActionEvent from a source mesh.
  26039. * @param source The source mesh that triggered the event
  26040. * @param evt The original (browser) event
  26041. * @param additionalData additional data for the event
  26042. * @returns the new ActionEvent
  26043. */
  26044. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26045. /**
  26046. * Helper function to auto-create an ActionEvent from a source sprite
  26047. * @param source The source sprite that triggered the event
  26048. * @param scene Scene associated with the sprite
  26049. * @param evt The original (browser) event
  26050. * @param additionalData additional data for the event
  26051. * @returns the new ActionEvent
  26052. */
  26053. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26054. /**
  26055. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26056. * @param scene the scene where the event occurred
  26057. * @param evt The original (browser) event
  26058. * @returns the new ActionEvent
  26059. */
  26060. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26061. /**
  26062. * Helper function to auto-create an ActionEvent from a primitive
  26063. * @param prim defines the target primitive
  26064. * @param pointerPos defines the pointer position
  26065. * @param evt The original (browser) event
  26066. * @param additionalData additional data for the event
  26067. * @returns the new ActionEvent
  26068. */
  26069. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26070. }
  26071. }
  26072. declare module "babylonjs/Actions/abstractActionManager" {
  26073. import { IDisposable } from "babylonjs/scene";
  26074. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26075. import { IAction } from "babylonjs/Actions/action";
  26076. import { Nullable } from "babylonjs/types";
  26077. /**
  26078. * Abstract class used to decouple action Manager from scene and meshes.
  26079. * Do not instantiate.
  26080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26081. */
  26082. export abstract class AbstractActionManager implements IDisposable {
  26083. /** Gets the list of active triggers */
  26084. static Triggers: {
  26085. [key: string]: number;
  26086. };
  26087. /** Gets the cursor to use when hovering items */
  26088. hoverCursor: string;
  26089. /** Gets the list of actions */
  26090. actions: IAction[];
  26091. /**
  26092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26093. */
  26094. isRecursive: boolean;
  26095. /**
  26096. * Releases all associated resources
  26097. */
  26098. abstract dispose(): void;
  26099. /**
  26100. * Does this action manager has pointer triggers
  26101. */
  26102. abstract readonly hasPointerTriggers: boolean;
  26103. /**
  26104. * Does this action manager has pick triggers
  26105. */
  26106. abstract readonly hasPickTriggers: boolean;
  26107. /**
  26108. * Process a specific trigger
  26109. * @param trigger defines the trigger to process
  26110. * @param evt defines the event details to be processed
  26111. */
  26112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26113. /**
  26114. * Does this action manager handles actions of any of the given triggers
  26115. * @param triggers defines the triggers to be tested
  26116. * @return a boolean indicating whether one (or more) of the triggers is handled
  26117. */
  26118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26119. /**
  26120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26121. * speed.
  26122. * @param triggerA defines the trigger to be tested
  26123. * @param triggerB defines the trigger to be tested
  26124. * @return a boolean indicating whether one (or more) of the triggers is handled
  26125. */
  26126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26127. /**
  26128. * Does this action manager handles actions of a given trigger
  26129. * @param trigger defines the trigger to be tested
  26130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26131. * @return whether the trigger is handled
  26132. */
  26133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26134. /**
  26135. * Serialize this manager to a JSON object
  26136. * @param name defines the property name to store this manager
  26137. * @returns a JSON representation of this manager
  26138. */
  26139. abstract serialize(name: string): any;
  26140. /**
  26141. * Registers an action to this action manager
  26142. * @param action defines the action to be registered
  26143. * @return the action amended (prepared) after registration
  26144. */
  26145. abstract registerAction(action: IAction): Nullable<IAction>;
  26146. /**
  26147. * Unregisters an action to this action manager
  26148. * @param action defines the action to be unregistered
  26149. * @return a boolean indicating whether the action has been unregistered
  26150. */
  26151. abstract unregisterAction(action: IAction): Boolean;
  26152. /**
  26153. * Does exist one action manager with at least one trigger
  26154. **/
  26155. static readonly HasTriggers: boolean;
  26156. /**
  26157. * Does exist one action manager with at least one pick trigger
  26158. **/
  26159. static readonly HasPickTriggers: boolean;
  26160. /**
  26161. * Does exist one action manager that handles actions of a given trigger
  26162. * @param trigger defines the trigger to be tested
  26163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26164. **/
  26165. static HasSpecificTrigger(trigger: number): boolean;
  26166. }
  26167. }
  26168. declare module "babylonjs/node" {
  26169. import { Scene } from "babylonjs/scene";
  26170. import { Nullable } from "babylonjs/types";
  26171. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26172. import { Engine } from "babylonjs/Engines/engine";
  26173. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26174. import { Observable } from "babylonjs/Misc/observable";
  26175. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26176. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26177. import { Animatable } from "babylonjs/Animations/animatable";
  26178. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26179. import { Animation } from "babylonjs/Animations/animation";
  26180. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26182. /**
  26183. * Defines how a node can be built from a string name.
  26184. */
  26185. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26186. /**
  26187. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26188. */
  26189. export class Node implements IBehaviorAware<Node> {
  26190. /** @hidden */
  26191. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26192. private static _NodeConstructors;
  26193. /**
  26194. * Add a new node constructor
  26195. * @param type defines the type name of the node to construct
  26196. * @param constructorFunc defines the constructor function
  26197. */
  26198. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26199. /**
  26200. * Returns a node constructor based on type name
  26201. * @param type defines the type name
  26202. * @param name defines the new node name
  26203. * @param scene defines the hosting scene
  26204. * @param options defines optional options to transmit to constructors
  26205. * @returns the new constructor or null
  26206. */
  26207. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26208. /**
  26209. * Gets or sets the name of the node
  26210. */
  26211. name: string;
  26212. /**
  26213. * Gets or sets the id of the node
  26214. */
  26215. id: string;
  26216. /**
  26217. * Gets or sets the unique id of the node
  26218. */
  26219. uniqueId: number;
  26220. /**
  26221. * Gets or sets a string used to store user defined state for the node
  26222. */
  26223. state: string;
  26224. /**
  26225. * Gets or sets an object used to store user defined information for the node
  26226. */
  26227. metadata: any;
  26228. /**
  26229. * For internal use only. Please do not use.
  26230. */
  26231. reservedDataStore: any;
  26232. /**
  26233. * List of inspectable custom properties (used by the Inspector)
  26234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26235. */
  26236. inspectableCustomProperties: IInspectable[];
  26237. /**
  26238. * Gets or sets a boolean used to define if the node must be serialized
  26239. */
  26240. doNotSerialize: boolean;
  26241. /** @hidden */
  26242. _isDisposed: boolean;
  26243. /**
  26244. * Gets a list of Animations associated with the node
  26245. */
  26246. animations: import("babylonjs/Animations/animation").Animation[];
  26247. protected _ranges: {
  26248. [name: string]: Nullable<AnimationRange>;
  26249. };
  26250. /**
  26251. * Callback raised when the node is ready to be used
  26252. */
  26253. onReady: Nullable<(node: Node) => void>;
  26254. private _isEnabled;
  26255. private _isParentEnabled;
  26256. private _isReady;
  26257. /** @hidden */
  26258. _currentRenderId: number;
  26259. private _parentUpdateId;
  26260. /** @hidden */
  26261. _childUpdateId: number;
  26262. /** @hidden */
  26263. _waitingParentId: Nullable<string>;
  26264. /** @hidden */
  26265. _scene: Scene;
  26266. /** @hidden */
  26267. _cache: any;
  26268. private _parentNode;
  26269. private _children;
  26270. /** @hidden */
  26271. _worldMatrix: Matrix;
  26272. /** @hidden */
  26273. _worldMatrixDeterminant: number;
  26274. /** @hidden */
  26275. _worldMatrixDeterminantIsDirty: boolean;
  26276. /** @hidden */
  26277. private _sceneRootNodesIndex;
  26278. /**
  26279. * Gets a boolean indicating if the node has been disposed
  26280. * @returns true if the node was disposed
  26281. */
  26282. isDisposed(): boolean;
  26283. /**
  26284. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26285. * @see https://doc.babylonjs.com/how_to/parenting
  26286. */
  26287. parent: Nullable<Node>;
  26288. private addToSceneRootNodes;
  26289. private removeFromSceneRootNodes;
  26290. private _animationPropertiesOverride;
  26291. /**
  26292. * Gets or sets the animation properties override
  26293. */
  26294. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26295. /**
  26296. * Gets a string idenfifying the name of the class
  26297. * @returns "Node" string
  26298. */
  26299. getClassName(): string;
  26300. /** @hidden */
  26301. readonly _isNode: boolean;
  26302. /**
  26303. * An event triggered when the mesh is disposed
  26304. */
  26305. onDisposeObservable: Observable<Node>;
  26306. private _onDisposeObserver;
  26307. /**
  26308. * Sets a callback that will be raised when the node will be disposed
  26309. */
  26310. onDispose: () => void;
  26311. /**
  26312. * Creates a new Node
  26313. * @param name the name and id to be given to this node
  26314. * @param scene the scene this node will be added to
  26315. * @param addToRootNodes the node will be added to scene.rootNodes
  26316. */
  26317. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26318. /**
  26319. * Gets the scene of the node
  26320. * @returns a scene
  26321. */
  26322. getScene(): Scene;
  26323. /**
  26324. * Gets the engine of the node
  26325. * @returns a Engine
  26326. */
  26327. getEngine(): Engine;
  26328. private _behaviors;
  26329. /**
  26330. * Attach a behavior to the node
  26331. * @see http://doc.babylonjs.com/features/behaviour
  26332. * @param behavior defines the behavior to attach
  26333. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26334. * @returns the current Node
  26335. */
  26336. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26337. /**
  26338. * Remove an attached behavior
  26339. * @see http://doc.babylonjs.com/features/behaviour
  26340. * @param behavior defines the behavior to attach
  26341. * @returns the current Node
  26342. */
  26343. removeBehavior(behavior: Behavior<Node>): Node;
  26344. /**
  26345. * Gets the list of attached behaviors
  26346. * @see http://doc.babylonjs.com/features/behaviour
  26347. */
  26348. readonly behaviors: Behavior<Node>[];
  26349. /**
  26350. * Gets an attached behavior by name
  26351. * @param name defines the name of the behavior to look for
  26352. * @see http://doc.babylonjs.com/features/behaviour
  26353. * @returns null if behavior was not found else the requested behavior
  26354. */
  26355. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26356. /**
  26357. * Returns the latest update of the World matrix
  26358. * @returns a Matrix
  26359. */
  26360. getWorldMatrix(): Matrix;
  26361. /** @hidden */
  26362. _getWorldMatrixDeterminant(): number;
  26363. /**
  26364. * Returns directly the latest state of the mesh World matrix.
  26365. * A Matrix is returned.
  26366. */
  26367. readonly worldMatrixFromCache: Matrix;
  26368. /** @hidden */
  26369. _initCache(): void;
  26370. /** @hidden */
  26371. updateCache(force?: boolean): void;
  26372. /** @hidden */
  26373. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26374. /** @hidden */
  26375. _updateCache(ignoreParentClass?: boolean): void;
  26376. /** @hidden */
  26377. _isSynchronized(): boolean;
  26378. /** @hidden */
  26379. _markSyncedWithParent(): void;
  26380. /** @hidden */
  26381. isSynchronizedWithParent(): boolean;
  26382. /** @hidden */
  26383. isSynchronized(): boolean;
  26384. /**
  26385. * Is this node ready to be used/rendered
  26386. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26387. * @return true if the node is ready
  26388. */
  26389. isReady(completeCheck?: boolean): boolean;
  26390. /**
  26391. * Is this node enabled?
  26392. * 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
  26393. * @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
  26394. * @return whether this node (and its parent) is enabled
  26395. */
  26396. isEnabled(checkAncestors?: boolean): boolean;
  26397. /** @hidden */
  26398. protected _syncParentEnabledState(): void;
  26399. /**
  26400. * Set the enabled state of this node
  26401. * @param value defines the new enabled state
  26402. */
  26403. setEnabled(value: boolean): void;
  26404. /**
  26405. * Is this node a descendant of the given node?
  26406. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26407. * @param ancestor defines the parent node to inspect
  26408. * @returns a boolean indicating if this node is a descendant of the given node
  26409. */
  26410. isDescendantOf(ancestor: Node): boolean;
  26411. /** @hidden */
  26412. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26413. /**
  26414. * Will return all nodes that have this node as ascendant
  26415. * @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
  26416. * @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
  26417. * @return all children nodes of all types
  26418. */
  26419. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26420. /**
  26421. * Get all child-meshes of this node
  26422. * @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)
  26423. * @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
  26424. * @returns an array of AbstractMesh
  26425. */
  26426. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26427. /**
  26428. * Get all direct children of this node
  26429. * @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
  26430. * @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)
  26431. * @returns an array of Node
  26432. */
  26433. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26434. /** @hidden */
  26435. _setReady(state: boolean): void;
  26436. /**
  26437. * Get an animation by name
  26438. * @param name defines the name of the animation to look for
  26439. * @returns null if not found else the requested animation
  26440. */
  26441. getAnimationByName(name: string): Nullable<Animation>;
  26442. /**
  26443. * Creates an animation range for this node
  26444. * @param name defines the name of the range
  26445. * @param from defines the starting key
  26446. * @param to defines the end key
  26447. */
  26448. createAnimationRange(name: string, from: number, to: number): void;
  26449. /**
  26450. * Delete a specific animation range
  26451. * @param name defines the name of the range to delete
  26452. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26453. */
  26454. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26455. /**
  26456. * Get an animation range by name
  26457. * @param name defines the name of the animation range to look for
  26458. * @returns null if not found else the requested animation range
  26459. */
  26460. getAnimationRange(name: string): Nullable<AnimationRange>;
  26461. /**
  26462. * Gets the list of all animation ranges defined on this node
  26463. * @returns an array
  26464. */
  26465. getAnimationRanges(): Nullable<AnimationRange>[];
  26466. /**
  26467. * Will start the animation sequence
  26468. * @param name defines the range frames for animation sequence
  26469. * @param loop defines if the animation should loop (false by default)
  26470. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26471. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26472. * @returns the object created for this animation. If range does not exist, it will return null
  26473. */
  26474. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26475. /**
  26476. * Serialize animation ranges into a JSON compatible object
  26477. * @returns serialization object
  26478. */
  26479. serializeAnimationRanges(): any;
  26480. /**
  26481. * Computes the world matrix of the node
  26482. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26483. * @returns the world matrix
  26484. */
  26485. computeWorldMatrix(force?: boolean): Matrix;
  26486. /**
  26487. * Releases resources associated with this node.
  26488. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26489. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26490. */
  26491. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26492. /**
  26493. * Parse animation range data from a serialization object and store them into a given node
  26494. * @param node defines where to store the animation ranges
  26495. * @param parsedNode defines the serialization object to read data from
  26496. * @param scene defines the hosting scene
  26497. */
  26498. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26499. /**
  26500. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26501. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26502. * @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
  26503. * @returns the new bounding vectors
  26504. */
  26505. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26506. min: Vector3;
  26507. max: Vector3;
  26508. };
  26509. }
  26510. }
  26511. declare module "babylonjs/Animations/animation" {
  26512. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26513. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26514. import { Nullable } from "babylonjs/types";
  26515. import { Scene } from "babylonjs/scene";
  26516. import { IAnimatable } from "babylonjs/Misc/tools";
  26517. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26518. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26519. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26520. import { Node } from "babylonjs/node";
  26521. import { Animatable } from "babylonjs/Animations/animatable";
  26522. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26523. /**
  26524. * @hidden
  26525. */
  26526. export class _IAnimationState {
  26527. key: number;
  26528. repeatCount: number;
  26529. workValue?: any;
  26530. loopMode?: number;
  26531. offsetValue?: any;
  26532. highLimitValue?: any;
  26533. }
  26534. /**
  26535. * Class used to store any kind of animation
  26536. */
  26537. export class Animation {
  26538. /**Name of the animation */
  26539. name: string;
  26540. /**Property to animate */
  26541. targetProperty: string;
  26542. /**The frames per second of the animation */
  26543. framePerSecond: number;
  26544. /**The data type of the animation */
  26545. dataType: number;
  26546. /**The loop mode of the animation */
  26547. loopMode?: number | undefined;
  26548. /**Specifies if blending should be enabled */
  26549. enableBlending?: boolean | undefined;
  26550. /**
  26551. * Use matrix interpolation instead of using direct key value when animating matrices
  26552. */
  26553. static AllowMatricesInterpolation: boolean;
  26554. /**
  26555. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26556. */
  26557. static AllowMatrixDecomposeForInterpolation: boolean;
  26558. /**
  26559. * Stores the key frames of the animation
  26560. */
  26561. private _keys;
  26562. /**
  26563. * Stores the easing function of the animation
  26564. */
  26565. private _easingFunction;
  26566. /**
  26567. * @hidden Internal use only
  26568. */
  26569. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26570. /**
  26571. * The set of event that will be linked to this animation
  26572. */
  26573. private _events;
  26574. /**
  26575. * Stores an array of target property paths
  26576. */
  26577. targetPropertyPath: string[];
  26578. /**
  26579. * Stores the blending speed of the animation
  26580. */
  26581. blendingSpeed: number;
  26582. /**
  26583. * Stores the animation ranges for the animation
  26584. */
  26585. private _ranges;
  26586. /**
  26587. * @hidden Internal use
  26588. */
  26589. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26590. /**
  26591. * Sets up an animation
  26592. * @param property The property to animate
  26593. * @param animationType The animation type to apply
  26594. * @param framePerSecond The frames per second of the animation
  26595. * @param easingFunction The easing function used in the animation
  26596. * @returns The created animation
  26597. */
  26598. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26599. /**
  26600. * Create and start an animation on a node
  26601. * @param name defines the name of the global animation that will be run on all nodes
  26602. * @param node defines the root node where the animation will take place
  26603. * @param targetProperty defines property to animate
  26604. * @param framePerSecond defines the number of frame per second yo use
  26605. * @param totalFrame defines the number of frames in total
  26606. * @param from defines the initial value
  26607. * @param to defines the final value
  26608. * @param loopMode defines which loop mode you want to use (off by default)
  26609. * @param easingFunction defines the easing function to use (linear by default)
  26610. * @param onAnimationEnd defines the callback to call when animation end
  26611. * @returns the animatable created for this animation
  26612. */
  26613. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26614. /**
  26615. * Create and start an animation on a node and its descendants
  26616. * @param name defines the name of the global animation that will be run on all nodes
  26617. * @param node defines the root node where the animation will take place
  26618. * @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
  26619. * @param targetProperty defines property to animate
  26620. * @param framePerSecond defines the number of frame per second to 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 an animation ends (will be called once per node)
  26627. * @returns the list of animatables created for all nodes
  26628. * @example https://www.babylonjs-playground.com/#MH0VLI
  26629. */
  26630. 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[]>;
  26631. /**
  26632. * Creates a new animation, merges it with the existing animations and starts it
  26633. * @param name Name of the animation
  26634. * @param node Node which contains the scene that begins the animations
  26635. * @param targetProperty Specifies which property to animate
  26636. * @param framePerSecond The frames per second of the animation
  26637. * @param totalFrame The total number of frames
  26638. * @param from The frame at the beginning of the animation
  26639. * @param to The frame at the end of the animation
  26640. * @param loopMode Specifies the loop mode of the animation
  26641. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26642. * @param onAnimationEnd Callback to run once the animation is complete
  26643. * @returns Nullable animation
  26644. */
  26645. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26646. /**
  26647. * Transition property of an host to the target Value
  26648. * @param property The property to transition
  26649. * @param targetValue The target Value of the property
  26650. * @param host The object where the property to animate belongs
  26651. * @param scene Scene used to run the animation
  26652. * @param frameRate Framerate (in frame/s) to use
  26653. * @param transition The transition type we want to use
  26654. * @param duration The duration of the animation, in milliseconds
  26655. * @param onAnimationEnd Callback trigger at the end of the animation
  26656. * @returns Nullable animation
  26657. */
  26658. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26659. /**
  26660. * Return the array of runtime animations currently using this animation
  26661. */
  26662. readonly runtimeAnimations: RuntimeAnimation[];
  26663. /**
  26664. * Specifies if any of the runtime animations are currently running
  26665. */
  26666. readonly hasRunningRuntimeAnimations: boolean;
  26667. /**
  26668. * Initializes the animation
  26669. * @param name Name of the animation
  26670. * @param targetProperty Property to animate
  26671. * @param framePerSecond The frames per second of the animation
  26672. * @param dataType The data type of the animation
  26673. * @param loopMode The loop mode of the animation
  26674. * @param enableBlending Specifies if blending should be enabled
  26675. */
  26676. constructor(
  26677. /**Name of the animation */
  26678. name: string,
  26679. /**Property to animate */
  26680. targetProperty: string,
  26681. /**The frames per second of the animation */
  26682. framePerSecond: number,
  26683. /**The data type of the animation */
  26684. dataType: number,
  26685. /**The loop mode of the animation */
  26686. loopMode?: number | undefined,
  26687. /**Specifies if blending should be enabled */
  26688. enableBlending?: boolean | undefined);
  26689. /**
  26690. * Converts the animation to a string
  26691. * @param fullDetails support for multiple levels of logging within scene loading
  26692. * @returns String form of the animation
  26693. */
  26694. toString(fullDetails?: boolean): string;
  26695. /**
  26696. * Add an event to this animation
  26697. * @param event Event to add
  26698. */
  26699. addEvent(event: AnimationEvent): void;
  26700. /**
  26701. * Remove all events found at the given frame
  26702. * @param frame The frame to remove events from
  26703. */
  26704. removeEvents(frame: number): void;
  26705. /**
  26706. * Retrieves all the events from the animation
  26707. * @returns Events from the animation
  26708. */
  26709. getEvents(): AnimationEvent[];
  26710. /**
  26711. * Creates an animation range
  26712. * @param name Name of the animation range
  26713. * @param from Starting frame of the animation range
  26714. * @param to Ending frame of the animation
  26715. */
  26716. createRange(name: string, from: number, to: number): void;
  26717. /**
  26718. * Deletes an animation range by name
  26719. * @param name Name of the animation range to delete
  26720. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26721. */
  26722. deleteRange(name: string, deleteFrames?: boolean): void;
  26723. /**
  26724. * Gets the animation range by name, or null if not defined
  26725. * @param name Name of the animation range
  26726. * @returns Nullable animation range
  26727. */
  26728. getRange(name: string): Nullable<AnimationRange>;
  26729. /**
  26730. * Gets the key frames from the animation
  26731. * @returns The key frames of the animation
  26732. */
  26733. getKeys(): Array<IAnimationKey>;
  26734. /**
  26735. * Gets the highest frame rate of the animation
  26736. * @returns Highest frame rate of the animation
  26737. */
  26738. getHighestFrame(): number;
  26739. /**
  26740. * Gets the easing function of the animation
  26741. * @returns Easing function of the animation
  26742. */
  26743. getEasingFunction(): IEasingFunction;
  26744. /**
  26745. * Sets the easing function of the animation
  26746. * @param easingFunction A custom mathematical formula for animation
  26747. */
  26748. setEasingFunction(easingFunction: EasingFunction): void;
  26749. /**
  26750. * Interpolates a scalar linearly
  26751. * @param startValue Start value of the animation curve
  26752. * @param endValue End value of the animation curve
  26753. * @param gradient Scalar amount to interpolate
  26754. * @returns Interpolated scalar value
  26755. */
  26756. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26757. /**
  26758. * Interpolates a scalar cubically
  26759. * @param startValue Start value of the animation curve
  26760. * @param outTangent End tangent of the animation
  26761. * @param endValue End value of the animation curve
  26762. * @param inTangent Start tangent of the animation curve
  26763. * @param gradient Scalar amount to interpolate
  26764. * @returns Interpolated scalar value
  26765. */
  26766. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26767. /**
  26768. * Interpolates a quaternion using a spherical linear interpolation
  26769. * @param startValue Start value of the animation curve
  26770. * @param endValue End value of the animation curve
  26771. * @param gradient Scalar amount to interpolate
  26772. * @returns Interpolated quaternion value
  26773. */
  26774. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26775. /**
  26776. * Interpolates a quaternion cubically
  26777. * @param startValue Start value of the animation curve
  26778. * @param outTangent End tangent of the animation curve
  26779. * @param endValue End value of the animation curve
  26780. * @param inTangent Start tangent of the animation curve
  26781. * @param gradient Scalar amount to interpolate
  26782. * @returns Interpolated quaternion value
  26783. */
  26784. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26785. /**
  26786. * Interpolates a Vector3 linearl
  26787. * @param startValue Start value of the animation curve
  26788. * @param endValue End value of the animation curve
  26789. * @param gradient Scalar amount to interpolate
  26790. * @returns Interpolated scalar value
  26791. */
  26792. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26793. /**
  26794. * Interpolates a Vector3 cubically
  26795. * @param startValue Start value of the animation curve
  26796. * @param outTangent End tangent of the animation
  26797. * @param endValue End value of the animation curve
  26798. * @param inTangent Start tangent of the animation curve
  26799. * @param gradient Scalar amount to interpolate
  26800. * @returns InterpolatedVector3 value
  26801. */
  26802. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26803. /**
  26804. * Interpolates a Vector2 linearly
  26805. * @param startValue Start value of the animation curve
  26806. * @param endValue End value of the animation curve
  26807. * @param gradient Scalar amount to interpolate
  26808. * @returns Interpolated Vector2 value
  26809. */
  26810. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26811. /**
  26812. * Interpolates a Vector2 cubically
  26813. * @param startValue Start value of the animation curve
  26814. * @param outTangent End tangent of the animation
  26815. * @param endValue End value of the animation curve
  26816. * @param inTangent Start tangent of the animation curve
  26817. * @param gradient Scalar amount to interpolate
  26818. * @returns Interpolated Vector2 value
  26819. */
  26820. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26821. /**
  26822. * Interpolates a size linearly
  26823. * @param startValue Start value of the animation curve
  26824. * @param endValue End value of the animation curve
  26825. * @param gradient Scalar amount to interpolate
  26826. * @returns Interpolated Size value
  26827. */
  26828. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26829. /**
  26830. * Interpolates a Color3 linearly
  26831. * @param startValue Start value of the animation curve
  26832. * @param endValue End value of the animation curve
  26833. * @param gradient Scalar amount to interpolate
  26834. * @returns Interpolated Color3 value
  26835. */
  26836. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26837. /**
  26838. * @hidden Internal use only
  26839. */
  26840. _getKeyValue(value: any): any;
  26841. /**
  26842. * @hidden Internal use only
  26843. */
  26844. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26845. /**
  26846. * Defines the function to use to interpolate matrices
  26847. * @param startValue defines the start matrix
  26848. * @param endValue defines the end matrix
  26849. * @param gradient defines the gradient between both matrices
  26850. * @param result defines an optional target matrix where to store the interpolation
  26851. * @returns the interpolated matrix
  26852. */
  26853. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26854. /**
  26855. * Makes a copy of the animation
  26856. * @returns Cloned animation
  26857. */
  26858. clone(): Animation;
  26859. /**
  26860. * Sets the key frames of the animation
  26861. * @param values The animation key frames to set
  26862. */
  26863. setKeys(values: Array<IAnimationKey>): void;
  26864. /**
  26865. * Serializes the animation to an object
  26866. * @returns Serialized object
  26867. */
  26868. serialize(): any;
  26869. /**
  26870. * Float animation type
  26871. */
  26872. private static _ANIMATIONTYPE_FLOAT;
  26873. /**
  26874. * Vector3 animation type
  26875. */
  26876. private static _ANIMATIONTYPE_VECTOR3;
  26877. /**
  26878. * Quaternion animation type
  26879. */
  26880. private static _ANIMATIONTYPE_QUATERNION;
  26881. /**
  26882. * Matrix animation type
  26883. */
  26884. private static _ANIMATIONTYPE_MATRIX;
  26885. /**
  26886. * Color3 animation type
  26887. */
  26888. private static _ANIMATIONTYPE_COLOR3;
  26889. /**
  26890. * Vector2 animation type
  26891. */
  26892. private static _ANIMATIONTYPE_VECTOR2;
  26893. /**
  26894. * Size animation type
  26895. */
  26896. private static _ANIMATIONTYPE_SIZE;
  26897. /**
  26898. * Relative Loop Mode
  26899. */
  26900. private static _ANIMATIONLOOPMODE_RELATIVE;
  26901. /**
  26902. * Cycle Loop Mode
  26903. */
  26904. private static _ANIMATIONLOOPMODE_CYCLE;
  26905. /**
  26906. * Constant Loop Mode
  26907. */
  26908. private static _ANIMATIONLOOPMODE_CONSTANT;
  26909. /**
  26910. * Get the float animation type
  26911. */
  26912. static readonly ANIMATIONTYPE_FLOAT: number;
  26913. /**
  26914. * Get the Vector3 animation type
  26915. */
  26916. static readonly ANIMATIONTYPE_VECTOR3: number;
  26917. /**
  26918. * Get the Vector2 animation type
  26919. */
  26920. static readonly ANIMATIONTYPE_VECTOR2: number;
  26921. /**
  26922. * Get the Size animation type
  26923. */
  26924. static readonly ANIMATIONTYPE_SIZE: number;
  26925. /**
  26926. * Get the Quaternion animation type
  26927. */
  26928. static readonly ANIMATIONTYPE_QUATERNION: number;
  26929. /**
  26930. * Get the Matrix animation type
  26931. */
  26932. static readonly ANIMATIONTYPE_MATRIX: number;
  26933. /**
  26934. * Get the Color3 animation type
  26935. */
  26936. static readonly ANIMATIONTYPE_COLOR3: number;
  26937. /**
  26938. * Get the Relative Loop Mode
  26939. */
  26940. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26941. /**
  26942. * Get the Cycle Loop Mode
  26943. */
  26944. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26945. /**
  26946. * Get the Constant Loop Mode
  26947. */
  26948. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26949. /** @hidden */
  26950. static _UniversalLerp(left: any, right: any, amount: number): any;
  26951. /**
  26952. * Parses an animation object and creates an animation
  26953. * @param parsedAnimation Parsed animation object
  26954. * @returns Animation object
  26955. */
  26956. static Parse(parsedAnimation: any): Animation;
  26957. /**
  26958. * Appends the serialized animations from the source animations
  26959. * @param source Source containing the animations
  26960. * @param destination Target to store the animations
  26961. */
  26962. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26963. }
  26964. }
  26965. declare module "babylonjs/Materials/Textures/baseTexture" {
  26966. import { Observable } from "babylonjs/Misc/observable";
  26967. import { IAnimatable } from "babylonjs/Misc/tools";
  26968. import { Nullable } from "babylonjs/types";
  26969. import { Scene } from "babylonjs/scene";
  26970. import { Matrix, ISize } from "babylonjs/Maths/math";
  26971. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26973. /**
  26974. * Base class of all the textures in babylon.
  26975. * It groups all the common properties the materials, post process, lights... might need
  26976. * in order to make a correct use of the texture.
  26977. */
  26978. export class BaseTexture implements IAnimatable {
  26979. /**
  26980. * Default anisotropic filtering level for the application.
  26981. * It is set to 4 as a good tradeoff between perf and quality.
  26982. */
  26983. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26984. /**
  26985. * Gets or sets the unique id of the texture
  26986. */
  26987. uniqueId: number;
  26988. /**
  26989. * Define the name of the texture.
  26990. */
  26991. name: string;
  26992. /**
  26993. * Gets or sets an object used to store user defined information.
  26994. */
  26995. metadata: any;
  26996. /**
  26997. * For internal use only. Please do not use.
  26998. */
  26999. reservedDataStore: any;
  27000. private _hasAlpha;
  27001. /**
  27002. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27003. */
  27004. hasAlpha: boolean;
  27005. /**
  27006. * Defines if the alpha value should be determined via the rgb values.
  27007. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27008. */
  27009. getAlphaFromRGB: boolean;
  27010. /**
  27011. * Intensity or strength of the texture.
  27012. * It is commonly used by materials to fine tune the intensity of the texture
  27013. */
  27014. level: number;
  27015. /**
  27016. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27017. * This is part of the texture as textures usually maps to one uv set.
  27018. */
  27019. coordinatesIndex: number;
  27020. private _coordinatesMode;
  27021. /**
  27022. * How a texture is mapped.
  27023. *
  27024. * | Value | Type | Description |
  27025. * | ----- | ----------------------------------- | ----------- |
  27026. * | 0 | EXPLICIT_MODE | |
  27027. * | 1 | SPHERICAL_MODE | |
  27028. * | 2 | PLANAR_MODE | |
  27029. * | 3 | CUBIC_MODE | |
  27030. * | 4 | PROJECTION_MODE | |
  27031. * | 5 | SKYBOX_MODE | |
  27032. * | 6 | INVCUBIC_MODE | |
  27033. * | 7 | EQUIRECTANGULAR_MODE | |
  27034. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27035. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27036. */
  27037. coordinatesMode: number;
  27038. /**
  27039. * | Value | Type | Description |
  27040. * | ----- | ------------------ | ----------- |
  27041. * | 0 | CLAMP_ADDRESSMODE | |
  27042. * | 1 | WRAP_ADDRESSMODE | |
  27043. * | 2 | MIRROR_ADDRESSMODE | |
  27044. */
  27045. wrapU: number;
  27046. /**
  27047. * | Value | Type | Description |
  27048. * | ----- | ------------------ | ----------- |
  27049. * | 0 | CLAMP_ADDRESSMODE | |
  27050. * | 1 | WRAP_ADDRESSMODE | |
  27051. * | 2 | MIRROR_ADDRESSMODE | |
  27052. */
  27053. wrapV: number;
  27054. /**
  27055. * | Value | Type | Description |
  27056. * | ----- | ------------------ | ----------- |
  27057. * | 0 | CLAMP_ADDRESSMODE | |
  27058. * | 1 | WRAP_ADDRESSMODE | |
  27059. * | 2 | MIRROR_ADDRESSMODE | |
  27060. */
  27061. wrapR: number;
  27062. /**
  27063. * With compliant hardware and browser (supporting anisotropic filtering)
  27064. * this defines the level of anisotropic filtering in the texture.
  27065. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27066. */
  27067. anisotropicFilteringLevel: number;
  27068. /**
  27069. * Define if the texture is a cube texture or if false a 2d texture.
  27070. */
  27071. isCube: boolean;
  27072. /**
  27073. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27074. */
  27075. is3D: boolean;
  27076. /**
  27077. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27078. * HDR texture are usually stored in linear space.
  27079. * This only impacts the PBR and Background materials
  27080. */
  27081. gammaSpace: boolean;
  27082. /**
  27083. * Gets whether or not the texture contains RGBD data.
  27084. */
  27085. readonly isRGBD: boolean;
  27086. /**
  27087. * Is Z inverted in the texture (useful in a cube texture).
  27088. */
  27089. invertZ: boolean;
  27090. /**
  27091. * Are mip maps generated for this texture or not.
  27092. */
  27093. readonly noMipmap: boolean;
  27094. /**
  27095. * @hidden
  27096. */
  27097. lodLevelInAlpha: boolean;
  27098. /**
  27099. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27100. */
  27101. lodGenerationOffset: number;
  27102. /**
  27103. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27104. */
  27105. lodGenerationScale: number;
  27106. /**
  27107. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27108. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27109. * average roughness values.
  27110. */
  27111. linearSpecularLOD: boolean;
  27112. /**
  27113. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27114. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27115. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27116. */
  27117. irradianceTexture: Nullable<BaseTexture>;
  27118. /**
  27119. * Define if the texture is a render target.
  27120. */
  27121. isRenderTarget: boolean;
  27122. /**
  27123. * Define the unique id of the texture in the scene.
  27124. */
  27125. readonly uid: string;
  27126. /**
  27127. * Return a string representation of the texture.
  27128. * @returns the texture as a string
  27129. */
  27130. toString(): string;
  27131. /**
  27132. * Get the class name of the texture.
  27133. * @returns "BaseTexture"
  27134. */
  27135. getClassName(): string;
  27136. /**
  27137. * Define the list of animation attached to the texture.
  27138. */
  27139. animations: import("babylonjs/Animations/animation").Animation[];
  27140. /**
  27141. * An event triggered when the texture is disposed.
  27142. */
  27143. onDisposeObservable: Observable<BaseTexture>;
  27144. private _onDisposeObserver;
  27145. /**
  27146. * Callback triggered when the texture has been disposed.
  27147. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27148. */
  27149. onDispose: () => void;
  27150. /**
  27151. * Define the current state of the loading sequence when in delayed load mode.
  27152. */
  27153. delayLoadState: number;
  27154. private _scene;
  27155. /** @hidden */
  27156. _texture: Nullable<InternalTexture>;
  27157. private _uid;
  27158. /**
  27159. * Define if the texture is preventinga material to render or not.
  27160. * If not and the texture is not ready, the engine will use a default black texture instead.
  27161. */
  27162. readonly isBlocking: boolean;
  27163. /**
  27164. * Instantiates a new BaseTexture.
  27165. * Base class of all the textures in babylon.
  27166. * It groups all the common properties the materials, post process, lights... might need
  27167. * in order to make a correct use of the texture.
  27168. * @param scene Define the scene the texture blongs to
  27169. */
  27170. constructor(scene: Nullable<Scene>);
  27171. /**
  27172. * Get the scene the texture belongs to.
  27173. * @returns the scene or null if undefined
  27174. */
  27175. getScene(): Nullable<Scene>;
  27176. /**
  27177. * Get the texture transform matrix used to offset tile the texture for istance.
  27178. * @returns the transformation matrix
  27179. */
  27180. getTextureMatrix(): Matrix;
  27181. /**
  27182. * Get the texture reflection matrix used to rotate/transform the reflection.
  27183. * @returns the reflection matrix
  27184. */
  27185. getReflectionTextureMatrix(): Matrix;
  27186. /**
  27187. * Get the underlying lower level texture from Babylon.
  27188. * @returns the insternal texture
  27189. */
  27190. getInternalTexture(): Nullable<InternalTexture>;
  27191. /**
  27192. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27193. * @returns true if ready or not blocking
  27194. */
  27195. isReadyOrNotBlocking(): boolean;
  27196. /**
  27197. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27198. * @returns true if fully ready
  27199. */
  27200. isReady(): boolean;
  27201. private _cachedSize;
  27202. /**
  27203. * Get the size of the texture.
  27204. * @returns the texture size.
  27205. */
  27206. getSize(): ISize;
  27207. /**
  27208. * Get the base size of the texture.
  27209. * It can be different from the size if the texture has been resized for POT for instance
  27210. * @returns the base size
  27211. */
  27212. getBaseSize(): ISize;
  27213. /**
  27214. * Update the sampling mode of the texture.
  27215. * Default is Trilinear mode.
  27216. *
  27217. * | Value | Type | Description |
  27218. * | ----- | ------------------ | ----------- |
  27219. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27220. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27221. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27222. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27223. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27224. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27225. * | 7 | NEAREST_LINEAR | |
  27226. * | 8 | NEAREST_NEAREST | |
  27227. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27228. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27229. * | 11 | LINEAR_LINEAR | |
  27230. * | 12 | LINEAR_NEAREST | |
  27231. *
  27232. * > _mag_: magnification filter (close to the viewer)
  27233. * > _min_: minification filter (far from the viewer)
  27234. * > _mip_: filter used between mip map levels
  27235. *@param samplingMode Define the new sampling mode of the texture
  27236. */
  27237. updateSamplingMode(samplingMode: number): void;
  27238. /**
  27239. * Scales the texture if is `canRescale()`
  27240. * @param ratio the resize factor we want to use to rescale
  27241. */
  27242. scale(ratio: number): void;
  27243. /**
  27244. * Get if the texture can rescale.
  27245. */
  27246. readonly canRescale: boolean;
  27247. /** @hidden */
  27248. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27249. /** @hidden */
  27250. _rebuild(): void;
  27251. /**
  27252. * Triggers the load sequence in delayed load mode.
  27253. */
  27254. delayLoad(): void;
  27255. /**
  27256. * Clones the texture.
  27257. * @returns the cloned texture
  27258. */
  27259. clone(): Nullable<BaseTexture>;
  27260. /**
  27261. * Get the texture underlying type (INT, FLOAT...)
  27262. */
  27263. readonly textureType: number;
  27264. /**
  27265. * Get the texture underlying format (RGB, RGBA...)
  27266. */
  27267. readonly textureFormat: number;
  27268. /**
  27269. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27270. * This will returns an RGBA array buffer containing either in values (0-255) or
  27271. * float values (0-1) depending of the underlying buffer type.
  27272. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27273. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27274. * @param buffer defines a user defined buffer to fill with data (can be null)
  27275. * @returns The Array buffer containing the pixels data.
  27276. */
  27277. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27278. /**
  27279. * Release and destroy the underlying lower level texture aka internalTexture.
  27280. */
  27281. releaseInternalTexture(): void;
  27282. /**
  27283. * Get the polynomial representation of the texture data.
  27284. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27285. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27286. */
  27287. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27288. /** @hidden */
  27289. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27290. /** @hidden */
  27291. readonly _lodTextureMid: Nullable<BaseTexture>;
  27292. /** @hidden */
  27293. readonly _lodTextureLow: Nullable<BaseTexture>;
  27294. /**
  27295. * Dispose the texture and release its associated resources.
  27296. */
  27297. dispose(): void;
  27298. /**
  27299. * Serialize the texture into a JSON representation that can be parsed later on.
  27300. * @returns the JSON representation of the texture
  27301. */
  27302. serialize(): any;
  27303. /**
  27304. * Helper function to be called back once a list of texture contains only ready textures.
  27305. * @param textures Define the list of textures to wait for
  27306. * @param callback Define the callback triggered once the entire list will be ready
  27307. */
  27308. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27309. }
  27310. }
  27311. declare module "babylonjs/Materials/uniformBuffer" {
  27312. import { Nullable, FloatArray } from "babylonjs/types";
  27313. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27314. import { Engine } from "babylonjs/Engines/engine";
  27315. import { Effect } from "babylonjs/Materials/effect";
  27316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27317. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27318. /**
  27319. * Uniform buffer objects.
  27320. *
  27321. * Handles blocks of uniform on the GPU.
  27322. *
  27323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27324. *
  27325. * For more information, please refer to :
  27326. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27327. */
  27328. export class UniformBuffer {
  27329. private _engine;
  27330. private _buffer;
  27331. private _data;
  27332. private _bufferData;
  27333. private _dynamic?;
  27334. private _uniformLocations;
  27335. private _uniformSizes;
  27336. private _uniformLocationPointer;
  27337. private _needSync;
  27338. private _noUBO;
  27339. private _currentEffect;
  27340. private static _MAX_UNIFORM_SIZE;
  27341. private static _tempBuffer;
  27342. /**
  27343. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27344. * This is dynamic to allow compat with webgl 1 and 2.
  27345. * You will need to pass the name of the uniform as well as the value.
  27346. */
  27347. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27348. /**
  27349. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27350. * This is dynamic to allow compat with webgl 1 and 2.
  27351. * You will need to pass the name of the uniform as well as the value.
  27352. */
  27353. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27354. /**
  27355. * Lambda to Update a single float in a uniform buffer.
  27356. * This is dynamic to allow compat with webgl 1 and 2.
  27357. * You will need to pass the name of the uniform as well as the value.
  27358. */
  27359. updateFloat: (name: string, x: number) => void;
  27360. /**
  27361. * Lambda to Update a vec2 of float in a uniform buffer.
  27362. * This is dynamic to allow compat with webgl 1 and 2.
  27363. * You will need to pass the name of the uniform as well as the value.
  27364. */
  27365. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27366. /**
  27367. * Lambda to Update a vec3 of float in a uniform buffer.
  27368. * This is dynamic to allow compat with webgl 1 and 2.
  27369. * You will need to pass the name of the uniform as well as the value.
  27370. */
  27371. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27372. /**
  27373. * Lambda to Update a vec4 of float in a uniform buffer.
  27374. * This is dynamic to allow compat with webgl 1 and 2.
  27375. * You will need to pass the name of the uniform as well as the value.
  27376. */
  27377. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27378. /**
  27379. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27380. * This is dynamic to allow compat with webgl 1 and 2.
  27381. * You will need to pass the name of the uniform as well as the value.
  27382. */
  27383. updateMatrix: (name: string, mat: Matrix) => void;
  27384. /**
  27385. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27386. * This is dynamic to allow compat with webgl 1 and 2.
  27387. * You will need to pass the name of the uniform as well as the value.
  27388. */
  27389. updateVector3: (name: string, vector: Vector3) => void;
  27390. /**
  27391. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27392. * This is dynamic to allow compat with webgl 1 and 2.
  27393. * You will need to pass the name of the uniform as well as the value.
  27394. */
  27395. updateVector4: (name: string, vector: Vector4) => void;
  27396. /**
  27397. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27398. * This is dynamic to allow compat with webgl 1 and 2.
  27399. * You will need to pass the name of the uniform as well as the value.
  27400. */
  27401. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27402. /**
  27403. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27404. * This is dynamic to allow compat with webgl 1 and 2.
  27405. * You will need to pass the name of the uniform as well as the value.
  27406. */
  27407. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27408. /**
  27409. * Instantiates a new Uniform buffer objects.
  27410. *
  27411. * Handles blocks of uniform on the GPU.
  27412. *
  27413. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27414. *
  27415. * For more information, please refer to :
  27416. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27417. * @param engine Define the engine the buffer is associated with
  27418. * @param data Define the data contained in the buffer
  27419. * @param dynamic Define if the buffer is updatable
  27420. */
  27421. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27422. /**
  27423. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27424. * or just falling back on setUniformXXX calls.
  27425. */
  27426. readonly useUbo: boolean;
  27427. /**
  27428. * Indicates if the WebGL underlying uniform buffer is in sync
  27429. * with the javascript cache data.
  27430. */
  27431. readonly isSync: boolean;
  27432. /**
  27433. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27434. * Also, a dynamic UniformBuffer will disable cache verification and always
  27435. * update the underlying WebGL uniform buffer to the GPU.
  27436. * @returns if Dynamic, otherwise false
  27437. */
  27438. isDynamic(): boolean;
  27439. /**
  27440. * The data cache on JS side.
  27441. * @returns the underlying data as a float array
  27442. */
  27443. getData(): Float32Array;
  27444. /**
  27445. * The underlying WebGL Uniform buffer.
  27446. * @returns the webgl buffer
  27447. */
  27448. getBuffer(): Nullable<DataBuffer>;
  27449. /**
  27450. * std140 layout specifies how to align data within an UBO structure.
  27451. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27452. * for specs.
  27453. */
  27454. private _fillAlignment;
  27455. /**
  27456. * Adds an uniform in the buffer.
  27457. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27458. * for the layout to be correct !
  27459. * @param name Name of the uniform, as used in the uniform block in the shader.
  27460. * @param size Data size, or data directly.
  27461. */
  27462. addUniform(name: string, size: number | number[]): void;
  27463. /**
  27464. * Adds a Matrix 4x4 to the uniform buffer.
  27465. * @param name Name of the uniform, as used in the uniform block in the shader.
  27466. * @param mat A 4x4 matrix.
  27467. */
  27468. addMatrix(name: string, mat: Matrix): void;
  27469. /**
  27470. * Adds a vec2 to the uniform buffer.
  27471. * @param name Name of the uniform, as used in the uniform block in the shader.
  27472. * @param x Define the x component value of the vec2
  27473. * @param y Define the y component value of the vec2
  27474. */
  27475. addFloat2(name: string, x: number, y: number): void;
  27476. /**
  27477. * Adds a vec3 to the uniform buffer.
  27478. * @param name Name of the uniform, as used in the uniform block in the shader.
  27479. * @param x Define the x component value of the vec3
  27480. * @param y Define the y component value of the vec3
  27481. * @param z Define the z component value of the vec3
  27482. */
  27483. addFloat3(name: string, x: number, y: number, z: number): void;
  27484. /**
  27485. * Adds a vec3 to the uniform buffer.
  27486. * @param name Name of the uniform, as used in the uniform block in the shader.
  27487. * @param color Define the vec3 from a Color
  27488. */
  27489. addColor3(name: string, color: Color3): void;
  27490. /**
  27491. * Adds a vec4 to the uniform buffer.
  27492. * @param name Name of the uniform, as used in the uniform block in the shader.
  27493. * @param color Define the rgb components from a Color
  27494. * @param alpha Define the a component of the vec4
  27495. */
  27496. addColor4(name: string, color: Color3, alpha: number): void;
  27497. /**
  27498. * Adds a vec3 to the uniform buffer.
  27499. * @param name Name of the uniform, as used in the uniform block in the shader.
  27500. * @param vector Define the vec3 components from a Vector
  27501. */
  27502. addVector3(name: string, vector: Vector3): void;
  27503. /**
  27504. * Adds a Matrix 3x3 to the uniform buffer.
  27505. * @param name Name of the uniform, as used in the uniform block in the shader.
  27506. */
  27507. addMatrix3x3(name: string): void;
  27508. /**
  27509. * Adds a Matrix 2x2 to the uniform buffer.
  27510. * @param name Name of the uniform, as used in the uniform block in the shader.
  27511. */
  27512. addMatrix2x2(name: string): void;
  27513. /**
  27514. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27515. */
  27516. create(): void;
  27517. /** @hidden */
  27518. _rebuild(): void;
  27519. /**
  27520. * Updates the WebGL Uniform Buffer on the GPU.
  27521. * If the `dynamic` flag is set to true, no cache comparison is done.
  27522. * Otherwise, the buffer will be updated only if the cache differs.
  27523. */
  27524. update(): void;
  27525. /**
  27526. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27527. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27528. * @param data Define the flattened data
  27529. * @param size Define the size of the data.
  27530. */
  27531. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27532. private _updateMatrix3x3ForUniform;
  27533. private _updateMatrix3x3ForEffect;
  27534. private _updateMatrix2x2ForEffect;
  27535. private _updateMatrix2x2ForUniform;
  27536. private _updateFloatForEffect;
  27537. private _updateFloatForUniform;
  27538. private _updateFloat2ForEffect;
  27539. private _updateFloat2ForUniform;
  27540. private _updateFloat3ForEffect;
  27541. private _updateFloat3ForUniform;
  27542. private _updateFloat4ForEffect;
  27543. private _updateFloat4ForUniform;
  27544. private _updateMatrixForEffect;
  27545. private _updateMatrixForUniform;
  27546. private _updateVector3ForEffect;
  27547. private _updateVector3ForUniform;
  27548. private _updateVector4ForEffect;
  27549. private _updateVector4ForUniform;
  27550. private _updateColor3ForEffect;
  27551. private _updateColor3ForUniform;
  27552. private _updateColor4ForEffect;
  27553. private _updateColor4ForUniform;
  27554. /**
  27555. * Sets a sampler uniform on the effect.
  27556. * @param name Define the name of the sampler.
  27557. * @param texture Define the texture to set in the sampler
  27558. */
  27559. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27560. /**
  27561. * Directly updates the value of the uniform in the cache AND on the GPU.
  27562. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27563. * @param data Define the flattened data
  27564. */
  27565. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27566. /**
  27567. * Binds this uniform buffer to an effect.
  27568. * @param effect Define the effect to bind the buffer to
  27569. * @param name Name of the uniform block in the shader.
  27570. */
  27571. bindToEffect(effect: Effect, name: string): void;
  27572. /**
  27573. * Disposes the uniform buffer.
  27574. */
  27575. dispose(): void;
  27576. }
  27577. }
  27578. declare module "babylonjs/Audio/analyser" {
  27579. import { Scene } from "babylonjs/scene";
  27580. /**
  27581. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27583. */
  27584. export class Analyser {
  27585. /**
  27586. * Gets or sets the smoothing
  27587. * @ignorenaming
  27588. */
  27589. SMOOTHING: number;
  27590. /**
  27591. * Gets or sets the FFT table size
  27592. * @ignorenaming
  27593. */
  27594. FFT_SIZE: number;
  27595. /**
  27596. * Gets or sets the bar graph amplitude
  27597. * @ignorenaming
  27598. */
  27599. BARGRAPHAMPLITUDE: number;
  27600. /**
  27601. * Gets or sets the position of the debug canvas
  27602. * @ignorenaming
  27603. */
  27604. DEBUGCANVASPOS: {
  27605. x: number;
  27606. y: number;
  27607. };
  27608. /**
  27609. * Gets or sets the debug canvas size
  27610. * @ignorenaming
  27611. */
  27612. DEBUGCANVASSIZE: {
  27613. width: number;
  27614. height: number;
  27615. };
  27616. private _byteFreqs;
  27617. private _byteTime;
  27618. private _floatFreqs;
  27619. private _webAudioAnalyser;
  27620. private _debugCanvas;
  27621. private _debugCanvasContext;
  27622. private _scene;
  27623. private _registerFunc;
  27624. private _audioEngine;
  27625. /**
  27626. * Creates a new analyser
  27627. * @param scene defines hosting scene
  27628. */
  27629. constructor(scene: Scene);
  27630. /**
  27631. * Get the number of data values you will have to play with for the visualization
  27632. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27633. * @returns a number
  27634. */
  27635. getFrequencyBinCount(): number;
  27636. /**
  27637. * Gets the current frequency data as a byte array
  27638. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27639. * @returns a Uint8Array
  27640. */
  27641. getByteFrequencyData(): Uint8Array;
  27642. /**
  27643. * Gets the current waveform as a byte array
  27644. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27645. * @returns a Uint8Array
  27646. */
  27647. getByteTimeDomainData(): Uint8Array;
  27648. /**
  27649. * Gets the current frequency data as a float array
  27650. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27651. * @returns a Float32Array
  27652. */
  27653. getFloatFrequencyData(): Float32Array;
  27654. /**
  27655. * Renders the debug canvas
  27656. */
  27657. drawDebugCanvas(): void;
  27658. /**
  27659. * Stops rendering the debug canvas and removes it
  27660. */
  27661. stopDebugCanvas(): void;
  27662. /**
  27663. * Connects two audio nodes
  27664. * @param inputAudioNode defines first node to connect
  27665. * @param outputAudioNode defines second node to connect
  27666. */
  27667. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27668. /**
  27669. * Releases all associated resources
  27670. */
  27671. dispose(): void;
  27672. }
  27673. }
  27674. declare module "babylonjs/Audio/audioEngine" {
  27675. import { IDisposable } from "babylonjs/scene";
  27676. import { Analyser } from "babylonjs/Audio/analyser";
  27677. import { Nullable } from "babylonjs/types";
  27678. import { Observable } from "babylonjs/Misc/observable";
  27679. /**
  27680. * This represents an audio engine and it is responsible
  27681. * to play, synchronize and analyse sounds throughout the application.
  27682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27683. */
  27684. export interface IAudioEngine extends IDisposable {
  27685. /**
  27686. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27687. */
  27688. readonly canUseWebAudio: boolean;
  27689. /**
  27690. * Gets the current AudioContext if available.
  27691. */
  27692. readonly audioContext: Nullable<AudioContext>;
  27693. /**
  27694. * The master gain node defines the global audio volume of your audio engine.
  27695. */
  27696. readonly masterGain: GainNode;
  27697. /**
  27698. * Gets whether or not mp3 are supported by your browser.
  27699. */
  27700. readonly isMP3supported: boolean;
  27701. /**
  27702. * Gets whether or not ogg are supported by your browser.
  27703. */
  27704. readonly isOGGsupported: boolean;
  27705. /**
  27706. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27707. * @ignoreNaming
  27708. */
  27709. WarnedWebAudioUnsupported: boolean;
  27710. /**
  27711. * Defines if the audio engine relies on a custom unlocked button.
  27712. * In this case, the embedded button will not be displayed.
  27713. */
  27714. useCustomUnlockedButton: boolean;
  27715. /**
  27716. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27717. */
  27718. readonly unlocked: boolean;
  27719. /**
  27720. * Event raised when audio has been unlocked on the browser.
  27721. */
  27722. onAudioUnlockedObservable: Observable<AudioEngine>;
  27723. /**
  27724. * Event raised when audio has been locked on the browser.
  27725. */
  27726. onAudioLockedObservable: Observable<AudioEngine>;
  27727. /**
  27728. * Flags the audio engine in Locked state.
  27729. * This happens due to new browser policies preventing audio to autoplay.
  27730. */
  27731. lock(): void;
  27732. /**
  27733. * Unlocks the audio engine once a user action has been done on the dom.
  27734. * This is helpful to resume play once browser policies have been satisfied.
  27735. */
  27736. unlock(): void;
  27737. }
  27738. /**
  27739. * This represents the default audio engine used in babylon.
  27740. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27742. */
  27743. export class AudioEngine implements IAudioEngine {
  27744. private _audioContext;
  27745. private _audioContextInitialized;
  27746. private _muteButton;
  27747. private _hostElement;
  27748. /**
  27749. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27750. */
  27751. canUseWebAudio: boolean;
  27752. /**
  27753. * The master gain node defines the global audio volume of your audio engine.
  27754. */
  27755. masterGain: GainNode;
  27756. /**
  27757. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27758. * @ignoreNaming
  27759. */
  27760. WarnedWebAudioUnsupported: boolean;
  27761. /**
  27762. * Gets whether or not mp3 are supported by your browser.
  27763. */
  27764. isMP3supported: boolean;
  27765. /**
  27766. * Gets whether or not ogg are supported by your browser.
  27767. */
  27768. isOGGsupported: boolean;
  27769. /**
  27770. * Gets whether audio has been unlocked on the device.
  27771. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27772. * a user interaction has happened.
  27773. */
  27774. unlocked: boolean;
  27775. /**
  27776. * Defines if the audio engine relies on a custom unlocked button.
  27777. * In this case, the embedded button will not be displayed.
  27778. */
  27779. useCustomUnlockedButton: boolean;
  27780. /**
  27781. * Event raised when audio has been unlocked on the browser.
  27782. */
  27783. onAudioUnlockedObservable: Observable<AudioEngine>;
  27784. /**
  27785. * Event raised when audio has been locked on the browser.
  27786. */
  27787. onAudioLockedObservable: Observable<AudioEngine>;
  27788. /**
  27789. * Gets the current AudioContext if available.
  27790. */
  27791. readonly audioContext: Nullable<AudioContext>;
  27792. private _connectedAnalyser;
  27793. /**
  27794. * Instantiates a new audio engine.
  27795. *
  27796. * There should be only one per page as some browsers restrict the number
  27797. * of audio contexts you can create.
  27798. * @param hostElement defines the host element where to display the mute icon if necessary
  27799. */
  27800. constructor(hostElement?: Nullable<HTMLElement>);
  27801. /**
  27802. * Flags the audio engine in Locked state.
  27803. * This happens due to new browser policies preventing audio to autoplay.
  27804. */
  27805. lock(): void;
  27806. /**
  27807. * Unlocks the audio engine once a user action has been done on the dom.
  27808. * This is helpful to resume play once browser policies have been satisfied.
  27809. */
  27810. unlock(): void;
  27811. private _resumeAudioContext;
  27812. private _initializeAudioContext;
  27813. private _tryToRun;
  27814. private _triggerRunningState;
  27815. private _triggerSuspendedState;
  27816. private _displayMuteButton;
  27817. private _moveButtonToTopLeft;
  27818. private _onResize;
  27819. private _hideMuteButton;
  27820. /**
  27821. * Destroy and release the resources associated with the audio ccontext.
  27822. */
  27823. dispose(): void;
  27824. /**
  27825. * Gets the global volume sets on the master gain.
  27826. * @returns the global volume if set or -1 otherwise
  27827. */
  27828. getGlobalVolume(): number;
  27829. /**
  27830. * Sets the global volume of your experience (sets on the master gain).
  27831. * @param newVolume Defines the new global volume of the application
  27832. */
  27833. setGlobalVolume(newVolume: number): void;
  27834. /**
  27835. * Connect the audio engine to an audio analyser allowing some amazing
  27836. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27838. * @param analyser The analyser to connect to the engine
  27839. */
  27840. connectToAnalyser(analyser: Analyser): void;
  27841. }
  27842. }
  27843. declare module "babylonjs/Loading/loadingScreen" {
  27844. /**
  27845. * Interface used to present a loading screen while loading a scene
  27846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27847. */
  27848. export interface ILoadingScreen {
  27849. /**
  27850. * Function called to display the loading screen
  27851. */
  27852. displayLoadingUI: () => void;
  27853. /**
  27854. * Function called to hide the loading screen
  27855. */
  27856. hideLoadingUI: () => void;
  27857. /**
  27858. * Gets or sets the color to use for the background
  27859. */
  27860. loadingUIBackgroundColor: string;
  27861. /**
  27862. * Gets or sets the text to display while loading
  27863. */
  27864. loadingUIText: string;
  27865. }
  27866. /**
  27867. * Class used for the default loading screen
  27868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27869. */
  27870. export class DefaultLoadingScreen implements ILoadingScreen {
  27871. private _renderingCanvas;
  27872. private _loadingText;
  27873. private _loadingDivBackgroundColor;
  27874. private _loadingDiv;
  27875. private _loadingTextDiv;
  27876. /** Gets or sets the logo url to use for the default loading screen */
  27877. static DefaultLogoUrl: string;
  27878. /** Gets or sets the spinner url to use for the default loading screen */
  27879. static DefaultSpinnerUrl: string;
  27880. /**
  27881. * Creates a new default loading screen
  27882. * @param _renderingCanvas defines the canvas used to render the scene
  27883. * @param _loadingText defines the default text to display
  27884. * @param _loadingDivBackgroundColor defines the default background color
  27885. */
  27886. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27887. /**
  27888. * Function called to display the loading screen
  27889. */
  27890. displayLoadingUI(): void;
  27891. /**
  27892. * Function called to hide the loading screen
  27893. */
  27894. hideLoadingUI(): void;
  27895. /**
  27896. * Gets or sets the text to display while loading
  27897. */
  27898. loadingUIText: string;
  27899. /**
  27900. * Gets or sets the color to use for the background
  27901. */
  27902. loadingUIBackgroundColor: string;
  27903. private _resizeLoadingUI;
  27904. }
  27905. }
  27906. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27907. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27908. import { Engine } from "babylonjs/Engines/engine";
  27909. import { Nullable } from "babylonjs/types";
  27910. /** @hidden */
  27911. export class WebGLPipelineContext implements IPipelineContext {
  27912. engine: Engine;
  27913. program: Nullable<WebGLProgram>;
  27914. context?: WebGLRenderingContext;
  27915. vertexShader?: WebGLShader;
  27916. fragmentShader?: WebGLShader;
  27917. isParallelCompiled: boolean;
  27918. onCompiled?: () => void;
  27919. transformFeedback?: WebGLTransformFeedback | null;
  27920. readonly isAsync: boolean;
  27921. readonly isReady: boolean;
  27922. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27923. }
  27924. }
  27925. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27926. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27927. /** @hidden */
  27928. export class WebGLDataBuffer extends DataBuffer {
  27929. private _buffer;
  27930. constructor(resource: WebGLBuffer);
  27931. readonly underlyingResource: any;
  27932. }
  27933. }
  27934. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27935. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27936. /** @hidden */
  27937. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27938. attributeProcessor(attribute: string): string;
  27939. varyingProcessor(varying: string, isFragment: boolean): string;
  27940. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27941. }
  27942. }
  27943. declare module "babylonjs/Materials/Textures/videoTexture" {
  27944. import { Observable } from "babylonjs/Misc/observable";
  27945. import { Nullable } from "babylonjs/types";
  27946. import { Scene } from "babylonjs/scene";
  27947. import { Texture } from "babylonjs/Materials/Textures/texture";
  27948. /**
  27949. * Settings for finer control over video usage
  27950. */
  27951. export interface VideoTextureSettings {
  27952. /**
  27953. * Applies `autoplay` to video, if specified
  27954. */
  27955. autoPlay?: boolean;
  27956. /**
  27957. * Applies `loop` to video, if specified
  27958. */
  27959. loop?: boolean;
  27960. /**
  27961. * Automatically updates internal texture from video at every frame in the render loop
  27962. */
  27963. autoUpdateTexture: boolean;
  27964. /**
  27965. * Image src displayed during the video loading or until the user interacts with the video.
  27966. */
  27967. poster?: string;
  27968. }
  27969. /**
  27970. * If you want to display a video in your scene, this is the special texture for that.
  27971. * This special texture works similar to other textures, with the exception of a few parameters.
  27972. * @see https://doc.babylonjs.com/how_to/video_texture
  27973. */
  27974. export class VideoTexture extends Texture {
  27975. /**
  27976. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27977. */
  27978. readonly autoUpdateTexture: boolean;
  27979. /**
  27980. * The video instance used by the texture internally
  27981. */
  27982. readonly video: HTMLVideoElement;
  27983. private _onUserActionRequestedObservable;
  27984. /**
  27985. * Event triggerd when a dom action is required by the user to play the video.
  27986. * This happens due to recent changes in browser policies preventing video to auto start.
  27987. */
  27988. readonly onUserActionRequestedObservable: Observable<Texture>;
  27989. private _generateMipMaps;
  27990. private _engine;
  27991. private _stillImageCaptured;
  27992. private _displayingPosterTexture;
  27993. private _settings;
  27994. private _createInternalTextureOnEvent;
  27995. /**
  27996. * Creates a video texture.
  27997. * If you want to display a video in your scene, this is the special texture for that.
  27998. * This special texture works similar to other textures, with the exception of a few parameters.
  27999. * @see https://doc.babylonjs.com/how_to/video_texture
  28000. * @param name optional name, will detect from video source, if not defined
  28001. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28002. * @param scene is obviously the current scene.
  28003. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28004. * @param invertY is false by default but can be used to invert video on Y axis
  28005. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28006. * @param settings allows finer control over video usage
  28007. */
  28008. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28009. private _getName;
  28010. private _getVideo;
  28011. private _createInternalTexture;
  28012. private reset;
  28013. /**
  28014. * @hidden Internal method to initiate `update`.
  28015. */
  28016. _rebuild(): void;
  28017. /**
  28018. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28019. */
  28020. update(): void;
  28021. /**
  28022. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28023. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28024. */
  28025. updateTexture(isVisible: boolean): void;
  28026. protected _updateInternalTexture: () => void;
  28027. /**
  28028. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28029. * @param url New url.
  28030. */
  28031. updateURL(url: string): void;
  28032. /**
  28033. * Dispose the texture and release its associated resources.
  28034. */
  28035. dispose(): void;
  28036. /**
  28037. * Creates a video texture straight from a stream.
  28038. * @param scene Define the scene the texture should be created in
  28039. * @param stream Define the stream the texture should be created from
  28040. * @returns The created video texture as a promise
  28041. */
  28042. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28043. /**
  28044. * Creates a video texture straight from your WebCam video feed.
  28045. * @param scene Define the scene the texture should be created in
  28046. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28047. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28048. * @returns The created video texture as a promise
  28049. */
  28050. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28051. minWidth: number;
  28052. maxWidth: number;
  28053. minHeight: number;
  28054. maxHeight: number;
  28055. deviceId: string;
  28056. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28057. /**
  28058. * Creates a video texture straight from your WebCam video feed.
  28059. * @param scene Define the scene the texture should be created in
  28060. * @param onReady Define a callback to triggered once the texture will be ready
  28061. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28062. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28063. */
  28064. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28065. minWidth: number;
  28066. maxWidth: number;
  28067. minHeight: number;
  28068. maxHeight: number;
  28069. deviceId: string;
  28070. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28071. }
  28072. }
  28073. declare module "babylonjs/Engines/engine" {
  28074. import { Observable } from "babylonjs/Misc/observable";
  28075. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28076. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28077. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28078. import { Camera } from "babylonjs/Cameras/camera";
  28079. import { Scene } from "babylonjs/scene";
  28080. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28081. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28082. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28083. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28084. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28085. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28087. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28088. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28089. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28090. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28091. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28092. import { WebRequest } from "babylonjs/Misc/webRequest";
  28093. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28094. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28095. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28096. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28097. import { Material } from "babylonjs/Materials/material";
  28098. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28100. /**
  28101. * Interface for attribute information associated with buffer instanciation
  28102. */
  28103. export class InstancingAttributeInfo {
  28104. /**
  28105. * Index/offset of the attribute in the vertex shader
  28106. */
  28107. index: number;
  28108. /**
  28109. * size of the attribute, 1, 2, 3 or 4
  28110. */
  28111. attributeSize: number;
  28112. /**
  28113. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28114. * default is FLOAT
  28115. */
  28116. attribyteType: number;
  28117. /**
  28118. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28119. */
  28120. normalized: boolean;
  28121. /**
  28122. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28123. */
  28124. offset: number;
  28125. /**
  28126. * Name of the GLSL attribute, for debugging purpose only
  28127. */
  28128. attributeName: string;
  28129. }
  28130. /**
  28131. * Define options used to create a depth texture
  28132. */
  28133. export class DepthTextureCreationOptions {
  28134. /** Specifies whether or not a stencil should be allocated in the texture */
  28135. generateStencil?: boolean;
  28136. /** Specifies whether or not bilinear filtering is enable on the texture */
  28137. bilinearFiltering?: boolean;
  28138. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28139. comparisonFunction?: number;
  28140. /** Specifies if the created texture is a cube texture */
  28141. isCube?: boolean;
  28142. }
  28143. /**
  28144. * Class used to describe the capabilities of the engine relatively to the current browser
  28145. */
  28146. export class EngineCapabilities {
  28147. /** Maximum textures units per fragment shader */
  28148. maxTexturesImageUnits: number;
  28149. /** Maximum texture units per vertex shader */
  28150. maxVertexTextureImageUnits: number;
  28151. /** Maximum textures units in the entire pipeline */
  28152. maxCombinedTexturesImageUnits: number;
  28153. /** Maximum texture size */
  28154. maxTextureSize: number;
  28155. /** Maximum cube texture size */
  28156. maxCubemapTextureSize: number;
  28157. /** Maximum render texture size */
  28158. maxRenderTextureSize: number;
  28159. /** Maximum number of vertex attributes */
  28160. maxVertexAttribs: number;
  28161. /** Maximum number of varyings */
  28162. maxVaryingVectors: number;
  28163. /** Maximum number of uniforms per vertex shader */
  28164. maxVertexUniformVectors: number;
  28165. /** Maximum number of uniforms per fragment shader */
  28166. maxFragmentUniformVectors: number;
  28167. /** Defines if standard derivates (dx/dy) are supported */
  28168. standardDerivatives: boolean;
  28169. /** Defines if s3tc texture compression is supported */
  28170. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28171. /** Defines if pvrtc texture compression is supported */
  28172. pvrtc: any;
  28173. /** Defines if etc1 texture compression is supported */
  28174. etc1: any;
  28175. /** Defines if etc2 texture compression is supported */
  28176. etc2: any;
  28177. /** Defines if astc texture compression is supported */
  28178. astc: any;
  28179. /** Defines if float textures are supported */
  28180. textureFloat: boolean;
  28181. /** Defines if vertex array objects are supported */
  28182. vertexArrayObject: boolean;
  28183. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28184. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28185. /** Gets the maximum level of anisotropy supported */
  28186. maxAnisotropy: number;
  28187. /** Defines if instancing is supported */
  28188. instancedArrays: boolean;
  28189. /** Defines if 32 bits indices are supported */
  28190. uintIndices: boolean;
  28191. /** Defines if high precision shaders are supported */
  28192. highPrecisionShaderSupported: boolean;
  28193. /** Defines if depth reading in the fragment shader is supported */
  28194. fragmentDepthSupported: boolean;
  28195. /** Defines if float texture linear filtering is supported*/
  28196. textureFloatLinearFiltering: boolean;
  28197. /** Defines if rendering to float textures is supported */
  28198. textureFloatRender: boolean;
  28199. /** Defines if half float textures are supported*/
  28200. textureHalfFloat: boolean;
  28201. /** Defines if half float texture linear filtering is supported*/
  28202. textureHalfFloatLinearFiltering: boolean;
  28203. /** Defines if rendering to half float textures is supported */
  28204. textureHalfFloatRender: boolean;
  28205. /** Defines if textureLOD shader command is supported */
  28206. textureLOD: boolean;
  28207. /** Defines if draw buffers extension is supported */
  28208. drawBuffersExtension: boolean;
  28209. /** Defines if depth textures are supported */
  28210. depthTextureExtension: boolean;
  28211. /** Defines if float color buffer are supported */
  28212. colorBufferFloat: boolean;
  28213. /** Gets disjoint timer query extension (null if not supported) */
  28214. timerQuery: EXT_disjoint_timer_query;
  28215. /** Defines if timestamp can be used with timer query */
  28216. canUseTimestampForTimerQuery: boolean;
  28217. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28218. multiview: any;
  28219. /** Function used to let the system compiles shaders in background */
  28220. parallelShaderCompile: {
  28221. COMPLETION_STATUS_KHR: number;
  28222. };
  28223. }
  28224. /** Interface defining initialization parameters for Engine class */
  28225. export interface EngineOptions extends WebGLContextAttributes {
  28226. /**
  28227. * Defines if the engine should no exceed a specified device ratio
  28228. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28229. */
  28230. limitDeviceRatio?: number;
  28231. /**
  28232. * Defines if webvr should be enabled automatically
  28233. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28234. */
  28235. autoEnableWebVR?: boolean;
  28236. /**
  28237. * Defines if webgl2 should be turned off even if supported
  28238. * @see http://doc.babylonjs.com/features/webgl2
  28239. */
  28240. disableWebGL2Support?: boolean;
  28241. /**
  28242. * Defines if webaudio should be initialized as well
  28243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28244. */
  28245. audioEngine?: boolean;
  28246. /**
  28247. * Defines if animations should run using a deterministic lock step
  28248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28249. */
  28250. deterministicLockstep?: boolean;
  28251. /** Defines the maximum steps to use with deterministic lock step mode */
  28252. lockstepMaxSteps?: number;
  28253. /**
  28254. * Defines that engine should ignore context lost events
  28255. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28256. */
  28257. doNotHandleContextLost?: boolean;
  28258. /**
  28259. * Defines that engine should ignore modifying touch action attribute and style
  28260. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28261. */
  28262. doNotHandleTouchAction?: boolean;
  28263. /**
  28264. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28265. */
  28266. useHighPrecisionFloats?: boolean;
  28267. }
  28268. /**
  28269. * Defines the interface used by display changed events
  28270. */
  28271. export interface IDisplayChangedEventArgs {
  28272. /** Gets the vrDisplay object (if any) */
  28273. vrDisplay: Nullable<any>;
  28274. /** Gets a boolean indicating if webVR is supported */
  28275. vrSupported: boolean;
  28276. }
  28277. /**
  28278. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28279. */
  28280. export class Engine {
  28281. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28282. static ExceptionList: ({
  28283. key: string;
  28284. capture: string;
  28285. captureConstraint: number;
  28286. targets: string[];
  28287. } | {
  28288. key: string;
  28289. capture: null;
  28290. captureConstraint: null;
  28291. targets: string[];
  28292. })[];
  28293. /** Gets the list of created engines */
  28294. static readonly Instances: Engine[];
  28295. /**
  28296. * Gets the latest created engine
  28297. */
  28298. static readonly LastCreatedEngine: Nullable<Engine>;
  28299. /**
  28300. * Gets the latest created scene
  28301. */
  28302. static readonly LastCreatedScene: Nullable<Scene>;
  28303. /**
  28304. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28305. * @param flag defines which part of the materials must be marked as dirty
  28306. * @param predicate defines a predicate used to filter which materials should be affected
  28307. */
  28308. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28309. /** @hidden */
  28310. static _TextureLoaders: IInternalTextureLoader[];
  28311. /** Defines that alpha blending is disabled */
  28312. static readonly ALPHA_DISABLE: number;
  28313. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28314. static readonly ALPHA_ADD: number;
  28315. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28316. static readonly ALPHA_COMBINE: number;
  28317. /** Defines that alpha blending to DEST - SRC * DEST */
  28318. static readonly ALPHA_SUBTRACT: number;
  28319. /** Defines that alpha blending to SRC * DEST */
  28320. static readonly ALPHA_MULTIPLY: number;
  28321. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28322. static readonly ALPHA_MAXIMIZED: number;
  28323. /** Defines that alpha blending to SRC + DEST */
  28324. static readonly ALPHA_ONEONE: number;
  28325. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28326. static readonly ALPHA_PREMULTIPLIED: number;
  28327. /**
  28328. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28329. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28330. */
  28331. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28332. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28333. static readonly ALPHA_INTERPOLATE: number;
  28334. /**
  28335. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28336. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28337. */
  28338. static readonly ALPHA_SCREENMODE: number;
  28339. /** Defines that the ressource is not delayed*/
  28340. static readonly DELAYLOADSTATE_NONE: number;
  28341. /** Defines that the ressource was successfully delay loaded */
  28342. static readonly DELAYLOADSTATE_LOADED: number;
  28343. /** Defines that the ressource is currently delay loading */
  28344. static readonly DELAYLOADSTATE_LOADING: number;
  28345. /** Defines that the ressource is delayed and has not started loading */
  28346. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28347. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28348. static readonly NEVER: number;
  28349. /** 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 */
  28350. static readonly ALWAYS: number;
  28351. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28352. static readonly LESS: number;
  28353. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28354. static readonly EQUAL: number;
  28355. /** 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 */
  28356. static readonly LEQUAL: number;
  28357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28358. static readonly GREATER: number;
  28359. /** 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 */
  28360. static readonly GEQUAL: number;
  28361. /** 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 */
  28362. static readonly NOTEQUAL: number;
  28363. /** Passed to stencilOperation to specify that stencil value must be kept */
  28364. static readonly KEEP: number;
  28365. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28366. static readonly REPLACE: number;
  28367. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28368. static readonly INCR: number;
  28369. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28370. static readonly DECR: number;
  28371. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28372. static readonly INVERT: number;
  28373. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28374. static readonly INCR_WRAP: number;
  28375. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28376. static readonly DECR_WRAP: number;
  28377. /** Texture is not repeating outside of 0..1 UVs */
  28378. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28379. /** Texture is repeating outside of 0..1 UVs */
  28380. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28381. /** Texture is repeating and mirrored */
  28382. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28383. /** ALPHA */
  28384. static readonly TEXTUREFORMAT_ALPHA: number;
  28385. /** LUMINANCE */
  28386. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28387. /** LUMINANCE_ALPHA */
  28388. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28389. /** RGB */
  28390. static readonly TEXTUREFORMAT_RGB: number;
  28391. /** RGBA */
  28392. static readonly TEXTUREFORMAT_RGBA: number;
  28393. /** RED */
  28394. static readonly TEXTUREFORMAT_RED: number;
  28395. /** RED (2nd reference) */
  28396. static readonly TEXTUREFORMAT_R: number;
  28397. /** RG */
  28398. static readonly TEXTUREFORMAT_RG: number;
  28399. /** RED_INTEGER */
  28400. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28401. /** RED_INTEGER (2nd reference) */
  28402. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28403. /** RG_INTEGER */
  28404. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28405. /** RGB_INTEGER */
  28406. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28407. /** RGBA_INTEGER */
  28408. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28409. /** UNSIGNED_BYTE */
  28410. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28411. /** UNSIGNED_BYTE (2nd reference) */
  28412. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28413. /** FLOAT */
  28414. static readonly TEXTURETYPE_FLOAT: number;
  28415. /** HALF_FLOAT */
  28416. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28417. /** BYTE */
  28418. static readonly TEXTURETYPE_BYTE: number;
  28419. /** SHORT */
  28420. static readonly TEXTURETYPE_SHORT: number;
  28421. /** UNSIGNED_SHORT */
  28422. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28423. /** INT */
  28424. static readonly TEXTURETYPE_INT: number;
  28425. /** UNSIGNED_INT */
  28426. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28427. /** UNSIGNED_SHORT_4_4_4_4 */
  28428. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28429. /** UNSIGNED_SHORT_5_5_5_1 */
  28430. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28431. /** UNSIGNED_SHORT_5_6_5 */
  28432. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28433. /** UNSIGNED_INT_2_10_10_10_REV */
  28434. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28435. /** UNSIGNED_INT_24_8 */
  28436. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28437. /** UNSIGNED_INT_10F_11F_11F_REV */
  28438. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28439. /** UNSIGNED_INT_5_9_9_9_REV */
  28440. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28441. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28442. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28443. /** nearest is mag = nearest and min = nearest and mip = linear */
  28444. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28445. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28446. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28447. /** Trilinear is mag = linear and min = linear and mip = linear */
  28448. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28449. /** nearest is mag = nearest and min = nearest and mip = linear */
  28450. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28451. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28452. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28453. /** Trilinear is mag = linear and min = linear and mip = linear */
  28454. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28455. /** mag = nearest and min = nearest and mip = nearest */
  28456. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28457. /** mag = nearest and min = linear and mip = nearest */
  28458. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28459. /** mag = nearest and min = linear and mip = linear */
  28460. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28461. /** mag = nearest and min = linear and mip = none */
  28462. static readonly TEXTURE_NEAREST_LINEAR: number;
  28463. /** mag = nearest and min = nearest and mip = none */
  28464. static readonly TEXTURE_NEAREST_NEAREST: number;
  28465. /** mag = linear and min = nearest and mip = nearest */
  28466. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28467. /** mag = linear and min = nearest and mip = linear */
  28468. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28469. /** mag = linear and min = linear and mip = none */
  28470. static readonly TEXTURE_LINEAR_LINEAR: number;
  28471. /** mag = linear and min = nearest and mip = none */
  28472. static readonly TEXTURE_LINEAR_NEAREST: number;
  28473. /** Explicit coordinates mode */
  28474. static readonly TEXTURE_EXPLICIT_MODE: number;
  28475. /** Spherical coordinates mode */
  28476. static readonly TEXTURE_SPHERICAL_MODE: number;
  28477. /** Planar coordinates mode */
  28478. static readonly TEXTURE_PLANAR_MODE: number;
  28479. /** Cubic coordinates mode */
  28480. static readonly TEXTURE_CUBIC_MODE: number;
  28481. /** Projection coordinates mode */
  28482. static readonly TEXTURE_PROJECTION_MODE: number;
  28483. /** Skybox coordinates mode */
  28484. static readonly TEXTURE_SKYBOX_MODE: number;
  28485. /** Inverse Cubic coordinates mode */
  28486. static readonly TEXTURE_INVCUBIC_MODE: number;
  28487. /** Equirectangular coordinates mode */
  28488. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28489. /** Equirectangular Fixed coordinates mode */
  28490. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28491. /** Equirectangular Fixed Mirrored coordinates mode */
  28492. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28493. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28494. static readonly SCALEMODE_FLOOR: number;
  28495. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28496. static readonly SCALEMODE_NEAREST: number;
  28497. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28498. static readonly SCALEMODE_CEILING: number;
  28499. /**
  28500. * Returns the current npm package of the sdk
  28501. */
  28502. static readonly NpmPackage: string;
  28503. /**
  28504. * Returns the current version of the framework
  28505. */
  28506. static readonly Version: string;
  28507. /**
  28508. * Returns a string describing the current engine
  28509. */
  28510. readonly description: string;
  28511. /**
  28512. * Gets or sets the epsilon value used by collision engine
  28513. */
  28514. static CollisionsEpsilon: number;
  28515. /**
  28516. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28517. */
  28518. static ShadersRepository: string;
  28519. /**
  28520. * Method called to create the default loading screen.
  28521. * This can be overriden in your own app.
  28522. * @param canvas The rendering canvas element
  28523. * @returns The loading screen
  28524. */
  28525. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28526. /**
  28527. * Method called to create the default rescale post process on each engine.
  28528. */
  28529. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28530. /** @hidden */
  28531. _shaderProcessor: IShaderProcessor;
  28532. /**
  28533. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28534. */
  28535. forcePOTTextures: boolean;
  28536. /**
  28537. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28538. */
  28539. isFullscreen: boolean;
  28540. /**
  28541. * Gets a boolean indicating if the pointer is currently locked
  28542. */
  28543. isPointerLock: boolean;
  28544. /**
  28545. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28546. */
  28547. cullBackFaces: boolean;
  28548. /**
  28549. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28550. */
  28551. renderEvenInBackground: boolean;
  28552. /**
  28553. * Gets or sets a boolean indicating that cache can be kept between frames
  28554. */
  28555. preventCacheWipeBetweenFrames: boolean;
  28556. /**
  28557. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28558. **/
  28559. enableOfflineSupport: boolean;
  28560. /**
  28561. * 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)
  28562. **/
  28563. disableManifestCheck: boolean;
  28564. /**
  28565. * Gets the list of created scenes
  28566. */
  28567. scenes: Scene[];
  28568. /**
  28569. * Event raised when a new scene is created
  28570. */
  28571. onNewSceneAddedObservable: Observable<Scene>;
  28572. /**
  28573. * Gets the list of created postprocesses
  28574. */
  28575. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28576. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28577. validateShaderPrograms: boolean;
  28578. /**
  28579. * Observable event triggered each time the rendering canvas is resized
  28580. */
  28581. onResizeObservable: Observable<Engine>;
  28582. /**
  28583. * Observable event triggered each time the canvas loses focus
  28584. */
  28585. onCanvasBlurObservable: Observable<Engine>;
  28586. /**
  28587. * Observable event triggered each time the canvas gains focus
  28588. */
  28589. onCanvasFocusObservable: Observable<Engine>;
  28590. /**
  28591. * Observable event triggered each time the canvas receives pointerout event
  28592. */
  28593. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28594. /**
  28595. * Observable event triggered before each texture is initialized
  28596. */
  28597. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28598. /**
  28599. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28600. */
  28601. disableUniformBuffers: boolean;
  28602. /** @hidden */
  28603. _uniformBuffers: UniformBuffer[];
  28604. /**
  28605. * Gets a boolean indicating that the engine supports uniform buffers
  28606. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28607. */
  28608. readonly supportsUniformBuffers: boolean;
  28609. /**
  28610. * Observable raised when the engine begins a new frame
  28611. */
  28612. onBeginFrameObservable: Observable<Engine>;
  28613. /**
  28614. * If set, will be used to request the next animation frame for the render loop
  28615. */
  28616. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28617. /**
  28618. * Observable raised when the engine ends the current frame
  28619. */
  28620. onEndFrameObservable: Observable<Engine>;
  28621. /**
  28622. * Observable raised when the engine is about to compile a shader
  28623. */
  28624. onBeforeShaderCompilationObservable: Observable<Engine>;
  28625. /**
  28626. * Observable raised when the engine has jsut compiled a shader
  28627. */
  28628. onAfterShaderCompilationObservable: Observable<Engine>;
  28629. /** @hidden */
  28630. _gl: WebGLRenderingContext;
  28631. private _renderingCanvas;
  28632. private _windowIsBackground;
  28633. private _webGLVersion;
  28634. protected _highPrecisionShadersAllowed: boolean;
  28635. /** @hidden */
  28636. readonly _shouldUseHighPrecisionShader: boolean;
  28637. /**
  28638. * Gets a boolean indicating that only power of 2 textures are supported
  28639. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28640. */
  28641. readonly needPOTTextures: boolean;
  28642. /** @hidden */
  28643. _badOS: boolean;
  28644. /** @hidden */
  28645. _badDesktopOS: boolean;
  28646. /**
  28647. * Gets the audio engine
  28648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28649. * @ignorenaming
  28650. */
  28651. static audioEngine: IAudioEngine;
  28652. /**
  28653. * Default AudioEngine factory responsible of creating the Audio Engine.
  28654. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28655. */
  28656. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28657. /**
  28658. * Default offline support factory responsible of creating a tool used to store data locally.
  28659. * By default, this will create a Database object if the workload has been embedded.
  28660. */
  28661. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28662. private _onFocus;
  28663. private _onBlur;
  28664. private _onCanvasPointerOut;
  28665. private _onCanvasBlur;
  28666. private _onCanvasFocus;
  28667. private _onFullscreenChange;
  28668. private _onPointerLockChange;
  28669. private _hardwareScalingLevel;
  28670. /** @hidden */
  28671. _caps: EngineCapabilities;
  28672. private _pointerLockRequested;
  28673. private _isStencilEnable;
  28674. private _colorWrite;
  28675. private _loadingScreen;
  28676. /** @hidden */
  28677. _drawCalls: PerfCounter;
  28678. private _glVersion;
  28679. private _glRenderer;
  28680. private _glVendor;
  28681. private _videoTextureSupported;
  28682. private _renderingQueueLaunched;
  28683. private _activeRenderLoops;
  28684. private _deterministicLockstep;
  28685. private _lockstepMaxSteps;
  28686. /**
  28687. * Observable signaled when a context lost event is raised
  28688. */
  28689. onContextLostObservable: Observable<Engine>;
  28690. /**
  28691. * Observable signaled when a context restored event is raised
  28692. */
  28693. onContextRestoredObservable: Observable<Engine>;
  28694. private _onContextLost;
  28695. private _onContextRestored;
  28696. private _contextWasLost;
  28697. /** @hidden */
  28698. _doNotHandleContextLost: boolean;
  28699. /**
  28700. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28702. */
  28703. doNotHandleContextLost: boolean;
  28704. private _performanceMonitor;
  28705. private _fps;
  28706. private _deltaTime;
  28707. /**
  28708. * Turn this value on if you want to pause FPS computation when in background
  28709. */
  28710. disablePerformanceMonitorInBackground: boolean;
  28711. /**
  28712. * Gets the performance monitor attached to this engine
  28713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28714. */
  28715. readonly performanceMonitor: PerformanceMonitor;
  28716. /**
  28717. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28718. */
  28719. disableVertexArrayObjects: boolean;
  28720. /** @hidden */
  28721. protected _depthCullingState: _DepthCullingState;
  28722. /** @hidden */
  28723. protected _stencilState: _StencilState;
  28724. /** @hidden */
  28725. protected _alphaState: _AlphaState;
  28726. /** @hidden */
  28727. protected _alphaMode: number;
  28728. /** @hidden */
  28729. _internalTexturesCache: InternalTexture[];
  28730. /** @hidden */
  28731. protected _activeChannel: number;
  28732. private _currentTextureChannel;
  28733. /** @hidden */
  28734. protected _boundTexturesCache: {
  28735. [key: string]: Nullable<InternalTexture>;
  28736. };
  28737. /** @hidden */
  28738. protected _currentEffect: Nullable<Effect>;
  28739. /** @hidden */
  28740. protected _currentProgram: Nullable<WebGLProgram>;
  28741. private _compiledEffects;
  28742. private _vertexAttribArraysEnabled;
  28743. /** @hidden */
  28744. protected _cachedViewport: Nullable<Viewport>;
  28745. private _cachedVertexArrayObject;
  28746. /** @hidden */
  28747. protected _cachedVertexBuffers: any;
  28748. /** @hidden */
  28749. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28750. /** @hidden */
  28751. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28752. /** @hidden */
  28753. _currentRenderTarget: Nullable<InternalTexture>;
  28754. private _uintIndicesCurrentlySet;
  28755. private _currentBoundBuffer;
  28756. /** @hidden */
  28757. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28758. private _currentBufferPointers;
  28759. private _currentInstanceLocations;
  28760. private _currentInstanceBuffers;
  28761. private _textureUnits;
  28762. /** @hidden */
  28763. _workingCanvas: Nullable<HTMLCanvasElement>;
  28764. /** @hidden */
  28765. _workingContext: Nullable<CanvasRenderingContext2D>;
  28766. private _rescalePostProcess;
  28767. private _dummyFramebuffer;
  28768. private _externalData;
  28769. /** @hidden */
  28770. _bindedRenderFunction: any;
  28771. private _vaoRecordInProgress;
  28772. private _mustWipeVertexAttributes;
  28773. private _emptyTexture;
  28774. private _emptyCubeTexture;
  28775. private _emptyTexture3D;
  28776. /** @hidden */
  28777. _frameHandler: number;
  28778. private _nextFreeTextureSlots;
  28779. private _maxSimultaneousTextures;
  28780. private _activeRequests;
  28781. private _texturesSupported;
  28782. /** @hidden */
  28783. _textureFormatInUse: Nullable<string>;
  28784. /**
  28785. * Gets the list of texture formats supported
  28786. */
  28787. readonly texturesSupported: Array<string>;
  28788. /**
  28789. * Gets the list of texture formats in use
  28790. */
  28791. readonly textureFormatInUse: Nullable<string>;
  28792. /**
  28793. * Gets the current viewport
  28794. */
  28795. readonly currentViewport: Nullable<Viewport>;
  28796. /**
  28797. * Gets the default empty texture
  28798. */
  28799. readonly emptyTexture: InternalTexture;
  28800. /**
  28801. * Gets the default empty 3D texture
  28802. */
  28803. readonly emptyTexture3D: InternalTexture;
  28804. /**
  28805. * Gets the default empty cube texture
  28806. */
  28807. readonly emptyCubeTexture: InternalTexture;
  28808. /**
  28809. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28810. */
  28811. readonly premultipliedAlpha: boolean;
  28812. /**
  28813. * Creates a new engine
  28814. * @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
  28815. * @param antialias defines enable antialiasing (default: false)
  28816. * @param options defines further options to be sent to the getContext() function
  28817. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28818. */
  28819. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28820. /**
  28821. * Initializes a webVR display and starts listening to display change events
  28822. * The onVRDisplayChangedObservable will be notified upon these changes
  28823. * @returns The onVRDisplayChangedObservable
  28824. */
  28825. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28826. /** @hidden */
  28827. _prepareVRComponent(): void;
  28828. /** @hidden */
  28829. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28830. /** @hidden */
  28831. _submitVRFrame(): void;
  28832. /**
  28833. * Call this function to leave webVR mode
  28834. * Will do nothing if webVR is not supported or if there is no webVR device
  28835. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28836. */
  28837. disableVR(): void;
  28838. /**
  28839. * Gets a boolean indicating that the system is in VR mode and is presenting
  28840. * @returns true if VR mode is engaged
  28841. */
  28842. isVRPresenting(): boolean;
  28843. /** @hidden */
  28844. _requestVRFrame(): void;
  28845. private _disableTouchAction;
  28846. private _rebuildInternalTextures;
  28847. private _rebuildEffects;
  28848. /**
  28849. * Gets a boolean indicating if all created effects are ready
  28850. * @returns true if all effects are ready
  28851. */
  28852. areAllEffectsReady(): boolean;
  28853. private _rebuildBuffers;
  28854. private _initGLContext;
  28855. /**
  28856. * Gets version of the current webGL context
  28857. */
  28858. readonly webGLVersion: number;
  28859. /**
  28860. * Gets a string idenfifying the name of the class
  28861. * @returns "Engine" string
  28862. */
  28863. getClassName(): string;
  28864. /**
  28865. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28866. */
  28867. readonly isStencilEnable: boolean;
  28868. /** @hidden */
  28869. _prepareWorkingCanvas(): void;
  28870. /**
  28871. * Reset the texture cache to empty state
  28872. */
  28873. resetTextureCache(): void;
  28874. /**
  28875. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28877. * @returns true if engine is in deterministic lock step mode
  28878. */
  28879. isDeterministicLockStep(): boolean;
  28880. /**
  28881. * Gets the max steps when engine is running in deterministic lock step
  28882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28883. * @returns the max steps
  28884. */
  28885. getLockstepMaxSteps(): number;
  28886. /**
  28887. * Gets an object containing information about the current webGL context
  28888. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28889. */
  28890. getGlInfo(): {
  28891. vendor: string;
  28892. renderer: string;
  28893. version: string;
  28894. };
  28895. /**
  28896. * Gets current aspect ratio
  28897. * @param camera defines the camera to use to get the aspect ratio
  28898. * @param useScreen defines if screen size must be used (or the current render target if any)
  28899. * @returns a number defining the aspect ratio
  28900. */
  28901. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28902. /**
  28903. * Gets current screen aspect ratio
  28904. * @returns a number defining the aspect ratio
  28905. */
  28906. getScreenAspectRatio(): number;
  28907. /**
  28908. * Gets the current render width
  28909. * @param useScreen defines if screen size must be used (or the current render target if any)
  28910. * @returns a number defining the current render width
  28911. */
  28912. getRenderWidth(useScreen?: boolean): number;
  28913. /**
  28914. * Gets the current render height
  28915. * @param useScreen defines if screen size must be used (or the current render target if any)
  28916. * @returns a number defining the current render height
  28917. */
  28918. getRenderHeight(useScreen?: boolean): number;
  28919. /**
  28920. * Gets the HTML canvas attached with the current webGL context
  28921. * @returns a HTML canvas
  28922. */
  28923. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28924. /**
  28925. * Gets the client rect of the HTML canvas attached with the current webGL context
  28926. * @returns a client rectanglee
  28927. */
  28928. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28929. /**
  28930. * Defines the hardware scaling level.
  28931. * By default the hardware scaling level is computed from the window device ratio.
  28932. * 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.
  28933. * @param level defines the level to use
  28934. */
  28935. setHardwareScalingLevel(level: number): void;
  28936. /**
  28937. * Gets the current hardware scaling level.
  28938. * By default the hardware scaling level is computed from the window device ratio.
  28939. * 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.
  28940. * @returns a number indicating the current hardware scaling level
  28941. */
  28942. getHardwareScalingLevel(): number;
  28943. /**
  28944. * Gets the list of loaded textures
  28945. * @returns an array containing all loaded textures
  28946. */
  28947. getLoadedTexturesCache(): InternalTexture[];
  28948. /**
  28949. * Gets the object containing all engine capabilities
  28950. * @returns the EngineCapabilities object
  28951. */
  28952. getCaps(): EngineCapabilities;
  28953. /**
  28954. * Gets the current depth function
  28955. * @returns a number defining the depth function
  28956. */
  28957. getDepthFunction(): Nullable<number>;
  28958. /**
  28959. * Sets the current depth function
  28960. * @param depthFunc defines the function to use
  28961. */
  28962. setDepthFunction(depthFunc: number): void;
  28963. /**
  28964. * Sets the current depth function to GREATER
  28965. */
  28966. setDepthFunctionToGreater(): void;
  28967. /**
  28968. * Sets the current depth function to GEQUAL
  28969. */
  28970. setDepthFunctionToGreaterOrEqual(): void;
  28971. /**
  28972. * Sets the current depth function to LESS
  28973. */
  28974. setDepthFunctionToLess(): void;
  28975. private _cachedStencilBuffer;
  28976. private _cachedStencilFunction;
  28977. private _cachedStencilMask;
  28978. private _cachedStencilOperationPass;
  28979. private _cachedStencilOperationFail;
  28980. private _cachedStencilOperationDepthFail;
  28981. private _cachedStencilReference;
  28982. /**
  28983. * Caches the the state of the stencil buffer
  28984. */
  28985. cacheStencilState(): void;
  28986. /**
  28987. * Restores the state of the stencil buffer
  28988. */
  28989. restoreStencilState(): void;
  28990. /**
  28991. * Sets the current depth function to LEQUAL
  28992. */
  28993. setDepthFunctionToLessOrEqual(): void;
  28994. /**
  28995. * Gets a boolean indicating if stencil buffer is enabled
  28996. * @returns the current stencil buffer state
  28997. */
  28998. getStencilBuffer(): boolean;
  28999. /**
  29000. * Enable or disable the stencil buffer
  29001. * @param enable defines if the stencil buffer must be enabled or disabled
  29002. */
  29003. setStencilBuffer(enable: boolean): void;
  29004. /**
  29005. * Gets the current stencil mask
  29006. * @returns a number defining the new stencil mask to use
  29007. */
  29008. getStencilMask(): number;
  29009. /**
  29010. * Sets the current stencil mask
  29011. * @param mask defines the new stencil mask to use
  29012. */
  29013. setStencilMask(mask: number): void;
  29014. /**
  29015. * Gets the current stencil function
  29016. * @returns a number defining the stencil function to use
  29017. */
  29018. getStencilFunction(): number;
  29019. /**
  29020. * Gets the current stencil reference value
  29021. * @returns a number defining the stencil reference value to use
  29022. */
  29023. getStencilFunctionReference(): number;
  29024. /**
  29025. * Gets the current stencil mask
  29026. * @returns a number defining the stencil mask to use
  29027. */
  29028. getStencilFunctionMask(): number;
  29029. /**
  29030. * Sets the current stencil function
  29031. * @param stencilFunc defines the new stencil function to use
  29032. */
  29033. setStencilFunction(stencilFunc: number): void;
  29034. /**
  29035. * Sets the current stencil reference
  29036. * @param reference defines the new stencil reference to use
  29037. */
  29038. setStencilFunctionReference(reference: number): void;
  29039. /**
  29040. * Sets the current stencil mask
  29041. * @param mask defines the new stencil mask to use
  29042. */
  29043. setStencilFunctionMask(mask: number): void;
  29044. /**
  29045. * Gets the current stencil operation when stencil fails
  29046. * @returns a number defining stencil operation to use when stencil fails
  29047. */
  29048. getStencilOperationFail(): number;
  29049. /**
  29050. * Gets the current stencil operation when depth fails
  29051. * @returns a number defining stencil operation to use when depth fails
  29052. */
  29053. getStencilOperationDepthFail(): number;
  29054. /**
  29055. * Gets the current stencil operation when stencil passes
  29056. * @returns a number defining stencil operation to use when stencil passes
  29057. */
  29058. getStencilOperationPass(): number;
  29059. /**
  29060. * Sets the stencil operation to use when stencil fails
  29061. * @param operation defines the stencil operation to use when stencil fails
  29062. */
  29063. setStencilOperationFail(operation: number): void;
  29064. /**
  29065. * Sets the stencil operation to use when depth fails
  29066. * @param operation defines the stencil operation to use when depth fails
  29067. */
  29068. setStencilOperationDepthFail(operation: number): void;
  29069. /**
  29070. * Sets the stencil operation to use when stencil passes
  29071. * @param operation defines the stencil operation to use when stencil passes
  29072. */
  29073. setStencilOperationPass(operation: number): void;
  29074. /**
  29075. * Sets a boolean indicating if the dithering state is enabled or disabled
  29076. * @param value defines the dithering state
  29077. */
  29078. setDitheringState(value: boolean): void;
  29079. /**
  29080. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29081. * @param value defines the rasterizer state
  29082. */
  29083. setRasterizerState(value: boolean): void;
  29084. /**
  29085. * stop executing a render loop function and remove it from the execution array
  29086. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29087. */
  29088. stopRenderLoop(renderFunction?: () => void): void;
  29089. /** @hidden */
  29090. _renderLoop(): void;
  29091. /**
  29092. * Register and execute a render loop. The engine can have more than one render function
  29093. * @param renderFunction defines the function to continuously execute
  29094. */
  29095. runRenderLoop(renderFunction: () => void): void;
  29096. /**
  29097. * Toggle full screen mode
  29098. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29099. */
  29100. switchFullscreen(requestPointerLock: boolean): void;
  29101. /**
  29102. * Enters full screen mode
  29103. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29104. */
  29105. enterFullscreen(requestPointerLock: boolean): void;
  29106. /**
  29107. * Exits full screen mode
  29108. */
  29109. exitFullscreen(): void;
  29110. /**
  29111. * Enters Pointerlock mode
  29112. */
  29113. enterPointerlock(): void;
  29114. /**
  29115. * Exits Pointerlock mode
  29116. */
  29117. exitPointerlock(): void;
  29118. /**
  29119. * Clear the current render buffer or the current render target (if any is set up)
  29120. * @param color defines the color to use
  29121. * @param backBuffer defines if the back buffer must be cleared
  29122. * @param depth defines if the depth buffer must be cleared
  29123. * @param stencil defines if the stencil buffer must be cleared
  29124. */
  29125. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29126. /**
  29127. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29128. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29129. * @param y defines the y-coordinate of the corner of the clear rectangle
  29130. * @param width defines the width of the clear rectangle
  29131. * @param height defines the height of the clear rectangle
  29132. * @param clearColor defines the clear color
  29133. */
  29134. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29135. /**
  29136. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29137. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29138. * @param y defines the y-coordinate of the corner of the clear rectangle
  29139. * @param width defines the width of the clear rectangle
  29140. * @param height defines the height of the clear rectangle
  29141. */
  29142. enableScissor(x: number, y: number, width: number, height: number): void;
  29143. /**
  29144. * Disable previously set scissor test rectangle
  29145. */
  29146. disableScissor(): void;
  29147. private _viewportCached;
  29148. /** @hidden */
  29149. _viewport(x: number, y: number, width: number, height: number): void;
  29150. /**
  29151. * Set the WebGL's viewport
  29152. * @param viewport defines the viewport element to be used
  29153. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29154. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29155. */
  29156. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29157. /**
  29158. * Directly set the WebGL Viewport
  29159. * @param x defines the x coordinate of the viewport (in screen space)
  29160. * @param y defines the y coordinate of the viewport (in screen space)
  29161. * @param width defines the width of the viewport (in screen space)
  29162. * @param height defines the height of the viewport (in screen space)
  29163. * @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
  29164. */
  29165. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29166. /**
  29167. * Begin a new frame
  29168. */
  29169. beginFrame(): void;
  29170. /**
  29171. * Enf the current frame
  29172. */
  29173. endFrame(): void;
  29174. /**
  29175. * Resize the view according to the canvas' size
  29176. */
  29177. resize(): void;
  29178. /**
  29179. * Force a specific size of the canvas
  29180. * @param width defines the new canvas' width
  29181. * @param height defines the new canvas' height
  29182. */
  29183. setSize(width: number, height: number): void;
  29184. /**
  29185. * Binds the frame buffer to the specified texture.
  29186. * @param texture The texture to render to or null for the default canvas
  29187. * @param faceIndex The face of the texture to render to in case of cube texture
  29188. * @param requiredWidth The width of the target to render to
  29189. * @param requiredHeight The height of the target to render to
  29190. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29191. * @param depthStencilTexture The depth stencil texture to use to render
  29192. * @param lodLevel defines le lod level to bind to the frame buffer
  29193. */
  29194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29195. /** @hidden */
  29196. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29197. /**
  29198. * Unbind the current render target texture from the webGL context
  29199. * @param texture defines the render target texture to unbind
  29200. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29201. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29202. */
  29203. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29204. /**
  29205. * Force the mipmap generation for the given render target texture
  29206. * @param texture defines the render target texture to use
  29207. */
  29208. generateMipMapsForCubemap(texture: InternalTexture): void;
  29209. /**
  29210. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29211. */
  29212. flushFramebuffer(): void;
  29213. /**
  29214. * Unbind the current render target and bind the default framebuffer
  29215. */
  29216. restoreDefaultFramebuffer(): void;
  29217. /**
  29218. * Create an uniform buffer
  29219. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29220. * @param elements defines the content of the uniform buffer
  29221. * @returns the webGL uniform buffer
  29222. */
  29223. createUniformBuffer(elements: FloatArray): DataBuffer;
  29224. /**
  29225. * Create a dynamic uniform buffer
  29226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29227. * @param elements defines the content of the uniform buffer
  29228. * @returns the webGL uniform buffer
  29229. */
  29230. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29231. /**
  29232. * Update an existing uniform buffer
  29233. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29234. * @param uniformBuffer defines the target uniform buffer
  29235. * @param elements defines the content to update
  29236. * @param offset defines the offset in the uniform buffer where update should start
  29237. * @param count defines the size of the data to update
  29238. */
  29239. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29240. private _resetVertexBufferBinding;
  29241. /**
  29242. * Creates a vertex buffer
  29243. * @param data the data for the vertex buffer
  29244. * @returns the new WebGL static buffer
  29245. */
  29246. createVertexBuffer(data: DataArray): DataBuffer;
  29247. /**
  29248. * Creates a dynamic vertex buffer
  29249. * @param data the data for the dynamic vertex buffer
  29250. * @returns the new WebGL dynamic buffer
  29251. */
  29252. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29253. /**
  29254. * Update a dynamic index buffer
  29255. * @param indexBuffer defines the target index buffer
  29256. * @param indices defines the data to update
  29257. * @param offset defines the offset in the target index buffer where update should start
  29258. */
  29259. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29260. /**
  29261. * Updates a dynamic vertex buffer.
  29262. * @param vertexBuffer the vertex buffer to update
  29263. * @param data the data used to update the vertex buffer
  29264. * @param byteOffset the byte offset of the data
  29265. * @param byteLength the byte length of the data
  29266. */
  29267. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29268. private _resetIndexBufferBinding;
  29269. /**
  29270. * Creates a new index buffer
  29271. * @param indices defines the content of the index buffer
  29272. * @param updatable defines if the index buffer must be updatable
  29273. * @returns a new webGL buffer
  29274. */
  29275. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29276. /**
  29277. * Bind a webGL buffer to the webGL context
  29278. * @param buffer defines the buffer to bind
  29279. */
  29280. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29281. /**
  29282. * Bind an uniform buffer to the current webGL context
  29283. * @param buffer defines the buffer to bind
  29284. */
  29285. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29286. /**
  29287. * Bind a buffer to the current webGL context at a given location
  29288. * @param buffer defines the buffer to bind
  29289. * @param location defines the index where to bind the buffer
  29290. */
  29291. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29292. /**
  29293. * Bind a specific block at a given index in a specific shader program
  29294. * @param pipelineContext defines the pipeline context to use
  29295. * @param blockName defines the block name
  29296. * @param index defines the index where to bind the block
  29297. */
  29298. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29299. private bindIndexBuffer;
  29300. private bindBuffer;
  29301. /**
  29302. * update the bound buffer with the given data
  29303. * @param data defines the data to update
  29304. */
  29305. updateArrayBuffer(data: Float32Array): void;
  29306. private _vertexAttribPointer;
  29307. private _bindIndexBufferWithCache;
  29308. private _bindVertexBuffersAttributes;
  29309. /**
  29310. * Records a vertex array object
  29311. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29312. * @param vertexBuffers defines the list of vertex buffers to store
  29313. * @param indexBuffer defines the index buffer to store
  29314. * @param effect defines the effect to store
  29315. * @returns the new vertex array object
  29316. */
  29317. recordVertexArrayObject(vertexBuffers: {
  29318. [key: string]: VertexBuffer;
  29319. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29320. /**
  29321. * Bind a specific vertex array object
  29322. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29323. * @param vertexArrayObject defines the vertex array object to bind
  29324. * @param indexBuffer defines the index buffer to bind
  29325. */
  29326. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29327. /**
  29328. * Bind webGl buffers directly to the webGL context
  29329. * @param vertexBuffer defines the vertex buffer to bind
  29330. * @param indexBuffer defines the index buffer to bind
  29331. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29332. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29333. * @param effect defines the effect associated with the vertex buffer
  29334. */
  29335. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29336. private _unbindVertexArrayObject;
  29337. /**
  29338. * Bind a list of vertex buffers to the webGL context
  29339. * @param vertexBuffers defines the list of vertex buffers to bind
  29340. * @param indexBuffer defines the index buffer to bind
  29341. * @param effect defines the effect associated with the vertex buffers
  29342. */
  29343. bindBuffers(vertexBuffers: {
  29344. [key: string]: Nullable<VertexBuffer>;
  29345. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29346. /**
  29347. * Unbind all instance attributes
  29348. */
  29349. unbindInstanceAttributes(): void;
  29350. /**
  29351. * Release and free the memory of a vertex array object
  29352. * @param vao defines the vertex array object to delete
  29353. */
  29354. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29355. /** @hidden */
  29356. _releaseBuffer(buffer: DataBuffer): boolean;
  29357. /**
  29358. * Creates a webGL buffer to use with instanciation
  29359. * @param capacity defines the size of the buffer
  29360. * @returns the webGL buffer
  29361. */
  29362. createInstancesBuffer(capacity: number): DataBuffer;
  29363. /**
  29364. * Delete a webGL buffer used with instanciation
  29365. * @param buffer defines the webGL buffer to delete
  29366. */
  29367. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29368. /**
  29369. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29370. * @param instancesBuffer defines the webGL buffer to update and bind
  29371. * @param data defines the data to store in the buffer
  29372. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29373. */
  29374. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29375. /**
  29376. * Apply all cached states (depth, culling, stencil and alpha)
  29377. */
  29378. applyStates(): void;
  29379. /**
  29380. * Send a draw order
  29381. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29382. * @param indexStart defines the starting index
  29383. * @param indexCount defines the number of index to draw
  29384. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29385. */
  29386. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29387. /**
  29388. * Draw a list of points
  29389. * @param verticesStart defines the index of first vertex to draw
  29390. * @param verticesCount defines the count of vertices to draw
  29391. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29392. */
  29393. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29394. /**
  29395. * Draw a list of unindexed primitives
  29396. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29397. * @param verticesStart defines the index of first vertex to draw
  29398. * @param verticesCount defines the count of vertices to draw
  29399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29400. */
  29401. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29402. /**
  29403. * Draw a list of indexed primitives
  29404. * @param fillMode defines the primitive to use
  29405. * @param indexStart defines the starting index
  29406. * @param indexCount defines the number of index to draw
  29407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29408. */
  29409. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29410. /**
  29411. * Draw a list of unindexed primitives
  29412. * @param fillMode defines the primitive to use
  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. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29418. private _drawMode;
  29419. /** @hidden */
  29420. _releaseEffect(effect: Effect): void;
  29421. /** @hidden */
  29422. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29423. /**
  29424. * Create a new effect (used to store vertex/fragment shaders)
  29425. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29426. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29427. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29428. * @param samplers defines an array of string used to represent textures
  29429. * @param defines defines the string containing the defines to use to compile the shaders
  29430. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29431. * @param onCompiled defines a function to call when the effect creation is successful
  29432. * @param onError defines a function to call when the effect creation has failed
  29433. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29434. * @returns the new Effect
  29435. */
  29436. 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;
  29437. private _compileShader;
  29438. private _compileRawShader;
  29439. /**
  29440. * Directly creates a webGL program
  29441. * @param pipelineContext defines the pipeline context to attach to
  29442. * @param vertexCode defines the vertex shader code to use
  29443. * @param fragmentCode defines the fragment shader code to use
  29444. * @param context defines the webGL context to use (if not set, the current one will be used)
  29445. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29446. * @returns the new webGL program
  29447. */
  29448. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29449. /**
  29450. * Creates a webGL program
  29451. * @param pipelineContext defines the pipeline context to attach to
  29452. * @param vertexCode defines the vertex shader code to use
  29453. * @param fragmentCode defines the fragment shader code to use
  29454. * @param defines defines the string containing the defines to use to compile the shaders
  29455. * @param context defines the webGL context to use (if not set, the current one will be used)
  29456. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29457. * @returns the new webGL program
  29458. */
  29459. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29460. /**
  29461. * Creates a new pipeline context
  29462. * @returns the new pipeline
  29463. */
  29464. createPipelineContext(): WebGLPipelineContext;
  29465. private _createShaderProgram;
  29466. private _finalizePipelineContext;
  29467. /** @hidden */
  29468. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29469. /** @hidden */
  29470. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29471. /** @hidden */
  29472. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29473. /**
  29474. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29475. * @param pipelineContext defines the pipeline context to use
  29476. * @param uniformsNames defines the list of uniform names
  29477. * @returns an array of webGL uniform locations
  29478. */
  29479. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29480. /**
  29481. * Gets the lsit of active attributes for a given webGL program
  29482. * @param pipelineContext defines the pipeline context to use
  29483. * @param attributesNames defines the list of attribute names to get
  29484. * @returns an array of indices indicating the offset of each attribute
  29485. */
  29486. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29487. /**
  29488. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29489. * @param effect defines the effect to activate
  29490. */
  29491. enableEffect(effect: Nullable<Effect>): void;
  29492. /**
  29493. * Set the value of an uniform to an array of int32
  29494. * @param uniform defines the webGL uniform location where to store the value
  29495. * @param array defines the array of int32 to store
  29496. */
  29497. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29498. /**
  29499. * Set the value of an uniform to an array of int32 (stored as vec2)
  29500. * @param uniform defines the webGL uniform location where to store the value
  29501. * @param array defines the array of int32 to store
  29502. */
  29503. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29504. /**
  29505. * Set the value of an uniform to an array of int32 (stored as vec3)
  29506. * @param uniform defines the webGL uniform location where to store the value
  29507. * @param array defines the array of int32 to store
  29508. */
  29509. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29510. /**
  29511. * Set the value of an uniform to an array of int32 (stored as vec4)
  29512. * @param uniform defines the webGL uniform location where to store the value
  29513. * @param array defines the array of int32 to store
  29514. */
  29515. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29516. /**
  29517. * Set the value of an uniform to an array of float32
  29518. * @param uniform defines the webGL uniform location where to store the value
  29519. * @param array defines the array of float32 to store
  29520. */
  29521. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29522. /**
  29523. * Set the value of an uniform to an array of float32 (stored as vec2)
  29524. * @param uniform defines the webGL uniform location where to store the value
  29525. * @param array defines the array of float32 to store
  29526. */
  29527. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29528. /**
  29529. * Set the value of an uniform to an array of float32 (stored as vec3)
  29530. * @param uniform defines the webGL uniform location where to store the value
  29531. * @param array defines the array of float32 to store
  29532. */
  29533. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29534. /**
  29535. * Set the value of an uniform to an array of float32 (stored as vec4)
  29536. * @param uniform defines the webGL uniform location where to store the value
  29537. * @param array defines the array of float32 to store
  29538. */
  29539. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29540. /**
  29541. * Set the value of an uniform to an array of number
  29542. * @param uniform defines the webGL uniform location where to store the value
  29543. * @param array defines the array of number to store
  29544. */
  29545. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29546. /**
  29547. * Set the value of an uniform to an array of number (stored as vec2)
  29548. * @param uniform defines the webGL uniform location where to store the value
  29549. * @param array defines the array of number to store
  29550. */
  29551. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29552. /**
  29553. * Set the value of an uniform to an array of number (stored as vec3)
  29554. * @param uniform defines the webGL uniform location where to store the value
  29555. * @param array defines the array of number to store
  29556. */
  29557. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29558. /**
  29559. * Set the value of an uniform to an array of number (stored as vec4)
  29560. * @param uniform defines the webGL uniform location where to store the value
  29561. * @param array defines the array of number to store
  29562. */
  29563. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29564. /**
  29565. * Set the value of an uniform to an array of float32 (stored as matrices)
  29566. * @param uniform defines the webGL uniform location where to store the value
  29567. * @param matrices defines the array of float32 to store
  29568. */
  29569. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29570. /**
  29571. * Set the value of an uniform to a matrix
  29572. * @param uniform defines the webGL uniform location where to store the value
  29573. * @param matrix defines the matrix to store
  29574. */
  29575. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29576. /**
  29577. * Set the value of an uniform to a matrix (3x3)
  29578. * @param uniform defines the webGL uniform location where to store the value
  29579. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29580. */
  29581. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29582. /**
  29583. * Set the value of an uniform to a matrix (2x2)
  29584. * @param uniform defines the webGL uniform location where to store the value
  29585. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29586. */
  29587. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29588. /**
  29589. * Set the value of an uniform to a number (int)
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param value defines the int number to store
  29592. */
  29593. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29594. /**
  29595. * Set the value of an uniform to a number (float)
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param value defines the float number to store
  29598. */
  29599. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29600. /**
  29601. * Set the value of an uniform to a vec2
  29602. * @param uniform defines the webGL uniform location where to store the value
  29603. * @param x defines the 1st component of the value
  29604. * @param y defines the 2nd component of the value
  29605. */
  29606. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29607. /**
  29608. * Set the value of an uniform to a vec3
  29609. * @param uniform defines the webGL uniform location where to store the value
  29610. * @param x defines the 1st component of the value
  29611. * @param y defines the 2nd component of the value
  29612. * @param z defines the 3rd component of the value
  29613. */
  29614. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29615. /**
  29616. * Set the value of an uniform to a boolean
  29617. * @param uniform defines the webGL uniform location where to store the value
  29618. * @param bool defines the boolean to store
  29619. */
  29620. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29621. /**
  29622. * Set the value of an uniform to a vec4
  29623. * @param uniform defines the webGL uniform location where to store the value
  29624. * @param x defines the 1st component of the value
  29625. * @param y defines the 2nd component of the value
  29626. * @param z defines the 3rd component of the value
  29627. * @param w defines the 4th component of the value
  29628. */
  29629. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29630. /**
  29631. * Set the value of an uniform to a Color3
  29632. * @param uniform defines the webGL uniform location where to store the value
  29633. * @param color3 defines the color to store
  29634. */
  29635. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29636. /**
  29637. * Set the value of an uniform to a Color3 and an alpha value
  29638. * @param uniform defines the webGL uniform location where to store the value
  29639. * @param color3 defines the color to store
  29640. * @param alpha defines the alpha component to store
  29641. */
  29642. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29643. /**
  29644. * Sets a Color4 on a uniform variable
  29645. * @param uniform defines the uniform location
  29646. * @param color4 defines the value to be set
  29647. */
  29648. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29649. /**
  29650. * Set various states to the webGL context
  29651. * @param culling defines backface culling state
  29652. * @param zOffset defines the value to apply to zOffset (0 by default)
  29653. * @param force defines if states must be applied even if cache is up to date
  29654. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29655. */
  29656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29657. /**
  29658. * Set the z offset to apply to current rendering
  29659. * @param value defines the offset to apply
  29660. */
  29661. setZOffset(value: number): void;
  29662. /**
  29663. * Gets the current value of the zOffset
  29664. * @returns the current zOffset state
  29665. */
  29666. getZOffset(): number;
  29667. /**
  29668. * Enable or disable depth buffering
  29669. * @param enable defines the state to set
  29670. */
  29671. setDepthBuffer(enable: boolean): void;
  29672. /**
  29673. * Gets a boolean indicating if depth writing is enabled
  29674. * @returns the current depth writing state
  29675. */
  29676. getDepthWrite(): boolean;
  29677. /**
  29678. * Enable or disable depth writing
  29679. * @param enable defines the state to set
  29680. */
  29681. setDepthWrite(enable: boolean): void;
  29682. /**
  29683. * Enable or disable color writing
  29684. * @param enable defines the state to set
  29685. */
  29686. setColorWrite(enable: boolean): void;
  29687. /**
  29688. * Gets a boolean indicating if color writing is enabled
  29689. * @returns the current color writing state
  29690. */
  29691. getColorWrite(): boolean;
  29692. /**
  29693. * Sets alpha constants used by some alpha blending modes
  29694. * @param r defines the red component
  29695. * @param g defines the green component
  29696. * @param b defines the blue component
  29697. * @param a defines the alpha component
  29698. */
  29699. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29700. /**
  29701. * Sets the current alpha mode
  29702. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29703. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29705. */
  29706. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29707. /**
  29708. * Gets the current alpha mode
  29709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29710. * @returns the current alpha mode
  29711. */
  29712. getAlphaMode(): number;
  29713. /**
  29714. * Clears the list of texture accessible through engine.
  29715. * This can help preventing texture load conflict due to name collision.
  29716. */
  29717. clearInternalTexturesCache(): void;
  29718. /**
  29719. * Force the entire cache to be cleared
  29720. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29721. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29722. */
  29723. wipeCaches(bruteForce?: boolean): void;
  29724. /**
  29725. * Set the compressed texture format to use, based on the formats you have, and the formats
  29726. * supported by the hardware / browser.
  29727. *
  29728. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29729. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29730. * to API arguments needed to compressed textures. This puts the burden on the container
  29731. * generator to house the arcane code for determining these for current & future formats.
  29732. *
  29733. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29734. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29735. *
  29736. * Note: The result of this call is not taken into account when a texture is base64.
  29737. *
  29738. * @param formatsAvailable defines the list of those format families you have created
  29739. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29740. *
  29741. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29742. * @returns The extension selected.
  29743. */
  29744. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29745. /** @hidden */
  29746. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29747. min: number;
  29748. mag: number;
  29749. };
  29750. /** @hidden */
  29751. _createTexture(): WebGLTexture;
  29752. /**
  29753. * Usually called from Texture.ts.
  29754. * Passed information to create a WebGLTexture
  29755. * @param urlArg defines a value which contains one of the following:
  29756. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29757. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29758. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29759. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29760. * @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)
  29761. * @param scene needed for loading to the correct scene
  29762. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29763. * @param onLoad optional callback to be called upon successful completion
  29764. * @param onError optional callback to be called upon failure
  29765. * @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
  29766. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29767. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29768. * @param forcedExtension defines the extension to use to pick the right loader
  29769. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29770. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29771. */
  29772. 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;
  29773. /**
  29774. * @hidden
  29775. * Rescales a texture
  29776. * @param source input texutre
  29777. * @param destination destination texture
  29778. * @param scene scene to use to render the resize
  29779. * @param internalFormat format to use when resizing
  29780. * @param onComplete callback to be called when resize has completed
  29781. */
  29782. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29783. private _unpackFlipYCached;
  29784. /**
  29785. * In case you are sharing the context with other applications, it might
  29786. * be interested to not cache the unpack flip y state to ensure a consistent
  29787. * value would be set.
  29788. */
  29789. enableUnpackFlipYCached: boolean;
  29790. /** @hidden */
  29791. _unpackFlipY(value: boolean): void;
  29792. /** @hidden */
  29793. _getUnpackAlignement(): number;
  29794. /**
  29795. * Creates a dynamic texture
  29796. * @param width defines the width of the texture
  29797. * @param height defines the height of the texture
  29798. * @param generateMipMaps defines if the engine should generate the mip levels
  29799. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29800. * @returns the dynamic texture inside an InternalTexture
  29801. */
  29802. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29803. /**
  29804. * Update the sampling mode of a given texture
  29805. * @param samplingMode defines the required sampling mode
  29806. * @param texture defines the texture to update
  29807. */
  29808. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29809. /**
  29810. * Update the content of a dynamic texture
  29811. * @param texture defines the texture to update
  29812. * @param canvas defines the canvas containing the source
  29813. * @param invertY defines if data must be stored with Y axis inverted
  29814. * @param premulAlpha defines if alpha is stored as premultiplied
  29815. * @param format defines the format of the data
  29816. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29817. */
  29818. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29819. /**
  29820. * Update a video texture
  29821. * @param texture defines the texture to update
  29822. * @param video defines the video element to use
  29823. * @param invertY defines if data must be stored with Y axis inverted
  29824. */
  29825. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29826. /**
  29827. * Updates a depth texture Comparison Mode and Function.
  29828. * If the comparison Function is equal to 0, the mode will be set to none.
  29829. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29830. * @param texture The texture to set the comparison function for
  29831. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29832. */
  29833. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29834. /** @hidden */
  29835. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29836. width: number;
  29837. height: number;
  29838. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29839. /**
  29840. * Creates a depth stencil texture.
  29841. * This is only available in WebGL 2 or with the depth texture extension available.
  29842. * @param size The size of face edge in the texture.
  29843. * @param options The options defining the texture.
  29844. * @returns The texture
  29845. */
  29846. createDepthStencilTexture(size: number | {
  29847. width: number;
  29848. height: number;
  29849. }, options: DepthTextureCreationOptions): InternalTexture;
  29850. /**
  29851. * Creates a depth stencil texture.
  29852. * This is only available in WebGL 2 or with the depth texture extension available.
  29853. * @param size The size of face edge in the texture.
  29854. * @param options The options defining the texture.
  29855. * @returns The texture
  29856. */
  29857. private _createDepthStencilTexture;
  29858. /**
  29859. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29860. * @param renderTarget The render target to set the frame buffer for
  29861. */
  29862. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29863. /**
  29864. * Creates a new render target texture
  29865. * @param size defines the size of the texture
  29866. * @param options defines the options used to create the texture
  29867. * @returns a new render target texture stored in an InternalTexture
  29868. */
  29869. createRenderTargetTexture(size: number | {
  29870. width: number;
  29871. height: number;
  29872. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29873. /** @hidden */
  29874. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29875. /**
  29876. * Updates the sample count of a render target texture
  29877. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29878. * @param texture defines the texture to update
  29879. * @param samples defines the sample count to set
  29880. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29881. */
  29882. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29883. /** @hidden */
  29884. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29885. /** @hidden */
  29886. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29887. /** @hidden */
  29888. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29889. /** @hidden */
  29890. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29891. /**
  29892. * @hidden
  29893. */
  29894. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29895. private _prepareWebGLTextureContinuation;
  29896. private _prepareWebGLTexture;
  29897. /** @hidden */
  29898. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29899. /** @hidden */
  29900. _releaseFramebufferObjects(texture: InternalTexture): void;
  29901. /** @hidden */
  29902. _releaseTexture(texture: InternalTexture): void;
  29903. private setProgram;
  29904. private _boundUniforms;
  29905. /**
  29906. * Binds an effect to the webGL context
  29907. * @param effect defines the effect to bind
  29908. */
  29909. bindSamplers(effect: Effect): void;
  29910. private _activateCurrentTexture;
  29911. /** @hidden */
  29912. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29913. /** @hidden */
  29914. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29915. /**
  29916. * Sets a texture to the webGL context from a postprocess
  29917. * @param channel defines the channel to use
  29918. * @param postProcess defines the source postprocess
  29919. */
  29920. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29921. /**
  29922. * Binds the output of the passed in post process to the texture channel specified
  29923. * @param channel The channel the texture should be bound to
  29924. * @param postProcess The post process which's output should be bound
  29925. */
  29926. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29927. /**
  29928. * Unbind all textures from the webGL context
  29929. */
  29930. unbindAllTextures(): void;
  29931. /**
  29932. * Sets a texture to the according uniform.
  29933. * @param channel The texture channel
  29934. * @param uniform The uniform to set
  29935. * @param texture The texture to apply
  29936. */
  29937. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29938. /**
  29939. * Sets a depth stencil texture from a render target to the according uniform.
  29940. * @param channel The texture channel
  29941. * @param uniform The uniform to set
  29942. * @param texture The render target texture containing the depth stencil texture to apply
  29943. */
  29944. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29945. private _bindSamplerUniformToChannel;
  29946. private _getTextureWrapMode;
  29947. private _setTexture;
  29948. /**
  29949. * Sets an array of texture to the webGL context
  29950. * @param channel defines the channel where the texture array must be set
  29951. * @param uniform defines the associated uniform location
  29952. * @param textures defines the array of textures to bind
  29953. */
  29954. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29955. /** @hidden */
  29956. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29957. private _setTextureParameterFloat;
  29958. private _setTextureParameterInteger;
  29959. /**
  29960. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29961. * @param x defines the x coordinate of the rectangle where pixels must be read
  29962. * @param y defines the y coordinate of the rectangle where pixels must be read
  29963. * @param width defines the width of the rectangle where pixels must be read
  29964. * @param height defines the height of the rectangle where pixels must be read
  29965. * @returns a Uint8Array containing RGBA colors
  29966. */
  29967. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29968. /**
  29969. * Add an externaly attached data from its key.
  29970. * This method call will fail and return false, if such key already exists.
  29971. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29972. * @param key the unique key that identifies the data
  29973. * @param data the data object to associate to the key for this Engine instance
  29974. * @return true if no such key were already present and the data was added successfully, false otherwise
  29975. */
  29976. addExternalData<T>(key: string, data: T): boolean;
  29977. /**
  29978. * Get an externaly attached data from its key
  29979. * @param key the unique key that identifies the data
  29980. * @return the associated data, if present (can be null), or undefined if not present
  29981. */
  29982. getExternalData<T>(key: string): T;
  29983. /**
  29984. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29985. * @param key the unique key that identifies the data
  29986. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29987. * @return the associated data, can be null if the factory returned null.
  29988. */
  29989. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29990. /**
  29991. * Remove an externaly attached data from the Engine instance
  29992. * @param key the unique key that identifies the data
  29993. * @return true if the data was successfully removed, false if it doesn't exist
  29994. */
  29995. removeExternalData(key: string): boolean;
  29996. /**
  29997. * Unbind all vertex attributes from the webGL context
  29998. */
  29999. unbindAllAttributes(): void;
  30000. /**
  30001. * 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
  30002. */
  30003. releaseEffects(): void;
  30004. /**
  30005. * Dispose and release all associated resources
  30006. */
  30007. dispose(): void;
  30008. /**
  30009. * Display the loading screen
  30010. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30011. */
  30012. displayLoadingUI(): void;
  30013. /**
  30014. * Hide the loading screen
  30015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30016. */
  30017. hideLoadingUI(): void;
  30018. /**
  30019. * Gets the current loading screen object
  30020. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30021. */
  30022. /**
  30023. * Sets the current loading screen object
  30024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30025. */
  30026. loadingScreen: ILoadingScreen;
  30027. /**
  30028. * Sets the current loading screen text
  30029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30030. */
  30031. loadingUIText: string;
  30032. /**
  30033. * Sets the current loading screen background color
  30034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30035. */
  30036. loadingUIBackgroundColor: string;
  30037. /**
  30038. * Attach a new callback raised when context lost event is fired
  30039. * @param callback defines the callback to call
  30040. */
  30041. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30042. /**
  30043. * Attach a new callback raised when context restored event is fired
  30044. * @param callback defines the callback to call
  30045. */
  30046. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30047. /**
  30048. * Gets the source code of the vertex shader associated with a specific webGL program
  30049. * @param program defines the program to use
  30050. * @returns a string containing the source code of the vertex shader associated with the program
  30051. */
  30052. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30053. /**
  30054. * Gets the source code of the fragment shader associated with a specific webGL program
  30055. * @param program defines the program to use
  30056. * @returns a string containing the source code of the fragment shader associated with the program
  30057. */
  30058. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30059. /**
  30060. * Get the current error code of the webGL context
  30061. * @returns the error code
  30062. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30063. */
  30064. getError(): number;
  30065. /**
  30066. * Gets the current framerate
  30067. * @returns a number representing the framerate
  30068. */
  30069. getFps(): number;
  30070. /**
  30071. * Gets the time spent between current and previous frame
  30072. * @returns a number representing the delta time in ms
  30073. */
  30074. getDeltaTime(): number;
  30075. private _measureFps;
  30076. /** @hidden */
  30077. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30078. private _canRenderToFloatFramebuffer;
  30079. private _canRenderToHalfFloatFramebuffer;
  30080. private _canRenderToFramebuffer;
  30081. /** @hidden */
  30082. _getWebGLTextureType(type: number): number;
  30083. /** @hidden */
  30084. _getInternalFormat(format: number): number;
  30085. /** @hidden */
  30086. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30087. /** @hidden */
  30088. _getRGBAMultiSampleBufferFormat(type: number): number;
  30089. /** @hidden */
  30090. _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;
  30091. /** @hidden */
  30092. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30093. /**
  30094. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30095. * @returns true if the engine can be created
  30096. * @ignorenaming
  30097. */
  30098. static isSupported(): boolean;
  30099. }
  30100. }
  30101. declare module "babylonjs/Materials/effect" {
  30102. import { Observable } from "babylonjs/Misc/observable";
  30103. import { Nullable } from "babylonjs/types";
  30104. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30105. import { IDisposable } from "babylonjs/scene";
  30106. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30107. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30108. import { Engine } from "babylonjs/Engines/engine";
  30109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30111. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30114. /**
  30115. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30116. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30117. */
  30118. export class EffectFallbacks {
  30119. private _defines;
  30120. private _currentRank;
  30121. private _maxRank;
  30122. private _mesh;
  30123. /**
  30124. * Removes the fallback from the bound mesh.
  30125. */
  30126. unBindMesh(): void;
  30127. /**
  30128. * Adds a fallback on the specified property.
  30129. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30130. * @param define The name of the define in the shader
  30131. */
  30132. addFallback(rank: number, define: string): void;
  30133. /**
  30134. * Sets the mesh to use CPU skinning when needing to fallback.
  30135. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30136. * @param mesh The mesh to use the fallbacks.
  30137. */
  30138. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30139. /**
  30140. * Checks to see if more fallbacks are still availible.
  30141. */
  30142. readonly isMoreFallbacks: boolean;
  30143. /**
  30144. * Removes the defines that should be removed when falling back.
  30145. * @param currentDefines defines the current define statements for the shader.
  30146. * @param effect defines the current effect we try to compile
  30147. * @returns The resulting defines with defines of the current rank removed.
  30148. */
  30149. reduce(currentDefines: string, effect: Effect): string;
  30150. }
  30151. /**
  30152. * Options to be used when creating an effect.
  30153. */
  30154. export class EffectCreationOptions {
  30155. /**
  30156. * Atrributes that will be used in the shader.
  30157. */
  30158. attributes: string[];
  30159. /**
  30160. * Uniform varible names that will be set in the shader.
  30161. */
  30162. uniformsNames: string[];
  30163. /**
  30164. * Uniform buffer varible names that will be set in the shader.
  30165. */
  30166. uniformBuffersNames: string[];
  30167. /**
  30168. * Sampler texture variable names that will be set in the shader.
  30169. */
  30170. samplers: string[];
  30171. /**
  30172. * Define statements that will be set in the shader.
  30173. */
  30174. defines: any;
  30175. /**
  30176. * Possible fallbacks for this effect to improve performance when needed.
  30177. */
  30178. fallbacks: Nullable<EffectFallbacks>;
  30179. /**
  30180. * Callback that will be called when the shader is compiled.
  30181. */
  30182. onCompiled: Nullable<(effect: Effect) => void>;
  30183. /**
  30184. * Callback that will be called if an error occurs during shader compilation.
  30185. */
  30186. onError: Nullable<(effect: Effect, errors: string) => void>;
  30187. /**
  30188. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30189. */
  30190. indexParameters: any;
  30191. /**
  30192. * Max number of lights that can be used in the shader.
  30193. */
  30194. maxSimultaneousLights: number;
  30195. /**
  30196. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30197. */
  30198. transformFeedbackVaryings: Nullable<string[]>;
  30199. }
  30200. /**
  30201. * Effect containing vertex and fragment shader that can be executed on an object.
  30202. */
  30203. export class Effect implements IDisposable {
  30204. /**
  30205. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30206. */
  30207. static ShadersRepository: string;
  30208. /**
  30209. * Name of the effect.
  30210. */
  30211. name: any;
  30212. /**
  30213. * String container all the define statements that should be set on the shader.
  30214. */
  30215. defines: string;
  30216. /**
  30217. * Callback that will be called when the shader is compiled.
  30218. */
  30219. onCompiled: Nullable<(effect: Effect) => void>;
  30220. /**
  30221. * Callback that will be called if an error occurs during shader compilation.
  30222. */
  30223. onError: Nullable<(effect: Effect, errors: string) => void>;
  30224. /**
  30225. * Callback that will be called when effect is bound.
  30226. */
  30227. onBind: Nullable<(effect: Effect) => void>;
  30228. /**
  30229. * Unique ID of the effect.
  30230. */
  30231. uniqueId: number;
  30232. /**
  30233. * Observable that will be called when the shader is compiled.
  30234. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30235. */
  30236. onCompileObservable: Observable<Effect>;
  30237. /**
  30238. * Observable that will be called if an error occurs during shader compilation.
  30239. */
  30240. onErrorObservable: Observable<Effect>;
  30241. /** @hidden */
  30242. _onBindObservable: Nullable<Observable<Effect>>;
  30243. /**
  30244. * Observable that will be called when effect is bound.
  30245. */
  30246. readonly onBindObservable: Observable<Effect>;
  30247. /** @hidden */
  30248. _bonesComputationForcedToCPU: boolean;
  30249. private static _uniqueIdSeed;
  30250. private _engine;
  30251. private _uniformBuffersNames;
  30252. private _uniformsNames;
  30253. private _samplerList;
  30254. private _samplers;
  30255. private _isReady;
  30256. private _compilationError;
  30257. private _attributesNames;
  30258. private _attributes;
  30259. private _uniforms;
  30260. /**
  30261. * Key for the effect.
  30262. * @hidden
  30263. */
  30264. _key: string;
  30265. private _indexParameters;
  30266. private _fallbacks;
  30267. private _vertexSourceCode;
  30268. private _fragmentSourceCode;
  30269. private _vertexSourceCodeOverride;
  30270. private _fragmentSourceCodeOverride;
  30271. private _transformFeedbackVaryings;
  30272. /**
  30273. * Compiled shader to webGL program.
  30274. * @hidden
  30275. */
  30276. _pipelineContext: Nullable<IPipelineContext>;
  30277. private _valueCache;
  30278. private static _baseCache;
  30279. /**
  30280. * Instantiates an effect.
  30281. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30282. * @param baseName Name of the effect.
  30283. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30284. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30285. * @param samplers List of sampler variables that will be passed to the shader.
  30286. * @param engine Engine to be used to render the effect
  30287. * @param defines Define statements to be added to the shader.
  30288. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30289. * @param onCompiled Callback that will be called when the shader is compiled.
  30290. * @param onError Callback that will be called if an error occurs during shader compilation.
  30291. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30292. */
  30293. 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);
  30294. private _useFinalCode;
  30295. /**
  30296. * Unique key for this effect
  30297. */
  30298. readonly key: string;
  30299. /**
  30300. * If the effect has been compiled and prepared.
  30301. * @returns if the effect is compiled and prepared.
  30302. */
  30303. isReady(): boolean;
  30304. /**
  30305. * The engine the effect was initialized with.
  30306. * @returns the engine.
  30307. */
  30308. getEngine(): Engine;
  30309. /**
  30310. * The pipeline context for this effect
  30311. * @returns the associated pipeline context
  30312. */
  30313. getPipelineContext(): Nullable<IPipelineContext>;
  30314. /**
  30315. * The set of names of attribute variables for the shader.
  30316. * @returns An array of attribute names.
  30317. */
  30318. getAttributesNames(): string[];
  30319. /**
  30320. * Returns the attribute at the given index.
  30321. * @param index The index of the attribute.
  30322. * @returns The location of the attribute.
  30323. */
  30324. getAttributeLocation(index: number): number;
  30325. /**
  30326. * Returns the attribute based on the name of the variable.
  30327. * @param name of the attribute to look up.
  30328. * @returns the attribute location.
  30329. */
  30330. getAttributeLocationByName(name: string): number;
  30331. /**
  30332. * The number of attributes.
  30333. * @returns the numnber of attributes.
  30334. */
  30335. getAttributesCount(): number;
  30336. /**
  30337. * Gets the index of a uniform variable.
  30338. * @param uniformName of the uniform to look up.
  30339. * @returns the index.
  30340. */
  30341. getUniformIndex(uniformName: string): number;
  30342. /**
  30343. * Returns the attribute based on the name of the variable.
  30344. * @param uniformName of the uniform to look up.
  30345. * @returns the location of the uniform.
  30346. */
  30347. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30348. /**
  30349. * Returns an array of sampler variable names
  30350. * @returns The array of sampler variable neames.
  30351. */
  30352. getSamplers(): string[];
  30353. /**
  30354. * The error from the last compilation.
  30355. * @returns the error string.
  30356. */
  30357. getCompilationError(): string;
  30358. /**
  30359. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30360. * @param func The callback to be used.
  30361. */
  30362. executeWhenCompiled(func: (effect: Effect) => void): void;
  30363. private _checkIsReady;
  30364. /** @hidden */
  30365. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30366. /** @hidden */
  30367. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30368. /** @hidden */
  30369. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30370. /**
  30371. * Recompiles the webGL program
  30372. * @param vertexSourceCode The source code for the vertex shader.
  30373. * @param fragmentSourceCode The source code for the fragment shader.
  30374. * @param onCompiled Callback called when completed.
  30375. * @param onError Callback called on error.
  30376. * @hidden
  30377. */
  30378. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30379. /**
  30380. * Prepares the effect
  30381. * @hidden
  30382. */
  30383. _prepareEffect(): void;
  30384. /**
  30385. * Checks if the effect is supported. (Must be called after compilation)
  30386. */
  30387. readonly isSupported: boolean;
  30388. /**
  30389. * Binds a texture to the engine to be used as output of the shader.
  30390. * @param channel Name of the output variable.
  30391. * @param texture Texture to bind.
  30392. * @hidden
  30393. */
  30394. _bindTexture(channel: string, texture: InternalTexture): void;
  30395. /**
  30396. * Sets a texture on the engine to be used in the shader.
  30397. * @param channel Name of the sampler variable.
  30398. * @param texture Texture to set.
  30399. */
  30400. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30401. /**
  30402. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30403. * @param channel Name of the sampler variable.
  30404. * @param texture Texture to set.
  30405. */
  30406. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30407. /**
  30408. * Sets an array of textures on the engine to be used in the shader.
  30409. * @param channel Name of the variable.
  30410. * @param textures Textures to set.
  30411. */
  30412. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30413. /**
  30414. * 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)
  30415. * @param channel Name of the sampler variable.
  30416. * @param postProcess Post process to get the input texture from.
  30417. */
  30418. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30419. /**
  30420. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30421. * 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)
  30422. * @param channel Name of the sampler variable.
  30423. * @param postProcess Post process to get the output texture from.
  30424. */
  30425. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30426. /** @hidden */
  30427. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30428. /** @hidden */
  30429. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30430. /** @hidden */
  30431. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30432. /** @hidden */
  30433. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30434. /**
  30435. * Binds a buffer to a uniform.
  30436. * @param buffer Buffer to bind.
  30437. * @param name Name of the uniform variable to bind to.
  30438. */
  30439. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30440. /**
  30441. * Binds block to a uniform.
  30442. * @param blockName Name of the block to bind.
  30443. * @param index Index to bind.
  30444. */
  30445. bindUniformBlock(blockName: string, index: number): void;
  30446. /**
  30447. * Sets an interger value on a uniform variable.
  30448. * @param uniformName Name of the variable.
  30449. * @param value Value to be set.
  30450. * @returns this effect.
  30451. */
  30452. setInt(uniformName: string, value: number): Effect;
  30453. /**
  30454. * Sets an int array on a uniform variable.
  30455. * @param uniformName Name of the variable.
  30456. * @param array array to be set.
  30457. * @returns this effect.
  30458. */
  30459. setIntArray(uniformName: string, array: Int32Array): Effect;
  30460. /**
  30461. * 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)
  30462. * @param uniformName Name of the variable.
  30463. * @param array array to be set.
  30464. * @returns this effect.
  30465. */
  30466. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30467. /**
  30468. * 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)
  30469. * @param uniformName Name of the variable.
  30470. * @param array array to be set.
  30471. * @returns this effect.
  30472. */
  30473. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30474. /**
  30475. * 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)
  30476. * @param uniformName Name of the variable.
  30477. * @param array array to be set.
  30478. * @returns this effect.
  30479. */
  30480. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30481. /**
  30482. * Sets an float array on a uniform variable.
  30483. * @param uniformName Name of the variable.
  30484. * @param array array to be set.
  30485. * @returns this effect.
  30486. */
  30487. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30488. /**
  30489. * 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)
  30490. * @param uniformName Name of the variable.
  30491. * @param array array to be set.
  30492. * @returns this effect.
  30493. */
  30494. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30495. /**
  30496. * 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)
  30497. * @param uniformName Name of the variable.
  30498. * @param array array to be set.
  30499. * @returns this effect.
  30500. */
  30501. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30502. /**
  30503. * 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)
  30504. * @param uniformName Name of the variable.
  30505. * @param array array to be set.
  30506. * @returns this effect.
  30507. */
  30508. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30509. /**
  30510. * Sets an array on a uniform variable.
  30511. * @param uniformName Name of the variable.
  30512. * @param array array to be set.
  30513. * @returns this effect.
  30514. */
  30515. setArray(uniformName: string, array: number[]): Effect;
  30516. /**
  30517. * 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)
  30518. * @param uniformName Name of the variable.
  30519. * @param array array to be set.
  30520. * @returns this effect.
  30521. */
  30522. setArray2(uniformName: string, array: number[]): Effect;
  30523. /**
  30524. * 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)
  30525. * @param uniformName Name of the variable.
  30526. * @param array array to be set.
  30527. * @returns this effect.
  30528. */
  30529. setArray3(uniformName: string, array: number[]): Effect;
  30530. /**
  30531. * 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)
  30532. * @param uniformName Name of the variable.
  30533. * @param array array to be set.
  30534. * @returns this effect.
  30535. */
  30536. setArray4(uniformName: string, array: number[]): Effect;
  30537. /**
  30538. * Sets matrices on a uniform variable.
  30539. * @param uniformName Name of the variable.
  30540. * @param matrices matrices to be set.
  30541. * @returns this effect.
  30542. */
  30543. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30544. /**
  30545. * Sets matrix on a uniform variable.
  30546. * @param uniformName Name of the variable.
  30547. * @param matrix matrix to be set.
  30548. * @returns this effect.
  30549. */
  30550. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30551. /**
  30552. * 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)
  30553. * @param uniformName Name of the variable.
  30554. * @param matrix matrix to be set.
  30555. * @returns this effect.
  30556. */
  30557. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30558. /**
  30559. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30560. * @param uniformName Name of the variable.
  30561. * @param matrix matrix to be set.
  30562. * @returns this effect.
  30563. */
  30564. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30565. /**
  30566. * Sets a float on a uniform variable.
  30567. * @param uniformName Name of the variable.
  30568. * @param value value to be set.
  30569. * @returns this effect.
  30570. */
  30571. setFloat(uniformName: string, value: number): Effect;
  30572. /**
  30573. * Sets a boolean on a uniform variable.
  30574. * @param uniformName Name of the variable.
  30575. * @param bool value to be set.
  30576. * @returns this effect.
  30577. */
  30578. setBool(uniformName: string, bool: boolean): Effect;
  30579. /**
  30580. * Sets a Vector2 on a uniform variable.
  30581. * @param uniformName Name of the variable.
  30582. * @param vector2 vector2 to be set.
  30583. * @returns this effect.
  30584. */
  30585. setVector2(uniformName: string, vector2: Vector2): Effect;
  30586. /**
  30587. * Sets a float2 on a uniform variable.
  30588. * @param uniformName Name of the variable.
  30589. * @param x First float in float2.
  30590. * @param y Second float in float2.
  30591. * @returns this effect.
  30592. */
  30593. setFloat2(uniformName: string, x: number, y: number): Effect;
  30594. /**
  30595. * Sets a Vector3 on a uniform variable.
  30596. * @param uniformName Name of the variable.
  30597. * @param vector3 Value to be set.
  30598. * @returns this effect.
  30599. */
  30600. setVector3(uniformName: string, vector3: Vector3): Effect;
  30601. /**
  30602. * Sets a float3 on a uniform variable.
  30603. * @param uniformName Name of the variable.
  30604. * @param x First float in float3.
  30605. * @param y Second float in float3.
  30606. * @param z Third float in float3.
  30607. * @returns this effect.
  30608. */
  30609. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30610. /**
  30611. * Sets a Vector4 on a uniform variable.
  30612. * @param uniformName Name of the variable.
  30613. * @param vector4 Value to be set.
  30614. * @returns this effect.
  30615. */
  30616. setVector4(uniformName: string, vector4: Vector4): Effect;
  30617. /**
  30618. * Sets a float4 on a uniform variable.
  30619. * @param uniformName Name of the variable.
  30620. * @param x First float in float4.
  30621. * @param y Second float in float4.
  30622. * @param z Third float in float4.
  30623. * @param w Fourth float in float4.
  30624. * @returns this effect.
  30625. */
  30626. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30627. /**
  30628. * Sets a Color3 on a uniform variable.
  30629. * @param uniformName Name of the variable.
  30630. * @param color3 Value to be set.
  30631. * @returns this effect.
  30632. */
  30633. setColor3(uniformName: string, color3: Color3): Effect;
  30634. /**
  30635. * Sets a Color4 on a uniform variable.
  30636. * @param uniformName Name of the variable.
  30637. * @param color3 Value to be set.
  30638. * @param alpha Alpha value to be set.
  30639. * @returns this effect.
  30640. */
  30641. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30642. /**
  30643. * Sets a Color4 on a uniform variable
  30644. * @param uniformName defines the name of the variable
  30645. * @param color4 defines the value to be set
  30646. * @returns this effect.
  30647. */
  30648. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30649. /** Release all associated resources */
  30650. dispose(): void;
  30651. /**
  30652. * This function will add a new shader to the shader store
  30653. * @param name the name of the shader
  30654. * @param pixelShader optional pixel shader content
  30655. * @param vertexShader optional vertex shader content
  30656. */
  30657. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30658. /**
  30659. * Store of each shader (The can be looked up using effect.key)
  30660. */
  30661. static ShadersStore: {
  30662. [key: string]: string;
  30663. };
  30664. /**
  30665. * Store of each included file for a shader (The can be looked up using effect.key)
  30666. */
  30667. static IncludesShadersStore: {
  30668. [key: string]: string;
  30669. };
  30670. /**
  30671. * Resets the cache of effects.
  30672. */
  30673. static ResetCache(): void;
  30674. }
  30675. }
  30676. declare module "babylonjs/Materials/colorCurves" {
  30677. import { Effect } from "babylonjs/Materials/effect";
  30678. /**
  30679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30681. * 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;
  30682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30683. */
  30684. export class ColorCurves {
  30685. private _dirty;
  30686. private _tempColor;
  30687. private _globalCurve;
  30688. private _highlightsCurve;
  30689. private _midtonesCurve;
  30690. private _shadowsCurve;
  30691. private _positiveCurve;
  30692. private _negativeCurve;
  30693. private _globalHue;
  30694. private _globalDensity;
  30695. private _globalSaturation;
  30696. private _globalExposure;
  30697. /**
  30698. * Gets the global Hue value.
  30699. * 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).
  30700. */
  30701. /**
  30702. * Sets the global Hue value.
  30703. * 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).
  30704. */
  30705. globalHue: number;
  30706. /**
  30707. * Gets the global Density value.
  30708. * 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.
  30709. * Values less than zero provide a filter of opposite hue.
  30710. */
  30711. /**
  30712. * Sets the global Density value.
  30713. * 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.
  30714. * Values less than zero provide a filter of opposite hue.
  30715. */
  30716. globalDensity: number;
  30717. /**
  30718. * Gets the global Saturation value.
  30719. * 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.
  30720. */
  30721. /**
  30722. * Sets the global Saturation value.
  30723. * 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.
  30724. */
  30725. globalSaturation: number;
  30726. /**
  30727. * Gets the global Exposure value.
  30728. * 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.
  30729. */
  30730. /**
  30731. * Sets the global Exposure value.
  30732. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  30733. */
  30734. globalExposure: number;
  30735. private _highlightsHue;
  30736. private _highlightsDensity;
  30737. private _highlightsSaturation;
  30738. private _highlightsExposure;
  30739. /**
  30740. * Gets the highlights Hue value.
  30741. * 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).
  30742. */
  30743. /**
  30744. * Sets the highlights Hue value.
  30745. * 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).
  30746. */
  30747. highlightsHue: number;
  30748. /**
  30749. * Gets the highlights Density value.
  30750. * 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.
  30751. * Values less than zero provide a filter of opposite hue.
  30752. */
  30753. /**
  30754. * Sets the highlights Density value.
  30755. * 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.
  30756. * Values less than zero provide a filter of opposite hue.
  30757. */
  30758. highlightsDensity: number;
  30759. /**
  30760. * Gets the highlights Saturation value.
  30761. * 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.
  30762. */
  30763. /**
  30764. * Sets the highlights Saturation value.
  30765. * 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.
  30766. */
  30767. highlightsSaturation: number;
  30768. /**
  30769. * Gets the highlights Exposure value.
  30770. * 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.
  30771. */
  30772. /**
  30773. * Sets the highlights Exposure value.
  30774. * 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.
  30775. */
  30776. highlightsExposure: number;
  30777. private _midtonesHue;
  30778. private _midtonesDensity;
  30779. private _midtonesSaturation;
  30780. private _midtonesExposure;
  30781. /**
  30782. * Gets the midtones Hue value.
  30783. * 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).
  30784. */
  30785. /**
  30786. * Sets the midtones Hue value.
  30787. * 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).
  30788. */
  30789. midtonesHue: number;
  30790. /**
  30791. * Gets the midtones Density value.
  30792. * 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.
  30793. * Values less than zero provide a filter of opposite hue.
  30794. */
  30795. /**
  30796. * Sets the midtones Density value.
  30797. * 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.
  30798. * Values less than zero provide a filter of opposite hue.
  30799. */
  30800. midtonesDensity: number;
  30801. /**
  30802. * Gets the midtones Saturation value.
  30803. * 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.
  30804. */
  30805. /**
  30806. * Sets the midtones Saturation value.
  30807. * 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.
  30808. */
  30809. midtonesSaturation: number;
  30810. /**
  30811. * Gets the midtones Exposure value.
  30812. * 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.
  30813. */
  30814. /**
  30815. * Sets the midtones Exposure value.
  30816. * 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.
  30817. */
  30818. midtonesExposure: number;
  30819. private _shadowsHue;
  30820. private _shadowsDensity;
  30821. private _shadowsSaturation;
  30822. private _shadowsExposure;
  30823. /**
  30824. * Gets the shadows Hue value.
  30825. * 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).
  30826. */
  30827. /**
  30828. * Sets the shadows Hue value.
  30829. * 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).
  30830. */
  30831. shadowsHue: number;
  30832. /**
  30833. * Gets the shadows Density value.
  30834. * 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.
  30835. * Values less than zero provide a filter of opposite hue.
  30836. */
  30837. /**
  30838. * Sets the shadows Density value.
  30839. * 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.
  30840. * Values less than zero provide a filter of opposite hue.
  30841. */
  30842. shadowsDensity: number;
  30843. /**
  30844. * Gets the shadows Saturation value.
  30845. * 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.
  30846. */
  30847. /**
  30848. * Sets the shadows Saturation value.
  30849. * 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.
  30850. */
  30851. shadowsSaturation: number;
  30852. /**
  30853. * Gets the shadows Exposure value.
  30854. * 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.
  30855. */
  30856. /**
  30857. * Sets the shadows Exposure value.
  30858. * 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.
  30859. */
  30860. shadowsExposure: number;
  30861. /**
  30862. * Returns the class name
  30863. * @returns The class name
  30864. */
  30865. getClassName(): string;
  30866. /**
  30867. * Binds the color curves to the shader.
  30868. * @param colorCurves The color curve to bind
  30869. * @param effect The effect to bind to
  30870. * @param positiveUniform The positive uniform shader parameter
  30871. * @param neutralUniform The neutral uniform shader parameter
  30872. * @param negativeUniform The negative uniform shader parameter
  30873. */
  30874. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30875. /**
  30876. * Prepare the list of uniforms associated with the ColorCurves effects.
  30877. * @param uniformsList The list of uniforms used in the effect
  30878. */
  30879. static PrepareUniforms(uniformsList: string[]): void;
  30880. /**
  30881. * Returns color grading data based on a hue, density, saturation and exposure value.
  30882. * @param filterHue The hue of the color filter.
  30883. * @param filterDensity The density of the color filter.
  30884. * @param saturation The saturation.
  30885. * @param exposure The exposure.
  30886. * @param result The result data container.
  30887. */
  30888. private getColorGradingDataToRef;
  30889. /**
  30890. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30891. * @param value The input slider value in range [-100,100].
  30892. * @returns Adjusted value.
  30893. */
  30894. private static applyColorGradingSliderNonlinear;
  30895. /**
  30896. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30897. * @param hue The hue (H) input.
  30898. * @param saturation The saturation (S) input.
  30899. * @param brightness The brightness (B) input.
  30900. * @result An RGBA color represented as Vector4.
  30901. */
  30902. private static fromHSBToRef;
  30903. /**
  30904. * Returns a value clamped between min and max
  30905. * @param value The value to clamp
  30906. * @param min The minimum of value
  30907. * @param max The maximum of value
  30908. * @returns The clamped value.
  30909. */
  30910. private static clamp;
  30911. /**
  30912. * Clones the current color curve instance.
  30913. * @return The cloned curves
  30914. */
  30915. clone(): ColorCurves;
  30916. /**
  30917. * Serializes the current color curve instance to a json representation.
  30918. * @return a JSON representation
  30919. */
  30920. serialize(): any;
  30921. /**
  30922. * Parses the color curve from a json representation.
  30923. * @param source the JSON source to parse
  30924. * @return The parsed curves
  30925. */
  30926. static Parse(source: any): ColorCurves;
  30927. }
  30928. }
  30929. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30930. import { Observable } from "babylonjs/Misc/observable";
  30931. import { Nullable } from "babylonjs/types";
  30932. import { Color4 } from "babylonjs/Maths/math";
  30933. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30934. import { Effect } from "babylonjs/Materials/effect";
  30935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30936. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30937. /**
  30938. * Interface to follow in your material defines to integrate easily the
  30939. * Image proccessing functions.
  30940. * @hidden
  30941. */
  30942. export interface IImageProcessingConfigurationDefines {
  30943. IMAGEPROCESSING: boolean;
  30944. VIGNETTE: boolean;
  30945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30946. VIGNETTEBLENDMODEOPAQUE: boolean;
  30947. TONEMAPPING: boolean;
  30948. TONEMAPPING_ACES: boolean;
  30949. CONTRAST: boolean;
  30950. EXPOSURE: boolean;
  30951. COLORCURVES: boolean;
  30952. COLORGRADING: boolean;
  30953. COLORGRADING3D: boolean;
  30954. SAMPLER3DGREENDEPTH: boolean;
  30955. SAMPLER3DBGRMAP: boolean;
  30956. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30957. }
  30958. /**
  30959. * @hidden
  30960. */
  30961. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30962. IMAGEPROCESSING: boolean;
  30963. VIGNETTE: boolean;
  30964. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30965. VIGNETTEBLENDMODEOPAQUE: boolean;
  30966. TONEMAPPING: boolean;
  30967. TONEMAPPING_ACES: boolean;
  30968. CONTRAST: boolean;
  30969. COLORCURVES: boolean;
  30970. COLORGRADING: boolean;
  30971. COLORGRADING3D: boolean;
  30972. SAMPLER3DGREENDEPTH: boolean;
  30973. SAMPLER3DBGRMAP: boolean;
  30974. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30975. EXPOSURE: boolean;
  30976. constructor();
  30977. }
  30978. /**
  30979. * This groups together the common properties used for image processing either in direct forward pass
  30980. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30981. * or not.
  30982. */
  30983. export class ImageProcessingConfiguration {
  30984. /**
  30985. * Default tone mapping applied in BabylonJS.
  30986. */
  30987. static readonly TONEMAPPING_STANDARD: number;
  30988. /**
  30989. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30990. * to other engines rendering to increase portability.
  30991. */
  30992. static readonly TONEMAPPING_ACES: number;
  30993. /**
  30994. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30995. */
  30996. colorCurves: Nullable<ColorCurves>;
  30997. private _colorCurvesEnabled;
  30998. /**
  30999. * Gets wether the color curves effect is enabled.
  31000. */
  31001. /**
  31002. * Sets wether the color curves effect is enabled.
  31003. */
  31004. colorCurvesEnabled: boolean;
  31005. private _colorGradingTexture;
  31006. /**
  31007. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31008. */
  31009. /**
  31010. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31011. */
  31012. colorGradingTexture: Nullable<BaseTexture>;
  31013. private _colorGradingEnabled;
  31014. /**
  31015. * Gets wether the color grading effect is enabled.
  31016. */
  31017. /**
  31018. * Sets wether the color grading effect is enabled.
  31019. */
  31020. colorGradingEnabled: boolean;
  31021. private _colorGradingWithGreenDepth;
  31022. /**
  31023. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31024. */
  31025. /**
  31026. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31027. */
  31028. colorGradingWithGreenDepth: boolean;
  31029. private _colorGradingBGR;
  31030. /**
  31031. * Gets wether the color grading texture contains BGR values.
  31032. */
  31033. /**
  31034. * Sets wether the color grading texture contains BGR values.
  31035. */
  31036. colorGradingBGR: boolean;
  31037. /** @hidden */
  31038. _exposure: number;
  31039. /**
  31040. * Gets the Exposure used in the effect.
  31041. */
  31042. /**
  31043. * Sets the Exposure used in the effect.
  31044. */
  31045. exposure: number;
  31046. private _toneMappingEnabled;
  31047. /**
  31048. * Gets wether the tone mapping effect is enabled.
  31049. */
  31050. /**
  31051. * Sets wether the tone mapping effect is enabled.
  31052. */
  31053. toneMappingEnabled: boolean;
  31054. private _toneMappingType;
  31055. /**
  31056. * Gets the type of tone mapping effect.
  31057. */
  31058. /**
  31059. * Sets the type of tone mapping effect used in BabylonJS.
  31060. */
  31061. toneMappingType: number;
  31062. protected _contrast: number;
  31063. /**
  31064. * Gets the contrast used in the effect.
  31065. */
  31066. /**
  31067. * Sets the contrast used in the effect.
  31068. */
  31069. contrast: number;
  31070. /**
  31071. * Vignette stretch size.
  31072. */
  31073. vignetteStretch: number;
  31074. /**
  31075. * Vignette centre X Offset.
  31076. */
  31077. vignetteCentreX: number;
  31078. /**
  31079. * Vignette centre Y Offset.
  31080. */
  31081. vignetteCentreY: number;
  31082. /**
  31083. * Vignette weight or intensity of the vignette effect.
  31084. */
  31085. vignetteWeight: number;
  31086. /**
  31087. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31088. * if vignetteEnabled is set to true.
  31089. */
  31090. vignetteColor: Color4;
  31091. /**
  31092. * Camera field of view used by the Vignette effect.
  31093. */
  31094. vignetteCameraFov: number;
  31095. private _vignetteBlendMode;
  31096. /**
  31097. * Gets the vignette blend mode allowing different kind of effect.
  31098. */
  31099. /**
  31100. * Sets the vignette blend mode allowing different kind of effect.
  31101. */
  31102. vignetteBlendMode: number;
  31103. private _vignetteEnabled;
  31104. /**
  31105. * Gets wether the vignette effect is enabled.
  31106. */
  31107. /**
  31108. * Sets wether the vignette effect is enabled.
  31109. */
  31110. vignetteEnabled: boolean;
  31111. private _applyByPostProcess;
  31112. /**
  31113. * Gets wether the image processing is applied through a post process or not.
  31114. */
  31115. /**
  31116. * Sets wether the image processing is applied through a post process or not.
  31117. */
  31118. applyByPostProcess: boolean;
  31119. private _isEnabled;
  31120. /**
  31121. * Gets wether the image processing is enabled or not.
  31122. */
  31123. /**
  31124. * Sets wether the image processing is enabled or not.
  31125. */
  31126. isEnabled: boolean;
  31127. /**
  31128. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31129. */
  31130. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31131. /**
  31132. * Method called each time the image processing information changes requires to recompile the effect.
  31133. */
  31134. protected _updateParameters(): void;
  31135. /**
  31136. * Gets the current class name.
  31137. * @return "ImageProcessingConfiguration"
  31138. */
  31139. getClassName(): string;
  31140. /**
  31141. * Prepare the list of uniforms associated with the Image Processing effects.
  31142. * @param uniforms The list of uniforms used in the effect
  31143. * @param defines the list of defines currently in use
  31144. */
  31145. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31146. /**
  31147. * Prepare the list of samplers associated with the Image Processing effects.
  31148. * @param samplersList The list of uniforms used in the effect
  31149. * @param defines the list of defines currently in use
  31150. */
  31151. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31152. /**
  31153. * Prepare the list of defines associated to the shader.
  31154. * @param defines the list of defines to complete
  31155. * @param forPostProcess Define if we are currently in post process mode or not
  31156. */
  31157. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31158. /**
  31159. * Returns true if all the image processing information are ready.
  31160. * @returns True if ready, otherwise, false
  31161. */
  31162. isReady(): boolean;
  31163. /**
  31164. * Binds the image processing to the shader.
  31165. * @param effect The effect to bind to
  31166. * @param aspectRatio Define the current aspect ratio of the effect
  31167. */
  31168. bind(effect: Effect, aspectRatio?: number): void;
  31169. /**
  31170. * Clones the current image processing instance.
  31171. * @return The cloned image processing
  31172. */
  31173. clone(): ImageProcessingConfiguration;
  31174. /**
  31175. * Serializes the current image processing instance to a json representation.
  31176. * @return a JSON representation
  31177. */
  31178. serialize(): any;
  31179. /**
  31180. * Parses the image processing from a json representation.
  31181. * @param source the JSON source to parse
  31182. * @return The parsed image processing
  31183. */
  31184. static Parse(source: any): ImageProcessingConfiguration;
  31185. private static _VIGNETTEMODE_MULTIPLY;
  31186. private static _VIGNETTEMODE_OPAQUE;
  31187. /**
  31188. * Used to apply the vignette as a mix with the pixel color.
  31189. */
  31190. static readonly VIGNETTEMODE_MULTIPLY: number;
  31191. /**
  31192. * Used to apply the vignette as a replacement of the pixel color.
  31193. */
  31194. static readonly VIGNETTEMODE_OPAQUE: number;
  31195. }
  31196. }
  31197. declare module "babylonjs/Materials/fresnelParameters" {
  31198. import { Color3 } from "babylonjs/Maths/math";
  31199. /**
  31200. * This represents all the required information to add a fresnel effect on a material:
  31201. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31202. */
  31203. export class FresnelParameters {
  31204. private _isEnabled;
  31205. /**
  31206. * Define if the fresnel effect is enable or not.
  31207. */
  31208. isEnabled: boolean;
  31209. /**
  31210. * Define the color used on edges (grazing angle)
  31211. */
  31212. leftColor: Color3;
  31213. /**
  31214. * Define the color used on center
  31215. */
  31216. rightColor: Color3;
  31217. /**
  31218. * Define bias applied to computed fresnel term
  31219. */
  31220. bias: number;
  31221. /**
  31222. * Defined the power exponent applied to fresnel term
  31223. */
  31224. power: number;
  31225. /**
  31226. * Clones the current fresnel and its valuues
  31227. * @returns a clone fresnel configuration
  31228. */
  31229. clone(): FresnelParameters;
  31230. /**
  31231. * Serializes the current fresnel parameters to a JSON representation.
  31232. * @return the JSON serialization
  31233. */
  31234. serialize(): any;
  31235. /**
  31236. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31237. * @param parsedFresnelParameters Define the JSON representation
  31238. * @returns the parsed parameters
  31239. */
  31240. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31241. }
  31242. }
  31243. declare module "babylonjs/Misc/decorators" {
  31244. import { Nullable } from "babylonjs/types";
  31245. import { Scene } from "babylonjs/scene";
  31246. import { IAnimatable } from "babylonjs/Misc/tools";
  31247. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31248. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31249. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31250. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31251. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31252. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31253. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31254. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31255. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31256. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31257. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31258. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31259. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31260. /**
  31261. * Decorator used to define property that can be serialized as reference to a camera
  31262. * @param sourceName defines the name of the property to decorate
  31263. */
  31264. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31265. /**
  31266. * Class used to help serialization objects
  31267. */
  31268. export class SerializationHelper {
  31269. /** @hidden */
  31270. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31271. /** @hidden */
  31272. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31273. /** @hidden */
  31274. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31275. /** @hidden */
  31276. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31277. /**
  31278. * Appends the serialized animations from the source animations
  31279. * @param source Source containing the animations
  31280. * @param destination Target to store the animations
  31281. */
  31282. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31283. /**
  31284. * Static function used to serialized a specific entity
  31285. * @param entity defines the entity to serialize
  31286. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31287. * @returns a JSON compatible object representing the serialization of the entity
  31288. */
  31289. static Serialize<T>(entity: T, serializationObject?: any): any;
  31290. /**
  31291. * Creates a new entity from a serialization data object
  31292. * @param creationFunction defines a function used to instanciated the new entity
  31293. * @param source defines the source serialization data
  31294. * @param scene defines the hosting scene
  31295. * @param rootUrl defines the root url for resources
  31296. * @returns a new entity
  31297. */
  31298. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31299. /**
  31300. * Clones an object
  31301. * @param creationFunction defines the function used to instanciate the new object
  31302. * @param source defines the source object
  31303. * @returns the cloned object
  31304. */
  31305. static Clone<T>(creationFunction: () => T, source: T): T;
  31306. /**
  31307. * Instanciates a new object based on a source one (some data will be shared between both object)
  31308. * @param creationFunction defines the function used to instanciate the new object
  31309. * @param source defines the source object
  31310. * @returns the new object
  31311. */
  31312. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31313. }
  31314. }
  31315. declare module "babylonjs/Cameras/camera" {
  31316. import { SmartArray } from "babylonjs/Misc/smartArray";
  31317. import { Observable } from "babylonjs/Misc/observable";
  31318. import { Nullable } from "babylonjs/types";
  31319. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31320. import { Scene } from "babylonjs/scene";
  31321. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31322. import { Node } from "babylonjs/node";
  31323. import { Mesh } from "babylonjs/Meshes/mesh";
  31324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31325. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31328. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31329. import { Ray } from "babylonjs/Culling/ray";
  31330. /**
  31331. * This is the base class of all the camera used in the application.
  31332. * @see http://doc.babylonjs.com/features/cameras
  31333. */
  31334. export class Camera extends Node {
  31335. /** @hidden */
  31336. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31337. /**
  31338. * This is the default projection mode used by the cameras.
  31339. * It helps recreating a feeling of perspective and better appreciate depth.
  31340. * This is the best way to simulate real life cameras.
  31341. */
  31342. static readonly PERSPECTIVE_CAMERA: number;
  31343. /**
  31344. * This helps creating camera with an orthographic mode.
  31345. * 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.
  31346. */
  31347. static readonly ORTHOGRAPHIC_CAMERA: number;
  31348. /**
  31349. * This is the default FOV mode for perspective cameras.
  31350. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31351. */
  31352. static readonly FOVMODE_VERTICAL_FIXED: number;
  31353. /**
  31354. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31355. */
  31356. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31357. /**
  31358. * This specifies ther is no need for a camera rig.
  31359. * Basically only one eye is rendered corresponding to the camera.
  31360. */
  31361. static readonly RIG_MODE_NONE: number;
  31362. /**
  31363. * Simulates a camera Rig with one blue eye and one red eye.
  31364. * This can be use with 3d blue and red glasses.
  31365. */
  31366. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31367. /**
  31368. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31369. */
  31370. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31371. /**
  31372. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31373. */
  31374. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31375. /**
  31376. * Defines that both eyes of the camera will be rendered over under each other.
  31377. */
  31378. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31379. /**
  31380. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31381. */
  31382. static readonly RIG_MODE_VR: number;
  31383. /**
  31384. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31385. */
  31386. static readonly RIG_MODE_WEBVR: number;
  31387. /**
  31388. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31389. */
  31390. static readonly RIG_MODE_CUSTOM: number;
  31391. /**
  31392. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31393. */
  31394. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31395. /**
  31396. * Define the input manager associated with the camera.
  31397. */
  31398. inputs: CameraInputsManager<Camera>;
  31399. /** @hidden */
  31400. _position: Vector3;
  31401. /**
  31402. * Define the current local position of the camera in the scene
  31403. */
  31404. position: Vector3;
  31405. /**
  31406. * The vector the camera should consider as up.
  31407. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31408. */
  31409. upVector: Vector3;
  31410. /**
  31411. * Define the current limit on the left side for an orthographic camera
  31412. * In scene unit
  31413. */
  31414. orthoLeft: Nullable<number>;
  31415. /**
  31416. * Define the current limit on the right side for an orthographic camera
  31417. * In scene unit
  31418. */
  31419. orthoRight: Nullable<number>;
  31420. /**
  31421. * Define the current limit on the bottom side for an orthographic camera
  31422. * In scene unit
  31423. */
  31424. orthoBottom: Nullable<number>;
  31425. /**
  31426. * Define the current limit on the top side for an orthographic camera
  31427. * In scene unit
  31428. */
  31429. orthoTop: Nullable<number>;
  31430. /**
  31431. * Field Of View is set in Radians. (default is 0.8)
  31432. */
  31433. fov: number;
  31434. /**
  31435. * Define the minimum distance the camera can see from.
  31436. * This is important to note that the depth buffer are not infinite and the closer it starts
  31437. * the more your scene might encounter depth fighting issue.
  31438. */
  31439. minZ: number;
  31440. /**
  31441. * Define the maximum distance the camera can see to.
  31442. * This is important to note that the depth buffer are not infinite and the further it end
  31443. * the more your scene might encounter depth fighting issue.
  31444. */
  31445. maxZ: number;
  31446. /**
  31447. * Define the default inertia of the camera.
  31448. * This helps giving a smooth feeling to the camera movement.
  31449. */
  31450. inertia: number;
  31451. /**
  31452. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31453. */
  31454. mode: number;
  31455. /**
  31456. * Define wether the camera is intermediate.
  31457. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31458. */
  31459. isIntermediate: boolean;
  31460. /**
  31461. * Define the viewport of the camera.
  31462. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31463. */
  31464. viewport: Viewport;
  31465. /**
  31466. * Restricts the camera to viewing objects with the same layerMask.
  31467. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31468. */
  31469. layerMask: number;
  31470. /**
  31471. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31472. */
  31473. fovMode: number;
  31474. /**
  31475. * Rig mode of the camera.
  31476. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31477. * This is normally controlled byt the camera themselves as internal use.
  31478. */
  31479. cameraRigMode: number;
  31480. /**
  31481. * Defines the distance between both "eyes" in case of a RIG
  31482. */
  31483. interaxialDistance: number;
  31484. /**
  31485. * Defines if stereoscopic rendering is done side by side or over under.
  31486. */
  31487. isStereoscopicSideBySide: boolean;
  31488. /**
  31489. * 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
  31490. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31491. * else in the scene.
  31492. */
  31493. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31494. /**
  31495. * When set, the camera will render to this render target instead of the default canvas
  31496. */
  31497. outputRenderTarget: Nullable<RenderTargetTexture>;
  31498. /**
  31499. * Observable triggered when the camera view matrix has changed.
  31500. */
  31501. onViewMatrixChangedObservable: Observable<Camera>;
  31502. /**
  31503. * Observable triggered when the camera Projection matrix has changed.
  31504. */
  31505. onProjectionMatrixChangedObservable: Observable<Camera>;
  31506. /**
  31507. * Observable triggered when the inputs have been processed.
  31508. */
  31509. onAfterCheckInputsObservable: Observable<Camera>;
  31510. /**
  31511. * Observable triggered when reset has been called and applied to the camera.
  31512. */
  31513. onRestoreStateObservable: Observable<Camera>;
  31514. /** @hidden */
  31515. _cameraRigParams: any;
  31516. /** @hidden */
  31517. _rigCameras: Camera[];
  31518. /** @hidden */
  31519. _rigPostProcess: Nullable<PostProcess>;
  31520. protected _webvrViewMatrix: Matrix;
  31521. /** @hidden */
  31522. _skipRendering: boolean;
  31523. /** @hidden */
  31524. _projectionMatrix: Matrix;
  31525. /** @hidden */
  31526. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31527. /** @hidden */
  31528. _activeMeshes: SmartArray<AbstractMesh>;
  31529. protected _globalPosition: Vector3;
  31530. /** @hidden */
  31531. _computedViewMatrix: Matrix;
  31532. private _doNotComputeProjectionMatrix;
  31533. private _transformMatrix;
  31534. private _frustumPlanes;
  31535. private _refreshFrustumPlanes;
  31536. private _storedFov;
  31537. private _stateStored;
  31538. /**
  31539. * Instantiates a new camera object.
  31540. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31541. * @see http://doc.babylonjs.com/features/cameras
  31542. * @param name Defines the name of the camera in the scene
  31543. * @param position Defines the position of the camera
  31544. * @param scene Defines the scene the camera belongs too
  31545. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31546. */
  31547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31548. /**
  31549. * Store current camera state (fov, position, etc..)
  31550. * @returns the camera
  31551. */
  31552. storeState(): Camera;
  31553. /**
  31554. * Restores the camera state values if it has been stored. You must call storeState() first
  31555. */
  31556. protected _restoreStateValues(): boolean;
  31557. /**
  31558. * Restored camera state. You must call storeState() first.
  31559. * @returns true if restored and false otherwise
  31560. */
  31561. restoreState(): boolean;
  31562. /**
  31563. * Gets the class name of the camera.
  31564. * @returns the class name
  31565. */
  31566. getClassName(): string;
  31567. /** @hidden */
  31568. readonly _isCamera: boolean;
  31569. /**
  31570. * Gets a string representation of the camera useful for debug purpose.
  31571. * @param fullDetails Defines that a more verboe level of logging is required
  31572. * @returns the string representation
  31573. */
  31574. toString(fullDetails?: boolean): string;
  31575. /**
  31576. * Gets the current world space position of the camera.
  31577. */
  31578. readonly globalPosition: Vector3;
  31579. /**
  31580. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31581. * @returns the active meshe list
  31582. */
  31583. getActiveMeshes(): SmartArray<AbstractMesh>;
  31584. /**
  31585. * Check wether a mesh is part of the current active mesh list of the camera
  31586. * @param mesh Defines the mesh to check
  31587. * @returns true if active, false otherwise
  31588. */
  31589. isActiveMesh(mesh: Mesh): boolean;
  31590. /**
  31591. * Is this camera ready to be used/rendered
  31592. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31593. * @return true if the camera is ready
  31594. */
  31595. isReady(completeCheck?: boolean): boolean;
  31596. /** @hidden */
  31597. _initCache(): void;
  31598. /** @hidden */
  31599. _updateCache(ignoreParentClass?: boolean): void;
  31600. /** @hidden */
  31601. _isSynchronized(): boolean;
  31602. /** @hidden */
  31603. _isSynchronizedViewMatrix(): boolean;
  31604. /** @hidden */
  31605. _isSynchronizedProjectionMatrix(): boolean;
  31606. /**
  31607. * Attach the input controls to a specific dom element to get the input from.
  31608. * @param element Defines the element the controls should be listened from
  31609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31610. */
  31611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31612. /**
  31613. * Detach the current controls from the specified dom element.
  31614. * @param element Defines the element to stop listening the inputs from
  31615. */
  31616. detachControl(element: HTMLElement): void;
  31617. /**
  31618. * Update the camera state according to the different inputs gathered during the frame.
  31619. */
  31620. update(): void;
  31621. /** @hidden */
  31622. _checkInputs(): void;
  31623. /** @hidden */
  31624. readonly rigCameras: Camera[];
  31625. /**
  31626. * Gets the post process used by the rig cameras
  31627. */
  31628. readonly rigPostProcess: Nullable<PostProcess>;
  31629. /**
  31630. * Internal, gets the first post proces.
  31631. * @returns the first post process to be run on this camera.
  31632. */
  31633. _getFirstPostProcess(): Nullable<PostProcess>;
  31634. private _cascadePostProcessesToRigCams;
  31635. /**
  31636. * Attach a post process to the camera.
  31637. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31638. * @param postProcess The post process to attach to the camera
  31639. * @param insertAt The position of the post process in case several of them are in use in the scene
  31640. * @returns the position the post process has been inserted at
  31641. */
  31642. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31643. /**
  31644. * Detach a post process to the camera.
  31645. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31646. * @param postProcess The post process to detach from the camera
  31647. */
  31648. detachPostProcess(postProcess: PostProcess): void;
  31649. /**
  31650. * Gets the current world matrix of the camera
  31651. */
  31652. getWorldMatrix(): Matrix;
  31653. /** @hidden */
  31654. _getViewMatrix(): Matrix;
  31655. /**
  31656. * Gets the current view matrix of the camera.
  31657. * @param force forces the camera to recompute the matrix without looking at the cached state
  31658. * @returns the view matrix
  31659. */
  31660. getViewMatrix(force?: boolean): Matrix;
  31661. /**
  31662. * Freeze the projection matrix.
  31663. * It will prevent the cache check of the camera projection compute and can speed up perf
  31664. * if no parameter of the camera are meant to change
  31665. * @param projection Defines manually a projection if necessary
  31666. */
  31667. freezeProjectionMatrix(projection?: Matrix): void;
  31668. /**
  31669. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31670. */
  31671. unfreezeProjectionMatrix(): void;
  31672. /**
  31673. * Gets the current projection matrix of the camera.
  31674. * @param force forces the camera to recompute the matrix without looking at the cached state
  31675. * @returns the projection matrix
  31676. */
  31677. getProjectionMatrix(force?: boolean): Matrix;
  31678. /**
  31679. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31680. * @returns a Matrix
  31681. */
  31682. getTransformationMatrix(): Matrix;
  31683. private _updateFrustumPlanes;
  31684. /**
  31685. * Checks if a cullable object (mesh...) is in the camera frustum
  31686. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31687. * @param target The object to check
  31688. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31689. * @returns true if the object is in frustum otherwise false
  31690. */
  31691. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31692. /**
  31693. * Checks if a cullable object (mesh...) is in the camera frustum
  31694. * Unlike isInFrustum this cheks the full bounding box
  31695. * @param target The object to check
  31696. * @returns true if the object is in frustum otherwise false
  31697. */
  31698. isCompletelyInFrustum(target: ICullable): boolean;
  31699. /**
  31700. * Gets a ray in the forward direction from the camera.
  31701. * @param length Defines the length of the ray to create
  31702. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31703. * @param origin Defines the start point of the ray which defaults to the camera position
  31704. * @returns the forward ray
  31705. */
  31706. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31707. /**
  31708. * Releases resources associated with this node.
  31709. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31710. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31711. */
  31712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31713. /** @hidden */
  31714. _isLeftCamera: boolean;
  31715. /**
  31716. * Gets the left camera of a rig setup in case of Rigged Camera
  31717. */
  31718. readonly isLeftCamera: boolean;
  31719. /** @hidden */
  31720. _isRightCamera: boolean;
  31721. /**
  31722. * Gets the right camera of a rig setup in case of Rigged Camera
  31723. */
  31724. readonly isRightCamera: boolean;
  31725. /**
  31726. * Gets the left camera of a rig setup in case of Rigged Camera
  31727. */
  31728. readonly leftCamera: Nullable<FreeCamera>;
  31729. /**
  31730. * Gets the right camera of a rig setup in case of Rigged Camera
  31731. */
  31732. readonly rightCamera: Nullable<FreeCamera>;
  31733. /**
  31734. * Gets the left camera target of a rig setup in case of Rigged Camera
  31735. * @returns the target position
  31736. */
  31737. getLeftTarget(): Nullable<Vector3>;
  31738. /**
  31739. * Gets the right camera target of a rig setup in case of Rigged Camera
  31740. * @returns the target position
  31741. */
  31742. getRightTarget(): Nullable<Vector3>;
  31743. /**
  31744. * @hidden
  31745. */
  31746. setCameraRigMode(mode: number, rigParams: any): void;
  31747. /** @hidden */
  31748. static _setStereoscopicRigMode(camera: Camera): void;
  31749. /** @hidden */
  31750. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31751. /** @hidden */
  31752. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31753. /** @hidden */
  31754. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31755. /** @hidden */
  31756. _getVRProjectionMatrix(): Matrix;
  31757. protected _updateCameraRotationMatrix(): void;
  31758. protected _updateWebVRCameraRotationMatrix(): void;
  31759. /**
  31760. * This function MUST be overwritten by the different WebVR cameras available.
  31761. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31762. * @hidden
  31763. */
  31764. _getWebVRProjectionMatrix(): Matrix;
  31765. /**
  31766. * This function MUST be overwritten by the different WebVR cameras available.
  31767. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31768. * @hidden
  31769. */
  31770. _getWebVRViewMatrix(): Matrix;
  31771. /** @hidden */
  31772. setCameraRigParameter(name: string, value: any): void;
  31773. /**
  31774. * needs to be overridden by children so sub has required properties to be copied
  31775. * @hidden
  31776. */
  31777. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31778. /**
  31779. * May need to be overridden by children
  31780. * @hidden
  31781. */
  31782. _updateRigCameras(): void;
  31783. /** @hidden */
  31784. _setupInputs(): void;
  31785. /**
  31786. * Serialiaze the camera setup to a json represention
  31787. * @returns the JSON representation
  31788. */
  31789. serialize(): any;
  31790. /**
  31791. * Clones the current camera.
  31792. * @param name The cloned camera name
  31793. * @returns the cloned camera
  31794. */
  31795. clone(name: string): Camera;
  31796. /**
  31797. * Gets the direction of the camera relative to a given local axis.
  31798. * @param localAxis Defines the reference axis to provide a relative direction.
  31799. * @return the direction
  31800. */
  31801. getDirection(localAxis: Vector3): Vector3;
  31802. /**
  31803. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31804. * @param localAxis Defines the reference axis to provide a relative direction.
  31805. * @param result Defines the vector to store the result in
  31806. */
  31807. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31808. /**
  31809. * Gets a camera constructor for a given camera type
  31810. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31811. * @param name The name of the camera the result will be able to instantiate
  31812. * @param scene The scene the result will construct the camera in
  31813. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31814. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31815. * @returns a factory method to construc the camera
  31816. */
  31817. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31818. /**
  31819. * Compute the world matrix of the camera.
  31820. * @returns the camera workd matrix
  31821. */
  31822. computeWorldMatrix(): Matrix;
  31823. /**
  31824. * Parse a JSON and creates the camera from the parsed information
  31825. * @param parsedCamera The JSON to parse
  31826. * @param scene The scene to instantiate the camera in
  31827. * @returns the newly constructed camera
  31828. */
  31829. static Parse(parsedCamera: any, scene: Scene): Camera;
  31830. }
  31831. }
  31832. declare module "babylonjs/Misc/tools" {
  31833. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31834. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31835. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31836. import { Observable } from "babylonjs/Misc/observable";
  31837. import { DomManagement } from "babylonjs/Misc/domManagement";
  31838. import { WebRequest } from "babylonjs/Misc/webRequest";
  31839. import { Camera } from "babylonjs/Cameras/camera";
  31840. import { Engine } from "babylonjs/Engines/engine";
  31841. import { Animation } from "babylonjs/Animations/animation";
  31842. /**
  31843. * Interface for any object that can request an animation frame
  31844. */
  31845. export interface ICustomAnimationFrameRequester {
  31846. /**
  31847. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31848. */
  31849. renderFunction?: Function;
  31850. /**
  31851. * Called to request the next frame to render to
  31852. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31853. */
  31854. requestAnimationFrame: Function;
  31855. /**
  31856. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31857. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31858. */
  31859. requestID?: number;
  31860. }
  31861. /**
  31862. * Interface containing an array of animations
  31863. */
  31864. export interface IAnimatable {
  31865. /**
  31866. * Array of animations
  31867. */
  31868. animations: Nullable<Array<Animation>>;
  31869. }
  31870. /** Interface used by value gradients (color, factor, ...) */
  31871. export interface IValueGradient {
  31872. /**
  31873. * Gets or sets the gradient value (between 0 and 1)
  31874. */
  31875. gradient: number;
  31876. }
  31877. /** Class used to store color4 gradient */
  31878. export class ColorGradient implements IValueGradient {
  31879. /**
  31880. * Gets or sets the gradient value (between 0 and 1)
  31881. */
  31882. gradient: number;
  31883. /**
  31884. * Gets or sets first associated color
  31885. */
  31886. color1: Color4;
  31887. /**
  31888. * Gets or sets second associated color
  31889. */
  31890. color2?: Color4;
  31891. /**
  31892. * Will get a color picked randomly between color1 and color2.
  31893. * If color2 is undefined then color1 will be used
  31894. * @param result defines the target Color4 to store the result in
  31895. */
  31896. getColorToRef(result: Color4): void;
  31897. }
  31898. /** Class used to store color 3 gradient */
  31899. export class Color3Gradient implements IValueGradient {
  31900. /**
  31901. * Gets or sets the gradient value (between 0 and 1)
  31902. */
  31903. gradient: number;
  31904. /**
  31905. * Gets or sets the associated color
  31906. */
  31907. color: Color3;
  31908. }
  31909. /** Class used to store factor gradient */
  31910. export class FactorGradient implements IValueGradient {
  31911. /**
  31912. * Gets or sets the gradient value (between 0 and 1)
  31913. */
  31914. gradient: number;
  31915. /**
  31916. * Gets or sets first associated factor
  31917. */
  31918. factor1: number;
  31919. /**
  31920. * Gets or sets second associated factor
  31921. */
  31922. factor2?: number;
  31923. /**
  31924. * Will get a number picked randomly between factor1 and factor2.
  31925. * If factor2 is undefined then factor1 will be used
  31926. * @returns the picked number
  31927. */
  31928. getFactor(): number;
  31929. }
  31930. /**
  31931. * @ignore
  31932. * Application error to support additional information when loading a file
  31933. */
  31934. export class LoadFileError extends Error {
  31935. /** defines the optional web request */
  31936. request?: WebRequest | undefined;
  31937. private static _setPrototypeOf;
  31938. /**
  31939. * Creates a new LoadFileError
  31940. * @param message defines the message of the error
  31941. * @param request defines the optional web request
  31942. */
  31943. constructor(message: string,
  31944. /** defines the optional web request */
  31945. request?: WebRequest | undefined);
  31946. }
  31947. /**
  31948. * Class used to define a retry strategy when error happens while loading assets
  31949. */
  31950. export class RetryStrategy {
  31951. /**
  31952. * Function used to defines an exponential back off strategy
  31953. * @param maxRetries defines the maximum number of retries (3 by default)
  31954. * @param baseInterval defines the interval between retries
  31955. * @returns the strategy function to use
  31956. */
  31957. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31958. }
  31959. /**
  31960. * File request interface
  31961. */
  31962. export interface IFileRequest {
  31963. /**
  31964. * Raised when the request is complete (success or error).
  31965. */
  31966. onCompleteObservable: Observable<IFileRequest>;
  31967. /**
  31968. * Aborts the request for a file.
  31969. */
  31970. abort: () => void;
  31971. }
  31972. /**
  31973. * Class containing a set of static utilities functions
  31974. */
  31975. export class Tools {
  31976. /**
  31977. * Gets or sets the base URL to use to load assets
  31978. */
  31979. static BaseUrl: string;
  31980. /**
  31981. * Enable/Disable Custom HTTP Request Headers globally.
  31982. * default = false
  31983. * @see CustomRequestHeaders
  31984. */
  31985. static UseCustomRequestHeaders: boolean;
  31986. /**
  31987. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31988. * i.e. when loading files, where the server/service expects an Authorization header
  31989. */
  31990. static CustomRequestHeaders: {
  31991. [key: string]: string;
  31992. };
  31993. /**
  31994. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31995. */
  31996. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31997. /**
  31998. * Default behaviour for cors in the application.
  31999. * It can be a string if the expected behavior is identical in the entire app.
  32000. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32001. */
  32002. static CorsBehavior: string | ((url: string | string[]) => string);
  32003. /**
  32004. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32005. * @ignorenaming
  32006. */
  32007. static UseFallbackTexture: boolean;
  32008. /**
  32009. * Use this object to register external classes like custom textures or material
  32010. * to allow the laoders to instantiate them
  32011. */
  32012. static RegisteredExternalClasses: {
  32013. [key: string]: Object;
  32014. };
  32015. /**
  32016. * Texture content used if a texture cannot loaded
  32017. * @ignorenaming
  32018. */
  32019. static fallbackTexture: string;
  32020. /**
  32021. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32022. * @param u defines the coordinate on X axis
  32023. * @param v defines the coordinate on Y axis
  32024. * @param width defines the width of the source data
  32025. * @param height defines the height of the source data
  32026. * @param pixels defines the source byte array
  32027. * @param color defines the output color
  32028. */
  32029. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32030. /**
  32031. * Interpolates between a and b via alpha
  32032. * @param a The lower value (returned when alpha = 0)
  32033. * @param b The upper value (returned when alpha = 1)
  32034. * @param alpha The interpolation-factor
  32035. * @return The mixed value
  32036. */
  32037. static Mix(a: number, b: number, alpha: number): number;
  32038. /**
  32039. * Tries to instantiate a new object from a given class name
  32040. * @param className defines the class name to instantiate
  32041. * @returns the new object or null if the system was not able to do the instantiation
  32042. */
  32043. static Instantiate(className: string): any;
  32044. /**
  32045. * Provides a slice function that will work even on IE
  32046. * @param data defines the array to slice
  32047. * @param start defines the start of the data (optional)
  32048. * @param end defines the end of the data (optional)
  32049. * @returns the new sliced array
  32050. */
  32051. static Slice<T>(data: T, start?: number, end?: number): T;
  32052. /**
  32053. * Polyfill for setImmediate
  32054. * @param action defines the action to execute after the current execution block
  32055. */
  32056. static SetImmediate(action: () => void): void;
  32057. /**
  32058. * Function indicating if a number is an exponent of 2
  32059. * @param value defines the value to test
  32060. * @returns true if the value is an exponent of 2
  32061. */
  32062. static IsExponentOfTwo(value: number): boolean;
  32063. private static _tmpFloatArray;
  32064. /**
  32065. * Returns the nearest 32-bit single precision float representation of a Number
  32066. * @param value A Number. If the parameter is of a different type, it will get converted
  32067. * to a number or to NaN if it cannot be converted
  32068. * @returns number
  32069. */
  32070. static FloatRound(value: number): number;
  32071. /**
  32072. * Find the next highest power of two.
  32073. * @param x Number to start search from.
  32074. * @return Next highest power of two.
  32075. */
  32076. static CeilingPOT(x: number): number;
  32077. /**
  32078. * Find the next lowest power of two.
  32079. * @param x Number to start search from.
  32080. * @return Next lowest power of two.
  32081. */
  32082. static FloorPOT(x: number): number;
  32083. /**
  32084. * Find the nearest power of two.
  32085. * @param x Number to start search from.
  32086. * @return Next nearest power of two.
  32087. */
  32088. static NearestPOT(x: number): number;
  32089. /**
  32090. * Get the closest exponent of two
  32091. * @param value defines the value to approximate
  32092. * @param max defines the maximum value to return
  32093. * @param mode defines how to define the closest value
  32094. * @returns closest exponent of two of the given value
  32095. */
  32096. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32097. /**
  32098. * Extracts the filename from a path
  32099. * @param path defines the path to use
  32100. * @returns the filename
  32101. */
  32102. static GetFilename(path: string): string;
  32103. /**
  32104. * Extracts the "folder" part of a path (everything before the filename).
  32105. * @param uri The URI to extract the info from
  32106. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32107. * @returns The "folder" part of the path
  32108. */
  32109. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32110. /**
  32111. * Extracts text content from a DOM element hierarchy
  32112. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32113. */
  32114. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32115. /**
  32116. * Convert an angle in radians to degrees
  32117. * @param angle defines the angle to convert
  32118. * @returns the angle in degrees
  32119. */
  32120. static ToDegrees(angle: number): number;
  32121. /**
  32122. * Convert an angle in degrees to radians
  32123. * @param angle defines the angle to convert
  32124. * @returns the angle in radians
  32125. */
  32126. static ToRadians(angle: number): number;
  32127. /**
  32128. * Encode a buffer to a base64 string
  32129. * @param buffer defines the buffer to encode
  32130. * @returns the encoded string
  32131. */
  32132. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32133. /**
  32134. * Extracts minimum and maximum values from a list of indexed positions
  32135. * @param positions defines the positions to use
  32136. * @param indices defines the indices to the positions
  32137. * @param indexStart defines the start index
  32138. * @param indexCount defines the end index
  32139. * @param bias defines bias value to add to the result
  32140. * @return minimum and maximum values
  32141. */
  32142. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32143. minimum: Vector3;
  32144. maximum: Vector3;
  32145. };
  32146. /**
  32147. * Extracts minimum and maximum values from a list of positions
  32148. * @param positions defines the positions to use
  32149. * @param start defines the start index in the positions array
  32150. * @param count defines the number of positions to handle
  32151. * @param bias defines bias value to add to the result
  32152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32153. * @return minimum and maximum values
  32154. */
  32155. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32156. minimum: Vector3;
  32157. maximum: Vector3;
  32158. };
  32159. /**
  32160. * Returns an array if obj is not an array
  32161. * @param obj defines the object to evaluate as an array
  32162. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32163. * @returns either obj directly if obj is an array or a new array containing obj
  32164. */
  32165. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32166. /**
  32167. * Gets the pointer prefix to use
  32168. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32169. */
  32170. static GetPointerPrefix(): string;
  32171. /**
  32172. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32173. * @param func - the function to be called
  32174. * @param requester - the object that will request the next frame. Falls back to window.
  32175. * @returns frame number
  32176. */
  32177. static QueueNewFrame(func: () => void, requester?: any): number;
  32178. /**
  32179. * Ask the browser to promote the current element to fullscreen rendering mode
  32180. * @param element defines the DOM element to promote
  32181. */
  32182. static RequestFullscreen(element: HTMLElement): void;
  32183. /**
  32184. * Asks the browser to exit fullscreen mode
  32185. */
  32186. static ExitFullscreen(): void;
  32187. /**
  32188. * Ask the browser to promote the current element to pointerlock mode
  32189. * @param element defines the DOM element to promote
  32190. */
  32191. static RequestPointerlock(element: HTMLElement): void;
  32192. /**
  32193. * Asks the browser to exit pointerlock mode
  32194. */
  32195. static ExitPointerlock(): void;
  32196. /**
  32197. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32198. * @param url define the url we are trying
  32199. * @param element define the dom element where to configure the cors policy
  32200. */
  32201. static SetCorsBehavior(url: string | string[], element: {
  32202. crossOrigin: string | null;
  32203. }): void;
  32204. /**
  32205. * Removes unwanted characters from an url
  32206. * @param url defines the url to clean
  32207. * @returns the cleaned url
  32208. */
  32209. static CleanUrl(url: string): string;
  32210. /**
  32211. * Gets or sets a function used to pre-process url before using them to load assets
  32212. */
  32213. static PreprocessUrl: (url: string) => string;
  32214. /**
  32215. * Loads an image as an HTMLImageElement.
  32216. * @param input url string, ArrayBuffer, or Blob to load
  32217. * @param onLoad callback called when the image successfully loads
  32218. * @param onError callback called when the image fails to load
  32219. * @param offlineProvider offline provider for caching
  32220. * @returns the HTMLImageElement of the loaded image
  32221. */
  32222. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32223. /**
  32224. * Loads a file
  32225. * @param url url string, ArrayBuffer, or Blob to load
  32226. * @param onSuccess callback called when the file successfully loads
  32227. * @param onProgress callback called while file is loading (if the server supports this mode)
  32228. * @param offlineProvider defines the offline provider for caching
  32229. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32230. * @param onError callback called when the file fails to load
  32231. * @returns a file request object
  32232. */
  32233. 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;
  32234. /**
  32235. * Loads a file from a url
  32236. * @param url the file url to load
  32237. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32238. */
  32239. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32240. /**
  32241. * Load a script (identified by an url). When the url returns, the
  32242. * content of this file is added into a new script element, attached to the DOM (body element)
  32243. * @param scriptUrl defines the url of the script to laod
  32244. * @param onSuccess defines the callback called when the script is loaded
  32245. * @param onError defines the callback to call if an error occurs
  32246. * @param scriptId defines the id of the script element
  32247. */
  32248. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32249. /**
  32250. * Load an asynchronous script (identified by an url). When the url returns, the
  32251. * content of this file is added into a new script element, attached to the DOM (body element)
  32252. * @param scriptUrl defines the url of the script to laod
  32253. * @param scriptId defines the id of the script element
  32254. * @returns a promise request object
  32255. */
  32256. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32257. /**
  32258. * Loads a file from a blob
  32259. * @param fileToLoad defines the blob to use
  32260. * @param callback defines the callback to call when data is loaded
  32261. * @param progressCallback defines the callback to call during loading process
  32262. * @returns a file request object
  32263. */
  32264. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32265. /**
  32266. * Loads a file
  32267. * @param fileToLoad defines the file to load
  32268. * @param callback defines the callback to call when data is loaded
  32269. * @param progressCallBack defines the callback to call during loading process
  32270. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32271. * @returns a file request object
  32272. */
  32273. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32274. /**
  32275. * Creates a data url from a given string content
  32276. * @param content defines the content to convert
  32277. * @returns the new data url link
  32278. */
  32279. static FileAsURL(content: string): string;
  32280. /**
  32281. * Format the given number to a specific decimal format
  32282. * @param value defines the number to format
  32283. * @param decimals defines the number of decimals to use
  32284. * @returns the formatted string
  32285. */
  32286. static Format(value: number, decimals?: number): string;
  32287. /**
  32288. * Checks if a given vector is inside a specific range
  32289. * @param v defines the vector to test
  32290. * @param min defines the minimum range
  32291. * @param max defines the maximum range
  32292. */
  32293. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32294. /**
  32295. * Tries to copy an object by duplicating every property
  32296. * @param source defines the source object
  32297. * @param destination defines the target object
  32298. * @param doNotCopyList defines a list of properties to avoid
  32299. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32300. */
  32301. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32302. /**
  32303. * Gets a boolean indicating if the given object has no own property
  32304. * @param obj defines the object to test
  32305. * @returns true if object has no own property
  32306. */
  32307. static IsEmpty(obj: any): boolean;
  32308. /**
  32309. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32310. * @param str Source string
  32311. * @param suffix Suffix to search for in the source string
  32312. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32313. */
  32314. static EndsWith(str: string, suffix: string): boolean;
  32315. /**
  32316. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32317. * @param str Source string
  32318. * @param suffix Suffix to search for in the source string
  32319. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32320. */
  32321. static StartsWith(str: string, suffix: string): boolean;
  32322. /**
  32323. * Function used to register events at window level
  32324. * @param events defines the events to register
  32325. */
  32326. static RegisterTopRootEvents(events: {
  32327. name: string;
  32328. handler: Nullable<(e: FocusEvent) => any>;
  32329. }[]): void;
  32330. /**
  32331. * Function used to unregister events from window level
  32332. * @param events defines the events to unregister
  32333. */
  32334. static UnregisterTopRootEvents(events: {
  32335. name: string;
  32336. handler: Nullable<(e: FocusEvent) => any>;
  32337. }[]): void;
  32338. /**
  32339. * @ignore
  32340. */
  32341. static _ScreenshotCanvas: HTMLCanvasElement;
  32342. /**
  32343. * Dumps the current bound framebuffer
  32344. * @param width defines the rendering width
  32345. * @param height defines the rendering height
  32346. * @param engine defines the hosting engine
  32347. * @param successCallback defines the callback triggered once the data are available
  32348. * @param mimeType defines the mime type of the result
  32349. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32350. */
  32351. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32352. /**
  32353. * Converts the canvas data to blob.
  32354. * This acts as a polyfill for browsers not supporting the to blob function.
  32355. * @param canvas Defines the canvas to extract the data from
  32356. * @param successCallback Defines the callback triggered once the data are available
  32357. * @param mimeType Defines the mime type of the result
  32358. */
  32359. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32360. /**
  32361. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32362. * @param successCallback defines the callback triggered once the data are available
  32363. * @param mimeType defines the mime type of the result
  32364. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32365. */
  32366. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32367. /**
  32368. * Downloads a blob in the browser
  32369. * @param blob defines the blob to download
  32370. * @param fileName defines the name of the downloaded file
  32371. */
  32372. static Download(blob: Blob, fileName: string): void;
  32373. /**
  32374. * Captures a screenshot of the current rendering
  32375. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32376. * @param engine defines the rendering engine
  32377. * @param camera defines the source camera
  32378. * @param size This parameter can be set to a single number or to an object with the
  32379. * following (optional) properties: precision, width, height. If a single number is passed,
  32380. * it will be used for both width and height. If an object is passed, the screenshot size
  32381. * will be derived from the parameters. The precision property is a multiplier allowing
  32382. * rendering at a higher or lower resolution
  32383. * @param successCallback defines the callback receives a single parameter which contains the
  32384. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32385. * src parameter of an <img> to display it
  32386. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32387. * Check your browser for supported MIME types
  32388. */
  32389. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32390. /**
  32391. * Generates an image screenshot from the specified camera.
  32392. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32393. * @param engine The engine to use for rendering
  32394. * @param camera The camera to use for rendering
  32395. * @param size This parameter can be set to a single number or to an object with the
  32396. * following (optional) properties: precision, width, height. If a single number is passed,
  32397. * it will be used for both width and height. If an object is passed, the screenshot size
  32398. * will be derived from the parameters. The precision property is a multiplier allowing
  32399. * rendering at a higher or lower resolution
  32400. * @param successCallback The callback receives a single parameter which contains the
  32401. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32402. * src parameter of an <img> to display it
  32403. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32404. * Check your browser for supported MIME types
  32405. * @param samples Texture samples (default: 1)
  32406. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32407. * @param fileName A name for for the downloaded file.
  32408. */
  32409. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32410. /**
  32411. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32412. * Be aware Math.random() could cause collisions, but:
  32413. * "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"
  32414. * @returns a pseudo random id
  32415. */
  32416. static RandomId(): string;
  32417. /**
  32418. * Test if the given uri is a base64 string
  32419. * @param uri The uri to test
  32420. * @return True if the uri is a base64 string or false otherwise
  32421. */
  32422. static IsBase64(uri: string): boolean;
  32423. /**
  32424. * Decode the given base64 uri.
  32425. * @param uri The uri to decode
  32426. * @return The decoded base64 data.
  32427. */
  32428. static DecodeBase64(uri: string): ArrayBuffer;
  32429. /**
  32430. * Gets the absolute url.
  32431. * @param url the input url
  32432. * @return the absolute url
  32433. */
  32434. static GetAbsoluteUrl(url: string): string;
  32435. /**
  32436. * No log
  32437. */
  32438. static readonly NoneLogLevel: number;
  32439. /**
  32440. * Only message logs
  32441. */
  32442. static readonly MessageLogLevel: number;
  32443. /**
  32444. * Only warning logs
  32445. */
  32446. static readonly WarningLogLevel: number;
  32447. /**
  32448. * Only error logs
  32449. */
  32450. static readonly ErrorLogLevel: number;
  32451. /**
  32452. * All logs
  32453. */
  32454. static readonly AllLogLevel: number;
  32455. /**
  32456. * Gets a value indicating the number of loading errors
  32457. * @ignorenaming
  32458. */
  32459. static readonly errorsCount: number;
  32460. /**
  32461. * Callback called when a new log is added
  32462. */
  32463. static OnNewCacheEntry: (entry: string) => void;
  32464. /**
  32465. * Log a message to the console
  32466. * @param message defines the message to log
  32467. */
  32468. static Log(message: string): void;
  32469. /**
  32470. * Write a warning message to the console
  32471. * @param message defines the message to log
  32472. */
  32473. static Warn(message: string): void;
  32474. /**
  32475. * Write an error message to the console
  32476. * @param message defines the message to log
  32477. */
  32478. static Error(message: string): void;
  32479. /**
  32480. * Gets current log cache (list of logs)
  32481. */
  32482. static readonly LogCache: string;
  32483. /**
  32484. * Clears the log cache
  32485. */
  32486. static ClearLogCache(): void;
  32487. /**
  32488. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32489. */
  32490. static LogLevels: number;
  32491. /**
  32492. * Checks if the loaded document was accessed via `file:`-Protocol.
  32493. * @returns boolean
  32494. */
  32495. static IsFileURL(): boolean;
  32496. /**
  32497. * Checks if the window object exists
  32498. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32499. */
  32500. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32501. /**
  32502. * No performance log
  32503. */
  32504. static readonly PerformanceNoneLogLevel: number;
  32505. /**
  32506. * Use user marks to log performance
  32507. */
  32508. static readonly PerformanceUserMarkLogLevel: number;
  32509. /**
  32510. * Log performance to the console
  32511. */
  32512. static readonly PerformanceConsoleLogLevel: number;
  32513. private static _performance;
  32514. /**
  32515. * Sets the current performance log level
  32516. */
  32517. static PerformanceLogLevel: number;
  32518. private static _StartPerformanceCounterDisabled;
  32519. private static _EndPerformanceCounterDisabled;
  32520. private static _StartUserMark;
  32521. private static _EndUserMark;
  32522. private static _StartPerformanceConsole;
  32523. private static _EndPerformanceConsole;
  32524. /**
  32525. * Starts a performance counter
  32526. */
  32527. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32528. /**
  32529. * Ends a specific performance coutner
  32530. */
  32531. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32532. /**
  32533. * Gets either window.performance.now() if supported or Date.now() else
  32534. */
  32535. static readonly Now: number;
  32536. /**
  32537. * This method will return the name of the class used to create the instance of the given object.
  32538. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32539. * @param object the object to get the class name from
  32540. * @param isType defines if the object is actually a type
  32541. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32542. */
  32543. static GetClassName(object: any, isType?: boolean): string;
  32544. /**
  32545. * Gets the first element of an array satisfying a given predicate
  32546. * @param array defines the array to browse
  32547. * @param predicate defines the predicate to use
  32548. * @returns null if not found or the element
  32549. */
  32550. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32551. /**
  32552. * This method will return the name of the full name of the class, including its owning module (if any).
  32553. * 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).
  32554. * @param object the object to get the class name from
  32555. * @param isType defines if the object is actually a type
  32556. * @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.
  32557. * @ignorenaming
  32558. */
  32559. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32560. /**
  32561. * Returns a promise that resolves after the given amount of time.
  32562. * @param delay Number of milliseconds to delay
  32563. * @returns Promise that resolves after the given amount of time
  32564. */
  32565. static DelayAsync(delay: number): Promise<void>;
  32566. /**
  32567. * Gets the current gradient from an array of IValueGradient
  32568. * @param ratio defines the current ratio to get
  32569. * @param gradients defines the array of IValueGradient
  32570. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32571. */
  32572. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32573. }
  32574. /**
  32575. * This class is used to track a performance counter which is number based.
  32576. * The user has access to many properties which give statistics of different nature.
  32577. *
  32578. * The implementer can track two kinds of Performance Counter: time and count.
  32579. * 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.
  32580. * 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.
  32581. */
  32582. export class PerfCounter {
  32583. /**
  32584. * Gets or sets a global boolean to turn on and off all the counters
  32585. */
  32586. static Enabled: boolean;
  32587. /**
  32588. * Returns the smallest value ever
  32589. */
  32590. readonly min: number;
  32591. /**
  32592. * Returns the biggest value ever
  32593. */
  32594. readonly max: number;
  32595. /**
  32596. * Returns the average value since the performance counter is running
  32597. */
  32598. readonly average: number;
  32599. /**
  32600. * Returns the average value of the last second the counter was monitored
  32601. */
  32602. readonly lastSecAverage: number;
  32603. /**
  32604. * Returns the current value
  32605. */
  32606. readonly current: number;
  32607. /**
  32608. * Gets the accumulated total
  32609. */
  32610. readonly total: number;
  32611. /**
  32612. * Gets the total value count
  32613. */
  32614. readonly count: number;
  32615. /**
  32616. * Creates a new counter
  32617. */
  32618. constructor();
  32619. /**
  32620. * Call this method to start monitoring a new frame.
  32621. * 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.
  32622. */
  32623. fetchNewFrame(): void;
  32624. /**
  32625. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32626. * @param newCount the count value to add to the monitored count
  32627. * @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.
  32628. */
  32629. addCount(newCount: number, fetchResult: boolean): void;
  32630. /**
  32631. * Start monitoring this performance counter
  32632. */
  32633. beginMonitoring(): void;
  32634. /**
  32635. * Compute the time lapsed since the previous beginMonitoring() call.
  32636. * @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
  32637. */
  32638. endMonitoring(newFrame?: boolean): void;
  32639. private _fetchResult;
  32640. private _startMonitoringTime;
  32641. private _min;
  32642. private _max;
  32643. private _average;
  32644. private _current;
  32645. private _totalValueCount;
  32646. private _totalAccumulated;
  32647. private _lastSecAverage;
  32648. private _lastSecAccumulated;
  32649. private _lastSecTime;
  32650. private _lastSecValueCount;
  32651. }
  32652. /**
  32653. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32654. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32655. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32656. * @param name The name of the class, case should be preserved
  32657. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32658. */
  32659. export function className(name: string, module?: string): (target: Object) => void;
  32660. /**
  32661. * An implementation of a loop for asynchronous functions.
  32662. */
  32663. export class AsyncLoop {
  32664. /**
  32665. * Defines the number of iterations for the loop
  32666. */
  32667. iterations: number;
  32668. /**
  32669. * Defines the current index of the loop.
  32670. */
  32671. index: number;
  32672. private _done;
  32673. private _fn;
  32674. private _successCallback;
  32675. /**
  32676. * Constructor.
  32677. * @param iterations the number of iterations.
  32678. * @param func the function to run each iteration
  32679. * @param successCallback the callback that will be called upon succesful execution
  32680. * @param offset starting offset.
  32681. */
  32682. constructor(
  32683. /**
  32684. * Defines the number of iterations for the loop
  32685. */
  32686. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32687. /**
  32688. * Execute the next iteration. Must be called after the last iteration was finished.
  32689. */
  32690. executeNext(): void;
  32691. /**
  32692. * Break the loop and run the success callback.
  32693. */
  32694. breakLoop(): void;
  32695. /**
  32696. * Create and run an async loop.
  32697. * @param iterations the number of iterations.
  32698. * @param fn the function to run each iteration
  32699. * @param successCallback the callback that will be called upon succesful execution
  32700. * @param offset starting offset.
  32701. * @returns the created async loop object
  32702. */
  32703. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32704. /**
  32705. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32706. * @param iterations total number of iterations
  32707. * @param syncedIterations number of synchronous iterations in each async iteration.
  32708. * @param fn the function to call each iteration.
  32709. * @param callback a success call back that will be called when iterating stops.
  32710. * @param breakFunction a break condition (optional)
  32711. * @param timeout timeout settings for the setTimeout function. default - 0.
  32712. * @returns the created async loop object
  32713. */
  32714. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32715. }
  32716. }
  32717. declare module "babylonjs/Collisions/collisionCoordinator" {
  32718. import { Nullable } from "babylonjs/types";
  32719. import { Scene } from "babylonjs/scene";
  32720. import { Vector3 } from "babylonjs/Maths/math";
  32721. import { Collider } from "babylonjs/Collisions/collider";
  32722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32723. /** @hidden */
  32724. export interface ICollisionCoordinator {
  32725. createCollider(): Collider;
  32726. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32727. init(scene: Scene): void;
  32728. }
  32729. /** @hidden */
  32730. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32731. private _scene;
  32732. private _scaledPosition;
  32733. private _scaledVelocity;
  32734. private _finalPosition;
  32735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32736. createCollider(): Collider;
  32737. init(scene: Scene): void;
  32738. private _collideWithWorld;
  32739. }
  32740. }
  32741. declare module "babylonjs/Inputs/scene.inputManager" {
  32742. import { Nullable } from "babylonjs/types";
  32743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32744. import { Vector2 } from "babylonjs/Maths/math";
  32745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32746. import { Scene } from "babylonjs/scene";
  32747. /**
  32748. * Class used to manage all inputs for the scene.
  32749. */
  32750. export class InputManager {
  32751. /** The distance in pixel that you have to move to prevent some events */
  32752. static DragMovementThreshold: number;
  32753. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32754. static LongPressDelay: number;
  32755. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32756. static DoubleClickDelay: number;
  32757. /** If you need to check double click without raising a single click at first click, enable this flag */
  32758. static ExclusiveDoubleClickMode: boolean;
  32759. private _wheelEventName;
  32760. private _onPointerMove;
  32761. private _onPointerDown;
  32762. private _onPointerUp;
  32763. private _initClickEvent;
  32764. private _initActionManager;
  32765. private _delayedSimpleClick;
  32766. private _delayedSimpleClickTimeout;
  32767. private _previousDelayedSimpleClickTimeout;
  32768. private _meshPickProceed;
  32769. private _previousButtonPressed;
  32770. private _currentPickResult;
  32771. private _previousPickResult;
  32772. private _totalPointersPressed;
  32773. private _doubleClickOccured;
  32774. private _pointerOverMesh;
  32775. private _pickedDownMesh;
  32776. private _pickedUpMesh;
  32777. private _pointerX;
  32778. private _pointerY;
  32779. private _unTranslatedPointerX;
  32780. private _unTranslatedPointerY;
  32781. private _startingPointerPosition;
  32782. private _previousStartingPointerPosition;
  32783. private _startingPointerTime;
  32784. private _previousStartingPointerTime;
  32785. private _pointerCaptures;
  32786. private _onKeyDown;
  32787. private _onKeyUp;
  32788. private _onCanvasFocusObserver;
  32789. private _onCanvasBlurObserver;
  32790. private _scene;
  32791. /**
  32792. * Creates a new InputManager
  32793. * @param scene defines the hosting scene
  32794. */
  32795. constructor(scene: Scene);
  32796. /**
  32797. * Gets the mesh that is currently under the pointer
  32798. */
  32799. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32800. /**
  32801. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32802. */
  32803. readonly unTranslatedPointer: Vector2;
  32804. /**
  32805. * Gets or sets the current on-screen X position of the pointer
  32806. */
  32807. pointerX: number;
  32808. /**
  32809. * Gets or sets the current on-screen Y position of the pointer
  32810. */
  32811. pointerY: number;
  32812. private _updatePointerPosition;
  32813. private _processPointerMove;
  32814. private _setRayOnPointerInfo;
  32815. private _checkPrePointerObservable;
  32816. /**
  32817. * Use this method to simulate a pointer move on a mesh
  32818. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32819. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32820. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32821. */
  32822. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32823. /**
  32824. * Use this method to simulate a pointer down on a mesh
  32825. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32826. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32827. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32828. */
  32829. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32830. private _processPointerDown;
  32831. /** @hidden */
  32832. _isPointerSwiping(): boolean;
  32833. /**
  32834. * Use this method to simulate a pointer up on a mesh
  32835. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32836. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32837. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32838. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32839. */
  32840. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32841. private _processPointerUp;
  32842. /**
  32843. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32844. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32845. * @returns true if the pointer was captured
  32846. */
  32847. isPointerCaptured(pointerId?: number): boolean;
  32848. /**
  32849. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32850. * @param attachUp defines if you want to attach events to pointerup
  32851. * @param attachDown defines if you want to attach events to pointerdown
  32852. * @param attachMove defines if you want to attach events to pointermove
  32853. */
  32854. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32855. /**
  32856. * Detaches all event handlers
  32857. */
  32858. detachControl(): void;
  32859. /**
  32860. * Force the value of meshUnderPointer
  32861. * @param mesh defines the mesh to use
  32862. */
  32863. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32864. /**
  32865. * Gets the mesh under the pointer
  32866. * @returns a Mesh or null if no mesh is under the pointer
  32867. */
  32868. getPointerOverMesh(): Nullable<AbstractMesh>;
  32869. }
  32870. }
  32871. declare module "babylonjs/Animations/animationGroup" {
  32872. import { Animatable } from "babylonjs/Animations/animatable";
  32873. import { Animation } from "babylonjs/Animations/animation";
  32874. import { Scene, IDisposable } from "babylonjs/scene";
  32875. import { Observable } from "babylonjs/Misc/observable";
  32876. import { Nullable } from "babylonjs/types";
  32877. import "babylonjs/Animations/animatable";
  32878. /**
  32879. * This class defines the direct association between an animation and a target
  32880. */
  32881. export class TargetedAnimation {
  32882. /**
  32883. * Animation to perform
  32884. */
  32885. animation: Animation;
  32886. /**
  32887. * Target to animate
  32888. */
  32889. target: any;
  32890. /**
  32891. * Serialize the object
  32892. * @returns the JSON object representing the current entity
  32893. */
  32894. serialize(): any;
  32895. }
  32896. /**
  32897. * Use this class to create coordinated animations on multiple targets
  32898. */
  32899. export class AnimationGroup implements IDisposable {
  32900. /** The name of the animation group */
  32901. name: string;
  32902. private _scene;
  32903. private _targetedAnimations;
  32904. private _animatables;
  32905. private _from;
  32906. private _to;
  32907. private _isStarted;
  32908. private _isPaused;
  32909. private _speedRatio;
  32910. private _loopAnimation;
  32911. /**
  32912. * Gets or sets the unique id of the node
  32913. */
  32914. uniqueId: number;
  32915. /**
  32916. * This observable will notify when one animation have ended
  32917. */
  32918. onAnimationEndObservable: Observable<TargetedAnimation>;
  32919. /**
  32920. * Observer raised when one animation loops
  32921. */
  32922. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32923. /**
  32924. * This observable will notify when all animations have ended.
  32925. */
  32926. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32927. /**
  32928. * This observable will notify when all animations have paused.
  32929. */
  32930. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32931. /**
  32932. * This observable will notify when all animations are playing.
  32933. */
  32934. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32935. /**
  32936. * Gets the first frame
  32937. */
  32938. readonly from: number;
  32939. /**
  32940. * Gets the last frame
  32941. */
  32942. readonly to: number;
  32943. /**
  32944. * Define if the animations are started
  32945. */
  32946. readonly isStarted: boolean;
  32947. /**
  32948. * Gets a value indicating that the current group is playing
  32949. */
  32950. readonly isPlaying: boolean;
  32951. /**
  32952. * Gets or sets the speed ratio to use for all animations
  32953. */
  32954. /**
  32955. * Gets or sets the speed ratio to use for all animations
  32956. */
  32957. speedRatio: number;
  32958. /**
  32959. * Gets or sets if all animations should loop or not
  32960. */
  32961. loopAnimation: boolean;
  32962. /**
  32963. * Gets the targeted animations for this animation group
  32964. */
  32965. readonly targetedAnimations: Array<TargetedAnimation>;
  32966. /**
  32967. * returning the list of animatables controlled by this animation group.
  32968. */
  32969. readonly animatables: Array<Animatable>;
  32970. /**
  32971. * Instantiates a new Animation Group.
  32972. * This helps managing several animations at once.
  32973. * @see http://doc.babylonjs.com/how_to/group
  32974. * @param name Defines the name of the group
  32975. * @param scene Defines the scene the group belongs to
  32976. */
  32977. constructor(
  32978. /** The name of the animation group */
  32979. name: string, scene?: Nullable<Scene>);
  32980. /**
  32981. * Add an animation (with its target) in the group
  32982. * @param animation defines the animation we want to add
  32983. * @param target defines the target of the animation
  32984. * @returns the TargetedAnimation object
  32985. */
  32986. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32987. /**
  32988. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32989. * It can add constant keys at begin or end
  32990. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32991. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32992. * @returns the animation group
  32993. */
  32994. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32995. /**
  32996. * Start all animations on given targets
  32997. * @param loop defines if animations must loop
  32998. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32999. * @param from defines the from key (optional)
  33000. * @param to defines the to key (optional)
  33001. * @returns the current animation group
  33002. */
  33003. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33004. /**
  33005. * Pause all animations
  33006. * @returns the animation group
  33007. */
  33008. pause(): AnimationGroup;
  33009. /**
  33010. * Play all animations to initial state
  33011. * This function will start() the animations if they were not started or will restart() them if they were paused
  33012. * @param loop defines if animations must loop
  33013. * @returns the animation group
  33014. */
  33015. play(loop?: boolean): AnimationGroup;
  33016. /**
  33017. * Reset all animations to initial state
  33018. * @returns the animation group
  33019. */
  33020. reset(): AnimationGroup;
  33021. /**
  33022. * Restart animations from key 0
  33023. * @returns the animation group
  33024. */
  33025. restart(): AnimationGroup;
  33026. /**
  33027. * Stop all animations
  33028. * @returns the animation group
  33029. */
  33030. stop(): AnimationGroup;
  33031. /**
  33032. * Set animation weight for all animatables
  33033. * @param weight defines the weight to use
  33034. * @return the animationGroup
  33035. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33036. */
  33037. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33038. /**
  33039. * Synchronize and normalize all animatables with a source animatable
  33040. * @param root defines the root animatable to synchronize with
  33041. * @return the animationGroup
  33042. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33043. */
  33044. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33045. /**
  33046. * Goes to a specific frame in this animation group
  33047. * @param frame the frame number to go to
  33048. * @return the animationGroup
  33049. */
  33050. goToFrame(frame: number): AnimationGroup;
  33051. /**
  33052. * Dispose all associated resources
  33053. */
  33054. dispose(): void;
  33055. private _checkAnimationGroupEnded;
  33056. /**
  33057. * Clone the current animation group and returns a copy
  33058. * @param newName defines the name of the new group
  33059. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33060. * @returns the new aniamtion group
  33061. */
  33062. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33063. /**
  33064. * Serializes the animationGroup to an object
  33065. * @returns Serialized object
  33066. */
  33067. serialize(): any;
  33068. /**
  33069. * Returns a new AnimationGroup object parsed from the source provided.
  33070. * @param parsedAnimationGroup defines the source
  33071. * @param scene defines the scene that will receive the animationGroup
  33072. * @returns a new AnimationGroup
  33073. */
  33074. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33075. /**
  33076. * Returns the string "AnimationGroup"
  33077. * @returns "AnimationGroup"
  33078. */
  33079. getClassName(): string;
  33080. /**
  33081. * Creates a detailled string about the object
  33082. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33083. * @returns a string representing the object
  33084. */
  33085. toString(fullDetails?: boolean): string;
  33086. }
  33087. }
  33088. declare module "babylonjs/scene" {
  33089. import { Nullable } from "babylonjs/types";
  33090. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33091. import { Observable } from "babylonjs/Misc/observable";
  33092. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33093. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33094. import { Geometry } from "babylonjs/Meshes/geometry";
  33095. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33098. import { Mesh } from "babylonjs/Meshes/mesh";
  33099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33100. import { Bone } from "babylonjs/Bones/bone";
  33101. import { Skeleton } from "babylonjs/Bones/skeleton";
  33102. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33103. import { Camera } from "babylonjs/Cameras/camera";
  33104. import { AbstractScene } from "babylonjs/abstractScene";
  33105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33106. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33107. import { Material } from "babylonjs/Materials/material";
  33108. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33109. import { Effect } from "babylonjs/Materials/effect";
  33110. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33111. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33112. import { Light } from "babylonjs/Lights/light";
  33113. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33114. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33115. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33116. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33117. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33118. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33119. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33120. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33121. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33122. import { Engine } from "babylonjs/Engines/engine";
  33123. import { Node } from "babylonjs/node";
  33124. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33125. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33126. import { WebRequest } from "babylonjs/Misc/webRequest";
  33127. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33128. import { Ray } from "babylonjs/Culling/ray";
  33129. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33130. import { Animation } from "babylonjs/Animations/animation";
  33131. import { Animatable } from "babylonjs/Animations/animatable";
  33132. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33133. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33134. import { Collider } from "babylonjs/Collisions/collider";
  33135. /**
  33136. * Define an interface for all classes that will hold resources
  33137. */
  33138. export interface IDisposable {
  33139. /**
  33140. * Releases all held resources
  33141. */
  33142. dispose(): void;
  33143. }
  33144. /** Interface defining initialization parameters for Scene class */
  33145. export interface SceneOptions {
  33146. /**
  33147. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33148. * It will improve performance when the number of geometries becomes important.
  33149. */
  33150. useGeometryUniqueIdsMap?: boolean;
  33151. /**
  33152. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33153. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33154. */
  33155. useMaterialMeshMap?: boolean;
  33156. /**
  33157. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33158. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33159. */
  33160. useClonedMeshhMap?: boolean;
  33161. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33162. virtual?: boolean;
  33163. }
  33164. /**
  33165. * Represents a scene to be rendered by the engine.
  33166. * @see http://doc.babylonjs.com/features/scene
  33167. */
  33168. export class Scene extends AbstractScene implements IAnimatable {
  33169. private static _uniqueIdCounter;
  33170. /** The fog is deactivated */
  33171. static readonly FOGMODE_NONE: number;
  33172. /** The fog density is following an exponential function */
  33173. static readonly FOGMODE_EXP: number;
  33174. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33175. static readonly FOGMODE_EXP2: number;
  33176. /** The fog density is following a linear function. */
  33177. static readonly FOGMODE_LINEAR: number;
  33178. /**
  33179. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33181. */
  33182. static MinDeltaTime: number;
  33183. /**
  33184. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33186. */
  33187. static MaxDeltaTime: number;
  33188. /**
  33189. * Factory used to create the default material.
  33190. * @param name The name of the material to create
  33191. * @param scene The scene to create the material for
  33192. * @returns The default material
  33193. */
  33194. static DefaultMaterialFactory(scene: Scene): Material;
  33195. /**
  33196. * Factory used to create the a collision coordinator.
  33197. * @returns The collision coordinator
  33198. */
  33199. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33200. /** @hidden */
  33201. _inputManager: InputManager;
  33202. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33203. cameraToUseForPointers: Nullable<Camera>;
  33204. /** @hidden */
  33205. readonly _isScene: boolean;
  33206. /**
  33207. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33208. */
  33209. autoClear: boolean;
  33210. /**
  33211. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33212. */
  33213. autoClearDepthAndStencil: boolean;
  33214. /**
  33215. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33216. */
  33217. clearColor: Color4;
  33218. /**
  33219. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33220. */
  33221. ambientColor: Color3;
  33222. /**
  33223. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33224. * It should only be one of the following (if not the default embedded one):
  33225. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33226. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33227. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33228. * The material properties need to be setup according to the type of texture in use.
  33229. */
  33230. environmentBRDFTexture: BaseTexture;
  33231. /** @hidden */
  33232. protected _environmentTexture: Nullable<BaseTexture>;
  33233. /**
  33234. * Texture used in all pbr material as the reflection texture.
  33235. * As in the majority of the scene they are the same (exception for multi room and so on),
  33236. * this is easier to reference from here than from all the materials.
  33237. */
  33238. /**
  33239. * Texture used in all pbr material as the reflection texture.
  33240. * As in the majority of the scene they are the same (exception for multi room and so on),
  33241. * this is easier to set here than in all the materials.
  33242. */
  33243. environmentTexture: Nullable<BaseTexture>;
  33244. /** @hidden */
  33245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33246. /**
  33247. * Default image processing configuration used either in the rendering
  33248. * Forward main pass or through the imageProcessingPostProcess if present.
  33249. * As in the majority of the scene they are the same (exception for multi camera),
  33250. * this is easier to reference from here than from all the materials and post process.
  33251. *
  33252. * No setter as we it is a shared configuration, you can set the values instead.
  33253. */
  33254. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33255. private _forceWireframe;
  33256. /**
  33257. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33258. */
  33259. forceWireframe: boolean;
  33260. private _forcePointsCloud;
  33261. /**
  33262. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33263. */
  33264. forcePointsCloud: boolean;
  33265. /**
  33266. * Gets or sets the active clipplane 1
  33267. */
  33268. clipPlane: Nullable<Plane>;
  33269. /**
  33270. * Gets or sets the active clipplane 2
  33271. */
  33272. clipPlane2: Nullable<Plane>;
  33273. /**
  33274. * Gets or sets the active clipplane 3
  33275. */
  33276. clipPlane3: Nullable<Plane>;
  33277. /**
  33278. * Gets or sets the active clipplane 4
  33279. */
  33280. clipPlane4: Nullable<Plane>;
  33281. /**
  33282. * Gets or sets a boolean indicating if animations are enabled
  33283. */
  33284. animationsEnabled: boolean;
  33285. private _animationPropertiesOverride;
  33286. /**
  33287. * Gets or sets the animation properties override
  33288. */
  33289. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33290. /**
  33291. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33292. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33293. */
  33294. useConstantAnimationDeltaTime: boolean;
  33295. /**
  33296. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33297. * Please note that it requires to run a ray cast through the scene on every frame
  33298. */
  33299. constantlyUpdateMeshUnderPointer: boolean;
  33300. /**
  33301. * Defines the HTML cursor to use when hovering over interactive elements
  33302. */
  33303. hoverCursor: string;
  33304. /**
  33305. * Defines the HTML default cursor to use (empty by default)
  33306. */
  33307. defaultCursor: string;
  33308. /**
  33309. * This is used to call preventDefault() on pointer down
  33310. * in order to block unwanted artifacts like system double clicks
  33311. */
  33312. preventDefaultOnPointerDown: boolean;
  33313. /**
  33314. * This is used to call preventDefault() on pointer up
  33315. * in order to block unwanted artifacts like system double clicks
  33316. */
  33317. preventDefaultOnPointerUp: boolean;
  33318. /**
  33319. * Gets or sets user defined metadata
  33320. */
  33321. metadata: any;
  33322. /**
  33323. * For internal use only. Please do not use.
  33324. */
  33325. reservedDataStore: any;
  33326. /**
  33327. * Gets the name of the plugin used to load this scene (null by default)
  33328. */
  33329. loadingPluginName: string;
  33330. /**
  33331. * Use this array to add regular expressions used to disable offline support for specific urls
  33332. */
  33333. disableOfflineSupportExceptionRules: RegExp[];
  33334. /**
  33335. * An event triggered when the scene is disposed.
  33336. */
  33337. onDisposeObservable: Observable<Scene>;
  33338. private _onDisposeObserver;
  33339. /** Sets a function to be executed when this scene is disposed. */
  33340. onDispose: () => void;
  33341. /**
  33342. * An event triggered before rendering the scene (right after animations and physics)
  33343. */
  33344. onBeforeRenderObservable: Observable<Scene>;
  33345. private _onBeforeRenderObserver;
  33346. /** Sets a function to be executed before rendering this scene */
  33347. beforeRender: Nullable<() => void>;
  33348. /**
  33349. * An event triggered after rendering the scene
  33350. */
  33351. onAfterRenderObservable: Observable<Scene>;
  33352. /**
  33353. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33354. */
  33355. onAfterRenderCameraObservable: Observable<Camera>;
  33356. private _onAfterRenderObserver;
  33357. /** Sets a function to be executed after rendering this scene */
  33358. afterRender: Nullable<() => void>;
  33359. /**
  33360. * An event triggered before animating the scene
  33361. */
  33362. onBeforeAnimationsObservable: Observable<Scene>;
  33363. /**
  33364. * An event triggered after animations processing
  33365. */
  33366. onAfterAnimationsObservable: Observable<Scene>;
  33367. /**
  33368. * An event triggered before draw calls are ready to be sent
  33369. */
  33370. onBeforeDrawPhaseObservable: Observable<Scene>;
  33371. /**
  33372. * An event triggered after draw calls have been sent
  33373. */
  33374. onAfterDrawPhaseObservable: Observable<Scene>;
  33375. /**
  33376. * An event triggered when the scene is ready
  33377. */
  33378. onReadyObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered before rendering a camera
  33381. */
  33382. onBeforeCameraRenderObservable: Observable<Camera>;
  33383. private _onBeforeCameraRenderObserver;
  33384. /** Sets a function to be executed before rendering a camera*/
  33385. beforeCameraRender: () => void;
  33386. /**
  33387. * An event triggered after rendering a camera
  33388. */
  33389. onAfterCameraRenderObservable: Observable<Camera>;
  33390. private _onAfterCameraRenderObserver;
  33391. /** Sets a function to be executed after rendering a camera*/
  33392. afterCameraRender: () => void;
  33393. /**
  33394. * An event triggered when active meshes evaluation is about to start
  33395. */
  33396. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33397. /**
  33398. * An event triggered when active meshes evaluation is done
  33399. */
  33400. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33401. /**
  33402. * An event triggered when particles rendering is about to start
  33403. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33404. */
  33405. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33406. /**
  33407. * An event triggered when particles rendering is done
  33408. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33409. */
  33410. onAfterParticlesRenderingObservable: Observable<Scene>;
  33411. /**
  33412. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33413. */
  33414. onDataLoadedObservable: Observable<Scene>;
  33415. /**
  33416. * An event triggered when a camera is created
  33417. */
  33418. onNewCameraAddedObservable: Observable<Camera>;
  33419. /**
  33420. * An event triggered when a camera is removed
  33421. */
  33422. onCameraRemovedObservable: Observable<Camera>;
  33423. /**
  33424. * An event triggered when a light is created
  33425. */
  33426. onNewLightAddedObservable: Observable<Light>;
  33427. /**
  33428. * An event triggered when a light is removed
  33429. */
  33430. onLightRemovedObservable: Observable<Light>;
  33431. /**
  33432. * An event triggered when a geometry is created
  33433. */
  33434. onNewGeometryAddedObservable: Observable<Geometry>;
  33435. /**
  33436. * An event triggered when a geometry is removed
  33437. */
  33438. onGeometryRemovedObservable: Observable<Geometry>;
  33439. /**
  33440. * An event triggered when a transform node is created
  33441. */
  33442. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33443. /**
  33444. * An event triggered when a transform node is removed
  33445. */
  33446. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33447. /**
  33448. * An event triggered when a mesh is created
  33449. */
  33450. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33451. /**
  33452. * An event triggered when a mesh is removed
  33453. */
  33454. onMeshRemovedObservable: Observable<AbstractMesh>;
  33455. /**
  33456. * An event triggered when a skeleton is created
  33457. */
  33458. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33459. /**
  33460. * An event triggered when a skeleton is removed
  33461. */
  33462. onSkeletonRemovedObservable: Observable<Skeleton>;
  33463. /**
  33464. * An event triggered when a material is created
  33465. */
  33466. onNewMaterialAddedObservable: Observable<Material>;
  33467. /**
  33468. * An event triggered when a material is removed
  33469. */
  33470. onMaterialRemovedObservable: Observable<Material>;
  33471. /**
  33472. * An event triggered when a texture is created
  33473. */
  33474. onNewTextureAddedObservable: Observable<BaseTexture>;
  33475. /**
  33476. * An event triggered when a texture is removed
  33477. */
  33478. onTextureRemovedObservable: Observable<BaseTexture>;
  33479. /**
  33480. * An event triggered when render targets are about to be rendered
  33481. * Can happen multiple times per frame.
  33482. */
  33483. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33484. /**
  33485. * An event triggered when render targets were rendered.
  33486. * Can happen multiple times per frame.
  33487. */
  33488. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33489. /**
  33490. * An event triggered before calculating deterministic simulation step
  33491. */
  33492. onBeforeStepObservable: Observable<Scene>;
  33493. /**
  33494. * An event triggered after calculating deterministic simulation step
  33495. */
  33496. onAfterStepObservable: Observable<Scene>;
  33497. /**
  33498. * An event triggered when the activeCamera property is updated
  33499. */
  33500. onActiveCameraChanged: Observable<Scene>;
  33501. /**
  33502. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33503. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33504. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  33505. */
  33506. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33507. /**
  33508. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33509. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33510. * 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)
  33511. */
  33512. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33513. /**
  33514. * This Observable will when a mesh has been imported into the scene.
  33515. */
  33516. onMeshImportedObservable: Observable<AbstractMesh>;
  33517. /**
  33518. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33519. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33520. */
  33521. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33522. /** @hidden */
  33523. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33524. /**
  33525. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33526. */
  33527. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33528. /**
  33529. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33530. */
  33531. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33532. /**
  33533. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33534. */
  33535. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33536. /** Callback called when a pointer move is detected */
  33537. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33538. /** Callback called when a pointer down is detected */
  33539. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33540. /** Callback called when a pointer up is detected */
  33541. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33542. /** Callback called when a pointer pick is detected */
  33543. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33544. /**
  33545. * 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).
  33546. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33547. */
  33548. onPrePointerObservable: Observable<PointerInfoPre>;
  33549. /**
  33550. * Observable event triggered each time an input event is received from the rendering canvas
  33551. */
  33552. onPointerObservable: Observable<PointerInfo>;
  33553. /**
  33554. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33555. */
  33556. readonly unTranslatedPointer: Vector2;
  33557. /**
  33558. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33559. */
  33560. static DragMovementThreshold: number;
  33561. /**
  33562. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33563. */
  33564. static LongPressDelay: number;
  33565. /**
  33566. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33567. */
  33568. static DoubleClickDelay: number;
  33569. /** If you need to check double click without raising a single click at first click, enable this flag */
  33570. static ExclusiveDoubleClickMode: boolean;
  33571. /** @hidden */
  33572. _mirroredCameraPosition: Nullable<Vector3>;
  33573. /**
  33574. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33575. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33576. */
  33577. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33578. /**
  33579. * Observable event triggered each time an keyboard event is received from the hosting window
  33580. */
  33581. onKeyboardObservable: Observable<KeyboardInfo>;
  33582. private _useRightHandedSystem;
  33583. /**
  33584. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33585. */
  33586. useRightHandedSystem: boolean;
  33587. private _timeAccumulator;
  33588. private _currentStepId;
  33589. private _currentInternalStep;
  33590. /**
  33591. * Sets the step Id used by deterministic lock step
  33592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33593. * @param newStepId defines the step Id
  33594. */
  33595. setStepId(newStepId: number): void;
  33596. /**
  33597. * Gets the step Id used by deterministic lock step
  33598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33599. * @returns the step Id
  33600. */
  33601. getStepId(): number;
  33602. /**
  33603. * Gets the internal step used by deterministic lock step
  33604. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33605. * @returns the internal step
  33606. */
  33607. getInternalStep(): number;
  33608. private _fogEnabled;
  33609. /**
  33610. * Gets or sets a boolean indicating if fog is enabled on this scene
  33611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33612. * (Default is true)
  33613. */
  33614. fogEnabled: boolean;
  33615. private _fogMode;
  33616. /**
  33617. * Gets or sets the fog mode to use
  33618. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33619. * | mode | value |
  33620. * | --- | --- |
  33621. * | FOGMODE_NONE | 0 |
  33622. * | FOGMODE_EXP | 1 |
  33623. * | FOGMODE_EXP2 | 2 |
  33624. * | FOGMODE_LINEAR | 3 |
  33625. */
  33626. fogMode: number;
  33627. /**
  33628. * Gets or sets the fog color to use
  33629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33630. * (Default is Color3(0.2, 0.2, 0.3))
  33631. */
  33632. fogColor: Color3;
  33633. /**
  33634. * Gets or sets the fog density to use
  33635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33636. * (Default is 0.1)
  33637. */
  33638. fogDensity: number;
  33639. /**
  33640. * Gets or sets the fog start distance to use
  33641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33642. * (Default is 0)
  33643. */
  33644. fogStart: number;
  33645. /**
  33646. * Gets or sets the fog end distance to use
  33647. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33648. * (Default is 1000)
  33649. */
  33650. fogEnd: number;
  33651. private _shadowsEnabled;
  33652. /**
  33653. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33654. */
  33655. shadowsEnabled: boolean;
  33656. private _lightsEnabled;
  33657. /**
  33658. * Gets or sets a boolean indicating if lights are enabled on this scene
  33659. */
  33660. lightsEnabled: boolean;
  33661. /** All of the active cameras added to this scene. */
  33662. activeCameras: Camera[];
  33663. /** @hidden */
  33664. _activeCamera: Nullable<Camera>;
  33665. /** Gets or sets the current active camera */
  33666. activeCamera: Nullable<Camera>;
  33667. private _defaultMaterial;
  33668. /** The default material used on meshes when no material is affected */
  33669. /** The default material used on meshes when no material is affected */
  33670. defaultMaterial: Material;
  33671. private _texturesEnabled;
  33672. /**
  33673. * Gets or sets a boolean indicating if textures are enabled on this scene
  33674. */
  33675. texturesEnabled: boolean;
  33676. /**
  33677. * Gets or sets a boolean indicating if particles are enabled on this scene
  33678. */
  33679. particlesEnabled: boolean;
  33680. /**
  33681. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33682. */
  33683. spritesEnabled: boolean;
  33684. private _skeletonsEnabled;
  33685. /**
  33686. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33687. */
  33688. skeletonsEnabled: boolean;
  33689. /**
  33690. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33691. */
  33692. lensFlaresEnabled: boolean;
  33693. /**
  33694. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33696. */
  33697. collisionsEnabled: boolean;
  33698. private _collisionCoordinator;
  33699. /** @hidden */
  33700. readonly collisionCoordinator: ICollisionCoordinator;
  33701. /**
  33702. * Defines the gravity applied to this scene (used only for collisions)
  33703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33704. */
  33705. gravity: Vector3;
  33706. /**
  33707. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33708. */
  33709. postProcessesEnabled: boolean;
  33710. /**
  33711. * The list of postprocesses added to the scene
  33712. */
  33713. postProcesses: PostProcess[];
  33714. /**
  33715. * Gets the current postprocess manager
  33716. */
  33717. postProcessManager: PostProcessManager;
  33718. /**
  33719. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33720. */
  33721. renderTargetsEnabled: boolean;
  33722. /**
  33723. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33724. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33725. */
  33726. dumpNextRenderTargets: boolean;
  33727. /**
  33728. * The list of user defined render targets added to the scene
  33729. */
  33730. customRenderTargets: RenderTargetTexture[];
  33731. /**
  33732. * Defines if texture loading must be delayed
  33733. * If true, textures will only be loaded when they need to be rendered
  33734. */
  33735. useDelayedTextureLoading: boolean;
  33736. /**
  33737. * Gets the list of meshes imported to the scene through SceneLoader
  33738. */
  33739. importedMeshesFiles: String[];
  33740. /**
  33741. * Gets or sets a boolean indicating if probes are enabled on this scene
  33742. */
  33743. probesEnabled: boolean;
  33744. /**
  33745. * Gets or sets the current offline provider to use to store scene data
  33746. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33747. */
  33748. offlineProvider: IOfflineProvider;
  33749. /**
  33750. * Gets or sets the action manager associated with the scene
  33751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33752. */
  33753. actionManager: AbstractActionManager;
  33754. private _meshesForIntersections;
  33755. /**
  33756. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33757. */
  33758. proceduralTexturesEnabled: boolean;
  33759. private _engine;
  33760. private _totalVertices;
  33761. /** @hidden */
  33762. _activeIndices: PerfCounter;
  33763. /** @hidden */
  33764. _activeParticles: PerfCounter;
  33765. /** @hidden */
  33766. _activeBones: PerfCounter;
  33767. private _animationRatio;
  33768. /** @hidden */
  33769. _animationTimeLast: number;
  33770. /** @hidden */
  33771. _animationTime: number;
  33772. /**
  33773. * Gets or sets a general scale for animation speed
  33774. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33775. */
  33776. animationTimeScale: number;
  33777. /** @hidden */
  33778. _cachedMaterial: Nullable<Material>;
  33779. /** @hidden */
  33780. _cachedEffect: Nullable<Effect>;
  33781. /** @hidden */
  33782. _cachedVisibility: Nullable<number>;
  33783. private _renderId;
  33784. private _frameId;
  33785. private _executeWhenReadyTimeoutId;
  33786. private _intermediateRendering;
  33787. private _viewUpdateFlag;
  33788. private _projectionUpdateFlag;
  33789. /** @hidden */
  33790. _toBeDisposed: Nullable<IDisposable>[];
  33791. private _activeRequests;
  33792. /** @hidden */
  33793. _pendingData: any[];
  33794. private _isDisposed;
  33795. /**
  33796. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33797. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33798. */
  33799. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33800. private _activeMeshes;
  33801. private _processedMaterials;
  33802. private _renderTargets;
  33803. /** @hidden */
  33804. _activeParticleSystems: SmartArray<IParticleSystem>;
  33805. private _activeSkeletons;
  33806. private _softwareSkinnedMeshes;
  33807. private _renderingManager;
  33808. /** @hidden */
  33809. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33810. private _transformMatrix;
  33811. private _sceneUbo;
  33812. /** @hidden */
  33813. _viewMatrix: Matrix;
  33814. private _projectionMatrix;
  33815. /** @hidden */
  33816. _forcedViewPosition: Nullable<Vector3>;
  33817. /** @hidden */
  33818. _frustumPlanes: Plane[];
  33819. /**
  33820. * Gets the list of frustum planes (built from the active camera)
  33821. */
  33822. readonly frustumPlanes: Plane[];
  33823. /**
  33824. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33825. * This is useful if there are more lights that the maximum simulteanous authorized
  33826. */
  33827. requireLightSorting: boolean;
  33828. /** @hidden */
  33829. readonly useMaterialMeshMap: boolean;
  33830. /** @hidden */
  33831. readonly useClonedMeshhMap: boolean;
  33832. private _externalData;
  33833. private _uid;
  33834. /**
  33835. * @hidden
  33836. * Backing store of defined scene components.
  33837. */
  33838. _components: ISceneComponent[];
  33839. /**
  33840. * @hidden
  33841. * Backing store of defined scene components.
  33842. */
  33843. _serializableComponents: ISceneSerializableComponent[];
  33844. /**
  33845. * List of components to register on the next registration step.
  33846. */
  33847. private _transientComponents;
  33848. /**
  33849. * Registers the transient components if needed.
  33850. */
  33851. private _registerTransientComponents;
  33852. /**
  33853. * @hidden
  33854. * Add a component to the scene.
  33855. * Note that the ccomponent could be registered on th next frame if this is called after
  33856. * the register component stage.
  33857. * @param component Defines the component to add to the scene
  33858. */
  33859. _addComponent(component: ISceneComponent): void;
  33860. /**
  33861. * @hidden
  33862. * Gets a component from the scene.
  33863. * @param name defines the name of the component to retrieve
  33864. * @returns the component or null if not present
  33865. */
  33866. _getComponent(name: string): Nullable<ISceneComponent>;
  33867. /**
  33868. * @hidden
  33869. * Defines the actions happening before camera updates.
  33870. */
  33871. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33872. /**
  33873. * @hidden
  33874. * Defines the actions happening before clear the canvas.
  33875. */
  33876. _beforeClearStage: Stage<SimpleStageAction>;
  33877. /**
  33878. * @hidden
  33879. * Defines the actions when collecting render targets for the frame.
  33880. */
  33881. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33882. /**
  33883. * @hidden
  33884. * Defines the actions happening for one camera in the frame.
  33885. */
  33886. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33887. /**
  33888. * @hidden
  33889. * Defines the actions happening during the per mesh ready checks.
  33890. */
  33891. _isReadyForMeshStage: Stage<MeshStageAction>;
  33892. /**
  33893. * @hidden
  33894. * Defines the actions happening before evaluate active mesh checks.
  33895. */
  33896. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33897. /**
  33898. * @hidden
  33899. * Defines the actions happening during the evaluate sub mesh checks.
  33900. */
  33901. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33902. /**
  33903. * @hidden
  33904. * Defines the actions happening during the active mesh stage.
  33905. */
  33906. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33907. /**
  33908. * @hidden
  33909. * Defines the actions happening during the per camera render target step.
  33910. */
  33911. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33912. /**
  33913. * @hidden
  33914. * Defines the actions happening just before the active camera is drawing.
  33915. */
  33916. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33917. /**
  33918. * @hidden
  33919. * Defines the actions happening just before a render target is drawing.
  33920. */
  33921. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33922. /**
  33923. * @hidden
  33924. * Defines the actions happening just before a rendering group is drawing.
  33925. */
  33926. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33927. /**
  33928. * @hidden
  33929. * Defines the actions happening just before a mesh is drawing.
  33930. */
  33931. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33932. /**
  33933. * @hidden
  33934. * Defines the actions happening just after a mesh has been drawn.
  33935. */
  33936. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33937. /**
  33938. * @hidden
  33939. * Defines the actions happening just after a rendering group has been drawn.
  33940. */
  33941. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33942. /**
  33943. * @hidden
  33944. * Defines the actions happening just after the active camera has been drawn.
  33945. */
  33946. _afterCameraDrawStage: Stage<CameraStageAction>;
  33947. /**
  33948. * @hidden
  33949. * Defines the actions happening just after a render target has been drawn.
  33950. */
  33951. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33952. /**
  33953. * @hidden
  33954. * Defines the actions happening just after rendering all cameras and computing intersections.
  33955. */
  33956. _afterRenderStage: Stage<SimpleStageAction>;
  33957. /**
  33958. * @hidden
  33959. * Defines the actions happening when a pointer move event happens.
  33960. */
  33961. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33962. /**
  33963. * @hidden
  33964. * Defines the actions happening when a pointer down event happens.
  33965. */
  33966. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33967. /**
  33968. * @hidden
  33969. * Defines the actions happening when a pointer up event happens.
  33970. */
  33971. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33972. /**
  33973. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33974. */
  33975. private geometriesByUniqueId;
  33976. /**
  33977. * Creates a new Scene
  33978. * @param engine defines the engine to use to render this scene
  33979. * @param options defines the scene options
  33980. */
  33981. constructor(engine: Engine, options?: SceneOptions);
  33982. /**
  33983. * Gets a string idenfifying the name of the class
  33984. * @returns "Scene" string
  33985. */
  33986. getClassName(): string;
  33987. private _defaultMeshCandidates;
  33988. /**
  33989. * @hidden
  33990. */
  33991. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33992. private _defaultSubMeshCandidates;
  33993. /**
  33994. * @hidden
  33995. */
  33996. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33997. /**
  33998. * Sets the default candidate providers for the scene.
  33999. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34000. * and getCollidingSubMeshCandidates to their default function
  34001. */
  34002. setDefaultCandidateProviders(): void;
  34003. /**
  34004. * Gets the mesh that is currently under the pointer
  34005. */
  34006. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34007. /**
  34008. * Gets or sets the current on-screen X position of the pointer
  34009. */
  34010. pointerX: number;
  34011. /**
  34012. * Gets or sets the current on-screen Y position of the pointer
  34013. */
  34014. pointerY: number;
  34015. /**
  34016. * Gets the cached material (ie. the latest rendered one)
  34017. * @returns the cached material
  34018. */
  34019. getCachedMaterial(): Nullable<Material>;
  34020. /**
  34021. * Gets the cached effect (ie. the latest rendered one)
  34022. * @returns the cached effect
  34023. */
  34024. getCachedEffect(): Nullable<Effect>;
  34025. /**
  34026. * Gets the cached visibility state (ie. the latest rendered one)
  34027. * @returns the cached visibility state
  34028. */
  34029. getCachedVisibility(): Nullable<number>;
  34030. /**
  34031. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34032. * @param material defines the current material
  34033. * @param effect defines the current effect
  34034. * @param visibility defines the current visibility state
  34035. * @returns true if one parameter is not cached
  34036. */
  34037. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34038. /**
  34039. * Gets the engine associated with the scene
  34040. * @returns an Engine
  34041. */
  34042. getEngine(): Engine;
  34043. /**
  34044. * Gets the total number of vertices rendered per frame
  34045. * @returns the total number of vertices rendered per frame
  34046. */
  34047. getTotalVertices(): number;
  34048. /**
  34049. * Gets the performance counter for total vertices
  34050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34051. */
  34052. readonly totalVerticesPerfCounter: PerfCounter;
  34053. /**
  34054. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34055. * @returns the total number of active indices rendered per frame
  34056. */
  34057. getActiveIndices(): number;
  34058. /**
  34059. * Gets the performance counter for active indices
  34060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34061. */
  34062. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34063. /**
  34064. * Gets the total number of active particles rendered per frame
  34065. * @returns the total number of active particles rendered per frame
  34066. */
  34067. getActiveParticles(): number;
  34068. /**
  34069. * Gets the performance counter for active particles
  34070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34071. */
  34072. readonly activeParticlesPerfCounter: PerfCounter;
  34073. /**
  34074. * Gets the total number of active bones rendered per frame
  34075. * @returns the total number of active bones rendered per frame
  34076. */
  34077. getActiveBones(): number;
  34078. /**
  34079. * Gets the performance counter for active bones
  34080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34081. */
  34082. readonly activeBonesPerfCounter: PerfCounter;
  34083. /**
  34084. * Gets the array of active meshes
  34085. * @returns an array of AbstractMesh
  34086. */
  34087. getActiveMeshes(): SmartArray<AbstractMesh>;
  34088. /**
  34089. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34090. * @returns a number
  34091. */
  34092. getAnimationRatio(): number;
  34093. /**
  34094. * Gets an unique Id for the current render phase
  34095. * @returns a number
  34096. */
  34097. getRenderId(): number;
  34098. /**
  34099. * Gets an unique Id for the current frame
  34100. * @returns a number
  34101. */
  34102. getFrameId(): number;
  34103. /** Call this function if you want to manually increment the render Id*/
  34104. incrementRenderId(): void;
  34105. private _createUbo;
  34106. /**
  34107. * Use this method to simulate a pointer move on a mesh
  34108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34111. * @returns the current scene
  34112. */
  34113. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34114. /**
  34115. * Use this method to simulate a pointer down on a mesh
  34116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34119. * @returns the current scene
  34120. */
  34121. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34122. /**
  34123. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34128. * @returns the current scene
  34129. */
  34130. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34131. /**
  34132. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34133. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34134. * @returns true if the pointer was captured
  34135. */
  34136. isPointerCaptured(pointerId?: number): boolean;
  34137. /**
  34138. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34139. * @param attachUp defines if you want to attach events to pointerup
  34140. * @param attachDown defines if you want to attach events to pointerdown
  34141. * @param attachMove defines if you want to attach events to pointermove
  34142. */
  34143. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34144. /** Detaches all event handlers*/
  34145. detachControl(): void;
  34146. /**
  34147. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34148. * Delay loaded resources are not taking in account
  34149. * @return true if all required resources are ready
  34150. */
  34151. isReady(): boolean;
  34152. /** Resets all cached information relative to material (including effect and visibility) */
  34153. resetCachedMaterial(): void;
  34154. /**
  34155. * Registers a function to be called before every frame render
  34156. * @param func defines the function to register
  34157. */
  34158. registerBeforeRender(func: () => void): void;
  34159. /**
  34160. * Unregisters a function called before every frame render
  34161. * @param func defines the function to unregister
  34162. */
  34163. unregisterBeforeRender(func: () => void): void;
  34164. /**
  34165. * Registers a function to be called after every frame render
  34166. * @param func defines the function to register
  34167. */
  34168. registerAfterRender(func: () => void): void;
  34169. /**
  34170. * Unregisters a function called after every frame render
  34171. * @param func defines the function to unregister
  34172. */
  34173. unregisterAfterRender(func: () => void): void;
  34174. private _executeOnceBeforeRender;
  34175. /**
  34176. * The provided function will run before render once and will be disposed afterwards.
  34177. * A timeout delay can be provided so that the function will be executed in N ms.
  34178. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34179. * @param func The function to be executed.
  34180. * @param timeout optional delay in ms
  34181. */
  34182. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34183. /** @hidden */
  34184. _addPendingData(data: any): void;
  34185. /** @hidden */
  34186. _removePendingData(data: any): void;
  34187. /**
  34188. * Returns the number of items waiting to be loaded
  34189. * @returns the number of items waiting to be loaded
  34190. */
  34191. getWaitingItemsCount(): number;
  34192. /**
  34193. * Returns a boolean indicating if the scene is still loading data
  34194. */
  34195. readonly isLoading: boolean;
  34196. /**
  34197. * Registers a function to be executed when the scene is ready
  34198. * @param {Function} func - the function to be executed
  34199. */
  34200. executeWhenReady(func: () => void): void;
  34201. /**
  34202. * Returns a promise that resolves when the scene is ready
  34203. * @returns A promise that resolves when the scene is ready
  34204. */
  34205. whenReadyAsync(): Promise<void>;
  34206. /** @hidden */
  34207. _checkIsReady(): void;
  34208. /**
  34209. * Gets all animatable attached to the scene
  34210. */
  34211. readonly animatables: Animatable[];
  34212. /**
  34213. * Resets the last animation time frame.
  34214. * Useful to override when animations start running when loading a scene for the first time.
  34215. */
  34216. resetLastAnimationTimeFrame(): void;
  34217. /**
  34218. * Gets the current view matrix
  34219. * @returns a Matrix
  34220. */
  34221. getViewMatrix(): Matrix;
  34222. /**
  34223. * Gets the current projection matrix
  34224. * @returns a Matrix
  34225. */
  34226. getProjectionMatrix(): Matrix;
  34227. /**
  34228. * Gets the current transform matrix
  34229. * @returns a Matrix made of View * Projection
  34230. */
  34231. getTransformMatrix(): Matrix;
  34232. /**
  34233. * Sets the current transform matrix
  34234. * @param viewL defines the View matrix to use
  34235. * @param projectionL defines the Projection matrix to use
  34236. * @param viewR defines the right View matrix to use (if provided)
  34237. * @param projectionR defines the right Projection matrix to use (if provided)
  34238. */
  34239. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34240. /**
  34241. * Gets the uniform buffer used to store scene data
  34242. * @returns a UniformBuffer
  34243. */
  34244. getSceneUniformBuffer(): UniformBuffer;
  34245. /**
  34246. * Gets an unique (relatively to the current scene) Id
  34247. * @returns an unique number for the scene
  34248. */
  34249. getUniqueId(): number;
  34250. /**
  34251. * Add a mesh to the list of scene's meshes
  34252. * @param newMesh defines the mesh to add
  34253. * @param recursive if all child meshes should also be added to the scene
  34254. */
  34255. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34256. /**
  34257. * Remove a mesh for the list of scene's meshes
  34258. * @param toRemove defines the mesh to remove
  34259. * @param recursive if all child meshes should also be removed from the scene
  34260. * @returns the index where the mesh was in the mesh list
  34261. */
  34262. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34263. /**
  34264. * Add a transform node to the list of scene's transform nodes
  34265. * @param newTransformNode defines the transform node to add
  34266. */
  34267. addTransformNode(newTransformNode: TransformNode): void;
  34268. /**
  34269. * Remove a transform node for the list of scene's transform nodes
  34270. * @param toRemove defines the transform node to remove
  34271. * @returns the index where the transform node was in the transform node list
  34272. */
  34273. removeTransformNode(toRemove: TransformNode): number;
  34274. /**
  34275. * Remove a skeleton for the list of scene's skeletons
  34276. * @param toRemove defines the skeleton to remove
  34277. * @returns the index where the skeleton was in the skeleton list
  34278. */
  34279. removeSkeleton(toRemove: Skeleton): number;
  34280. /**
  34281. * Remove a morph target for the list of scene's morph targets
  34282. * @param toRemove defines the morph target to remove
  34283. * @returns the index where the morph target was in the morph target list
  34284. */
  34285. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34286. /**
  34287. * Remove a light for the list of scene's lights
  34288. * @param toRemove defines the light to remove
  34289. * @returns the index where the light was in the light list
  34290. */
  34291. removeLight(toRemove: Light): number;
  34292. /**
  34293. * Remove a camera for the list of scene's cameras
  34294. * @param toRemove defines the camera to remove
  34295. * @returns the index where the camera was in the camera list
  34296. */
  34297. removeCamera(toRemove: Camera): number;
  34298. /**
  34299. * Remove a particle system for the list of scene's particle systems
  34300. * @param toRemove defines the particle system to remove
  34301. * @returns the index where the particle system was in the particle system list
  34302. */
  34303. removeParticleSystem(toRemove: IParticleSystem): number;
  34304. /**
  34305. * Remove a animation for the list of scene's animations
  34306. * @param toRemove defines the animation to remove
  34307. * @returns the index where the animation was in the animation list
  34308. */
  34309. removeAnimation(toRemove: Animation): number;
  34310. /**
  34311. * Will stop the animation of the given target
  34312. * @param target - the target
  34313. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34314. * @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)
  34315. */
  34316. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34317. /**
  34318. * Removes the given animation group from this scene.
  34319. * @param toRemove The animation group to remove
  34320. * @returns The index of the removed animation group
  34321. */
  34322. removeAnimationGroup(toRemove: AnimationGroup): number;
  34323. /**
  34324. * Removes the given multi-material from this scene.
  34325. * @param toRemove The multi-material to remove
  34326. * @returns The index of the removed multi-material
  34327. */
  34328. removeMultiMaterial(toRemove: MultiMaterial): number;
  34329. /**
  34330. * Removes the given material from this scene.
  34331. * @param toRemove The material to remove
  34332. * @returns The index of the removed material
  34333. */
  34334. removeMaterial(toRemove: Material): number;
  34335. /**
  34336. * Removes the given action manager from this scene.
  34337. * @param toRemove The action manager to remove
  34338. * @returns The index of the removed action manager
  34339. */
  34340. removeActionManager(toRemove: AbstractActionManager): number;
  34341. /**
  34342. * Removes the given texture from this scene.
  34343. * @param toRemove The texture to remove
  34344. * @returns The index of the removed texture
  34345. */
  34346. removeTexture(toRemove: BaseTexture): number;
  34347. /**
  34348. * Adds the given light to this scene
  34349. * @param newLight The light to add
  34350. */
  34351. addLight(newLight: Light): void;
  34352. /**
  34353. * Sorts the list list based on light priorities
  34354. */
  34355. sortLightsByPriority(): void;
  34356. /**
  34357. * Adds the given camera to this scene
  34358. * @param newCamera The camera to add
  34359. */
  34360. addCamera(newCamera: Camera): void;
  34361. /**
  34362. * Adds the given skeleton to this scene
  34363. * @param newSkeleton The skeleton to add
  34364. */
  34365. addSkeleton(newSkeleton: Skeleton): void;
  34366. /**
  34367. * Adds the given particle system to this scene
  34368. * @param newParticleSystem The particle system to add
  34369. */
  34370. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34371. /**
  34372. * Adds the given animation to this scene
  34373. * @param newAnimation The animation to add
  34374. */
  34375. addAnimation(newAnimation: Animation): void;
  34376. /**
  34377. * Adds the given animation group to this scene.
  34378. * @param newAnimationGroup The animation group to add
  34379. */
  34380. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34381. /**
  34382. * Adds the given multi-material to this scene
  34383. * @param newMultiMaterial The multi-material to add
  34384. */
  34385. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34386. /**
  34387. * Adds the given material to this scene
  34388. * @param newMaterial The material to add
  34389. */
  34390. addMaterial(newMaterial: Material): void;
  34391. /**
  34392. * Adds the given morph target to this scene
  34393. * @param newMorphTargetManager The morph target to add
  34394. */
  34395. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34396. /**
  34397. * Adds the given geometry to this scene
  34398. * @param newGeometry The geometry to add
  34399. */
  34400. addGeometry(newGeometry: Geometry): void;
  34401. /**
  34402. * Adds the given action manager to this scene
  34403. * @param newActionManager The action manager to add
  34404. */
  34405. addActionManager(newActionManager: AbstractActionManager): void;
  34406. /**
  34407. * Adds the given texture to this scene.
  34408. * @param newTexture The texture to add
  34409. */
  34410. addTexture(newTexture: BaseTexture): void;
  34411. /**
  34412. * Switch active camera
  34413. * @param newCamera defines the new active camera
  34414. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34415. */
  34416. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34417. /**
  34418. * sets the active camera of the scene using its ID
  34419. * @param id defines the camera's ID
  34420. * @return the new active camera or null if none found.
  34421. */
  34422. setActiveCameraByID(id: string): Nullable<Camera>;
  34423. /**
  34424. * sets the active camera of the scene using its name
  34425. * @param name defines the camera's name
  34426. * @returns the new active camera or null if none found.
  34427. */
  34428. setActiveCameraByName(name: string): Nullable<Camera>;
  34429. /**
  34430. * get an animation group using its name
  34431. * @param name defines the material's name
  34432. * @return the animation group or null if none found.
  34433. */
  34434. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34435. /**
  34436. * Get a material using its unique id
  34437. * @param uniqueId defines the material's unique id
  34438. * @return the material or null if none found.
  34439. */
  34440. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34441. /**
  34442. * get a material using its id
  34443. * @param id defines the material's ID
  34444. * @return the material or null if none found.
  34445. */
  34446. getMaterialByID(id: string): Nullable<Material>;
  34447. /**
  34448. * Gets a the last added material using a given id
  34449. * @param id defines the material's ID
  34450. * @return the last material with the given id or null if none found.
  34451. */
  34452. getLastMaterialByID(id: string): Nullable<Material>;
  34453. /**
  34454. * Gets a material using its name
  34455. * @param name defines the material's name
  34456. * @return the material or null if none found.
  34457. */
  34458. getMaterialByName(name: string): Nullable<Material>;
  34459. /**
  34460. * Gets a camera using its id
  34461. * @param id defines the id to look for
  34462. * @returns the camera or null if not found
  34463. */
  34464. getCameraByID(id: string): Nullable<Camera>;
  34465. /**
  34466. * Gets a camera using its unique id
  34467. * @param uniqueId defines the unique id to look for
  34468. * @returns the camera or null if not found
  34469. */
  34470. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34471. /**
  34472. * Gets a camera using its name
  34473. * @param name defines the camera's name
  34474. * @return the camera or null if none found.
  34475. */
  34476. getCameraByName(name: string): Nullable<Camera>;
  34477. /**
  34478. * Gets a bone using its id
  34479. * @param id defines the bone's id
  34480. * @return the bone or null if not found
  34481. */
  34482. getBoneByID(id: string): Nullable<Bone>;
  34483. /**
  34484. * Gets a bone using its id
  34485. * @param name defines the bone's name
  34486. * @return the bone or null if not found
  34487. */
  34488. getBoneByName(name: string): Nullable<Bone>;
  34489. /**
  34490. * Gets a light node using its name
  34491. * @param name defines the the light's name
  34492. * @return the light or null if none found.
  34493. */
  34494. getLightByName(name: string): Nullable<Light>;
  34495. /**
  34496. * Gets a light node using its id
  34497. * @param id defines the light's id
  34498. * @return the light or null if none found.
  34499. */
  34500. getLightByID(id: string): Nullable<Light>;
  34501. /**
  34502. * Gets a light node using its scene-generated unique ID
  34503. * @param uniqueId defines the light's unique id
  34504. * @return the light or null if none found.
  34505. */
  34506. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34507. /**
  34508. * Gets a particle system by id
  34509. * @param id defines the particle system id
  34510. * @return the corresponding system or null if none found
  34511. */
  34512. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34513. /**
  34514. * Gets a geometry using its ID
  34515. * @param id defines the geometry's id
  34516. * @return the geometry or null if none found.
  34517. */
  34518. getGeometryByID(id: string): Nullable<Geometry>;
  34519. private _getGeometryByUniqueID;
  34520. /**
  34521. * Add a new geometry to this scene
  34522. * @param geometry defines the geometry to be added to the scene.
  34523. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34524. * @return a boolean defining if the geometry was added or not
  34525. */
  34526. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34527. /**
  34528. * Removes an existing geometry
  34529. * @param geometry defines the geometry to be removed from the scene
  34530. * @return a boolean defining if the geometry was removed or not
  34531. */
  34532. removeGeometry(geometry: Geometry): boolean;
  34533. /**
  34534. * Gets the list of geometries attached to the scene
  34535. * @returns an array of Geometry
  34536. */
  34537. getGeometries(): Geometry[];
  34538. /**
  34539. * Gets the first added mesh found of a given ID
  34540. * @param id defines the id to search for
  34541. * @return the mesh found or null if not found at all
  34542. */
  34543. getMeshByID(id: string): Nullable<AbstractMesh>;
  34544. /**
  34545. * Gets a list of meshes using their id
  34546. * @param id defines the id to search for
  34547. * @returns a list of meshes
  34548. */
  34549. getMeshesByID(id: string): Array<AbstractMesh>;
  34550. /**
  34551. * Gets the first added transform node found of a given ID
  34552. * @param id defines the id to search for
  34553. * @return the found transform node or null if not found at all.
  34554. */
  34555. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34556. /**
  34557. * Gets a transform node with its auto-generated unique id
  34558. * @param uniqueId efines the unique id to search for
  34559. * @return the found transform node or null if not found at all.
  34560. */
  34561. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34562. /**
  34563. * Gets a list of transform nodes using their id
  34564. * @param id defines the id to search for
  34565. * @returns a list of transform nodes
  34566. */
  34567. getTransformNodesByID(id: string): Array<TransformNode>;
  34568. /**
  34569. * Gets a mesh with its auto-generated unique id
  34570. * @param uniqueId defines the unique id to search for
  34571. * @return the found mesh or null if not found at all.
  34572. */
  34573. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34574. /**
  34575. * Gets a the last added mesh using a given id
  34576. * @param id defines the id to search for
  34577. * @return the found mesh or null if not found at all.
  34578. */
  34579. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34580. /**
  34581. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34582. * @param id defines the id to search for
  34583. * @return the found node or null if not found at all
  34584. */
  34585. getLastEntryByID(id: string): Nullable<Node>;
  34586. /**
  34587. * Gets a node (Mesh, Camera, Light) using a given id
  34588. * @param id defines the id to search for
  34589. * @return the found node or null if not found at all
  34590. */
  34591. getNodeByID(id: string): Nullable<Node>;
  34592. /**
  34593. * Gets a node (Mesh, Camera, Light) using a given name
  34594. * @param name defines the name to search for
  34595. * @return the found node or null if not found at all.
  34596. */
  34597. getNodeByName(name: string): Nullable<Node>;
  34598. /**
  34599. * Gets a mesh using a given name
  34600. * @param name defines the name to search for
  34601. * @return the found mesh or null if not found at all.
  34602. */
  34603. getMeshByName(name: string): Nullable<AbstractMesh>;
  34604. /**
  34605. * Gets a transform node using a given name
  34606. * @param name defines the name to search for
  34607. * @return the found transform node or null if not found at all.
  34608. */
  34609. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34610. /**
  34611. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34612. * @param id defines the id to search for
  34613. * @return the found skeleton or null if not found at all.
  34614. */
  34615. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34616. /**
  34617. * Gets a skeleton using a given auto generated unique id
  34618. * @param uniqueId defines the unique id to search for
  34619. * @return the found skeleton or null if not found at all.
  34620. */
  34621. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34622. /**
  34623. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34624. * @param id defines the id to search for
  34625. * @return the found skeleton or null if not found at all.
  34626. */
  34627. getSkeletonById(id: string): Nullable<Skeleton>;
  34628. /**
  34629. * Gets a skeleton using a given name
  34630. * @param name defines the name to search for
  34631. * @return the found skeleton or null if not found at all.
  34632. */
  34633. getSkeletonByName(name: string): Nullable<Skeleton>;
  34634. /**
  34635. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34636. * @param id defines the id to search for
  34637. * @return the found morph target manager or null if not found at all.
  34638. */
  34639. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34640. /**
  34641. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34642. * @param id defines the id to search for
  34643. * @return the found morph target or null if not found at all.
  34644. */
  34645. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34646. /**
  34647. * Gets a boolean indicating if the given mesh is active
  34648. * @param mesh defines the mesh to look for
  34649. * @returns true if the mesh is in the active list
  34650. */
  34651. isActiveMesh(mesh: AbstractMesh): boolean;
  34652. /**
  34653. * Return a unique id as a string which can serve as an identifier for the scene
  34654. */
  34655. readonly uid: string;
  34656. /**
  34657. * Add an externaly attached data from its key.
  34658. * This method call will fail and return false, if such key already exists.
  34659. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34660. * @param key the unique key that identifies the data
  34661. * @param data the data object to associate to the key for this Engine instance
  34662. * @return true if no such key were already present and the data was added successfully, false otherwise
  34663. */
  34664. addExternalData<T>(key: string, data: T): boolean;
  34665. /**
  34666. * Get an externaly attached data from its key
  34667. * @param key the unique key that identifies the data
  34668. * @return the associated data, if present (can be null), or undefined if not present
  34669. */
  34670. getExternalData<T>(key: string): Nullable<T>;
  34671. /**
  34672. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34673. * @param key the unique key that identifies the data
  34674. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34675. * @return the associated data, can be null if the factory returned null.
  34676. */
  34677. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34678. /**
  34679. * Remove an externaly attached data from the Engine instance
  34680. * @param key the unique key that identifies the data
  34681. * @return true if the data was successfully removed, false if it doesn't exist
  34682. */
  34683. removeExternalData(key: string): boolean;
  34684. private _evaluateSubMesh;
  34685. /**
  34686. * Clear the processed materials smart array preventing retention point in material dispose.
  34687. */
  34688. freeProcessedMaterials(): void;
  34689. private _preventFreeActiveMeshesAndRenderingGroups;
  34690. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34691. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34692. * when disposing several meshes in a row or a hierarchy of meshes.
  34693. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34694. */
  34695. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34696. /**
  34697. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34698. */
  34699. freeActiveMeshes(): void;
  34700. /**
  34701. * Clear the info related to rendering groups preventing retention points during dispose.
  34702. */
  34703. freeRenderingGroups(): void;
  34704. /** @hidden */
  34705. _isInIntermediateRendering(): boolean;
  34706. /**
  34707. * Lambda returning the list of potentially active meshes.
  34708. */
  34709. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34710. /**
  34711. * Lambda returning the list of potentially active sub meshes.
  34712. */
  34713. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34714. /**
  34715. * Lambda returning the list of potentially intersecting sub meshes.
  34716. */
  34717. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34718. /**
  34719. * Lambda returning the list of potentially colliding sub meshes.
  34720. */
  34721. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34722. private _activeMeshesFrozen;
  34723. /**
  34724. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34725. * @returns the current scene
  34726. */
  34727. freezeActiveMeshes(): Scene;
  34728. /**
  34729. * Use this function to restart evaluating active meshes on every frame
  34730. * @returns the current scene
  34731. */
  34732. unfreezeActiveMeshes(): Scene;
  34733. private _evaluateActiveMeshes;
  34734. private _activeMesh;
  34735. /**
  34736. * Update the transform matrix to update from the current active camera
  34737. * @param force defines a boolean used to force the update even if cache is up to date
  34738. */
  34739. updateTransformMatrix(force?: boolean): void;
  34740. private _bindFrameBuffer;
  34741. /** @hidden */
  34742. _allowPostProcessClearColor: boolean;
  34743. /** @hidden */
  34744. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34745. private _processSubCameras;
  34746. private _checkIntersections;
  34747. /** @hidden */
  34748. _advancePhysicsEngineStep(step: number): void;
  34749. /**
  34750. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34751. */
  34752. getDeterministicFrameTime: () => number;
  34753. /** @hidden */
  34754. _animate(): void;
  34755. /** Execute all animations (for a frame) */
  34756. animate(): void;
  34757. /**
  34758. * Render the scene
  34759. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34760. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34761. */
  34762. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34763. /**
  34764. * Freeze all materials
  34765. * A frozen material will not be updatable but should be faster to render
  34766. */
  34767. freezeMaterials(): void;
  34768. /**
  34769. * Unfreeze all materials
  34770. * A frozen material will not be updatable but should be faster to render
  34771. */
  34772. unfreezeMaterials(): void;
  34773. /**
  34774. * Releases all held ressources
  34775. */
  34776. dispose(): void;
  34777. /**
  34778. * Gets if the scene is already disposed
  34779. */
  34780. readonly isDisposed: boolean;
  34781. /**
  34782. * Call this function to reduce memory footprint of the scene.
  34783. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34784. */
  34785. clearCachedVertexData(): void;
  34786. /**
  34787. * This function will remove the local cached buffer data from texture.
  34788. * It will save memory but will prevent the texture from being rebuilt
  34789. */
  34790. cleanCachedTextureBuffer(): void;
  34791. /**
  34792. * Get the world extend vectors with an optional filter
  34793. *
  34794. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34795. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34796. */
  34797. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34798. min: Vector3;
  34799. max: Vector3;
  34800. };
  34801. /**
  34802. * Creates a ray that can be used to pick in the scene
  34803. * @param x defines the x coordinate of the origin (on-screen)
  34804. * @param y defines the y coordinate of the origin (on-screen)
  34805. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34806. * @param camera defines the camera to use for the picking
  34807. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34808. * @returns a Ray
  34809. */
  34810. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34811. /**
  34812. * Creates a ray that can be used to pick in the scene
  34813. * @param x defines the x coordinate of the origin (on-screen)
  34814. * @param y defines the y coordinate of the origin (on-screen)
  34815. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34816. * @param result defines the ray where to store the picking ray
  34817. * @param camera defines the camera to use for the picking
  34818. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34819. * @returns the current scene
  34820. */
  34821. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34822. /**
  34823. * Creates a ray that can be used to pick in the scene
  34824. * @param x defines the x coordinate of the origin (on-screen)
  34825. * @param y defines the y coordinate of the origin (on-screen)
  34826. * @param camera defines the camera to use for the picking
  34827. * @returns a Ray
  34828. */
  34829. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34830. /**
  34831. * Creates a ray that can be used to pick in the scene
  34832. * @param x defines the x coordinate of the origin (on-screen)
  34833. * @param y defines the y coordinate of the origin (on-screen)
  34834. * @param result defines the ray where to store the picking ray
  34835. * @param camera defines the camera to use for the picking
  34836. * @returns the current scene
  34837. */
  34838. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34839. /** Launch a ray to try to pick a mesh in the scene
  34840. * @param x position on screen
  34841. * @param y position on screen
  34842. * @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
  34843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34844. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34846. * @returns a PickingInfo
  34847. */
  34848. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34849. /** Use the given ray to pick a mesh in the scene
  34850. * @param ray The ray to use to pick meshes
  34851. * @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
  34852. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34854. * @returns a PickingInfo
  34855. */
  34856. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34857. /**
  34858. * Launch a ray to try to pick a mesh in the scene
  34859. * @param x X position on screen
  34860. * @param y Y position on screen
  34861. * @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
  34862. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34864. * @returns an array of PickingInfo
  34865. */
  34866. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34867. /**
  34868. * Launch a ray to try to pick a mesh in the scene
  34869. * @param ray Ray to use
  34870. * @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
  34871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34872. * @returns an array of PickingInfo
  34873. */
  34874. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34875. /**
  34876. * Force the value of meshUnderPointer
  34877. * @param mesh defines the mesh to use
  34878. */
  34879. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34880. /**
  34881. * Gets the mesh under the pointer
  34882. * @returns a Mesh or null if no mesh is under the pointer
  34883. */
  34884. getPointerOverMesh(): Nullable<AbstractMesh>;
  34885. /** @hidden */
  34886. _rebuildGeometries(): void;
  34887. /** @hidden */
  34888. _rebuildTextures(): void;
  34889. private _getByTags;
  34890. /**
  34891. * Get a list of meshes by tags
  34892. * @param tagsQuery defines the tags query to use
  34893. * @param forEach defines a predicate used to filter results
  34894. * @returns an array of Mesh
  34895. */
  34896. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34897. /**
  34898. * Get a list of cameras by tags
  34899. * @param tagsQuery defines the tags query to use
  34900. * @param forEach defines a predicate used to filter results
  34901. * @returns an array of Camera
  34902. */
  34903. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34904. /**
  34905. * Get a list of lights by tags
  34906. * @param tagsQuery defines the tags query to use
  34907. * @param forEach defines a predicate used to filter results
  34908. * @returns an array of Light
  34909. */
  34910. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34911. /**
  34912. * Get a list of materials by tags
  34913. * @param tagsQuery defines the tags query to use
  34914. * @param forEach defines a predicate used to filter results
  34915. * @returns an array of Material
  34916. */
  34917. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34918. /**
  34919. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34920. * This allowed control for front to back rendering or reversly depending of the special needs.
  34921. *
  34922. * @param renderingGroupId The rendering group id corresponding to its index
  34923. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34924. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34925. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34926. */
  34927. 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;
  34928. /**
  34929. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34930. *
  34931. * @param renderingGroupId The rendering group id corresponding to its index
  34932. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34933. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34934. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34935. */
  34936. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34937. /**
  34938. * Gets the current auto clear configuration for one rendering group of the rendering
  34939. * manager.
  34940. * @param index the rendering group index to get the information for
  34941. * @returns The auto clear setup for the requested rendering group
  34942. */
  34943. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34944. private _blockMaterialDirtyMechanism;
  34945. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34946. blockMaterialDirtyMechanism: boolean;
  34947. /**
  34948. * Will flag all materials as dirty to trigger new shader compilation
  34949. * @param flag defines the flag used to specify which material part must be marked as dirty
  34950. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34951. */
  34952. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34953. /** @hidden */
  34954. _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;
  34955. /** @hidden */
  34956. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34957. }
  34958. }
  34959. declare module "babylonjs/assetContainer" {
  34960. import { AbstractScene } from "babylonjs/abstractScene";
  34961. import { Scene } from "babylonjs/scene";
  34962. import { Mesh } from "babylonjs/Meshes/mesh";
  34963. /**
  34964. * Set of assets to keep when moving a scene into an asset container.
  34965. */
  34966. export class KeepAssets extends AbstractScene {
  34967. }
  34968. /**
  34969. * Container with a set of assets that can be added or removed from a scene.
  34970. */
  34971. export class AssetContainer extends AbstractScene {
  34972. /**
  34973. * The scene the AssetContainer belongs to.
  34974. */
  34975. scene: Scene;
  34976. /**
  34977. * Instantiates an AssetContainer.
  34978. * @param scene The scene the AssetContainer belongs to.
  34979. */
  34980. constructor(scene: Scene);
  34981. /**
  34982. * Adds all the assets from the container to the scene.
  34983. */
  34984. addAllToScene(): void;
  34985. /**
  34986. * Removes all the assets in the container from the scene
  34987. */
  34988. removeAllFromScene(): void;
  34989. /**
  34990. * Disposes all the assets in the container
  34991. */
  34992. dispose(): void;
  34993. private _moveAssets;
  34994. /**
  34995. * Removes all the assets contained in the scene and adds them to the container.
  34996. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34997. */
  34998. moveAllFromScene(keepAssets?: KeepAssets): void;
  34999. /**
  35000. * 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.
  35001. * @returns the root mesh
  35002. */
  35003. createRootMesh(): Mesh;
  35004. }
  35005. }
  35006. declare module "babylonjs/abstractScene" {
  35007. import { Scene } from "babylonjs/scene";
  35008. import { Nullable } from "babylonjs/types";
  35009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35010. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35011. import { Geometry } from "babylonjs/Meshes/geometry";
  35012. import { Skeleton } from "babylonjs/Bones/skeleton";
  35013. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35014. import { AssetContainer } from "babylonjs/assetContainer";
  35015. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35016. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35018. import { Material } from "babylonjs/Materials/material";
  35019. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35020. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35021. import { Camera } from "babylonjs/Cameras/camera";
  35022. import { Light } from "babylonjs/Lights/light";
  35023. import { Node } from "babylonjs/node";
  35024. import { Animation } from "babylonjs/Animations/animation";
  35025. /**
  35026. * Defines how the parser contract is defined.
  35027. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35028. */
  35029. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35030. /**
  35031. * Defines how the individual parser contract is defined.
  35032. * These parser can parse an individual asset
  35033. */
  35034. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35035. /**
  35036. * Base class of the scene acting as a container for the different elements composing a scene.
  35037. * This class is dynamically extended by the different components of the scene increasing
  35038. * flexibility and reducing coupling
  35039. */
  35040. export abstract class AbstractScene {
  35041. /**
  35042. * Stores the list of available parsers in the application.
  35043. */
  35044. private static _BabylonFileParsers;
  35045. /**
  35046. * Stores the list of available individual parsers in the application.
  35047. */
  35048. private static _IndividualBabylonFileParsers;
  35049. /**
  35050. * Adds a parser in the list of available ones
  35051. * @param name Defines the name of the parser
  35052. * @param parser Defines the parser to add
  35053. */
  35054. static AddParser(name: string, parser: BabylonFileParser): void;
  35055. /**
  35056. * Gets a general parser from the list of avaialble ones
  35057. * @param name Defines the name of the parser
  35058. * @returns the requested parser or null
  35059. */
  35060. static GetParser(name: string): Nullable<BabylonFileParser>;
  35061. /**
  35062. * Adds n individual parser in the list of available ones
  35063. * @param name Defines the name of the parser
  35064. * @param parser Defines the parser to add
  35065. */
  35066. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35067. /**
  35068. * Gets an individual parser from the list of avaialble ones
  35069. * @param name Defines the name of the parser
  35070. * @returns the requested parser or null
  35071. */
  35072. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35073. /**
  35074. * Parser json data and populate both a scene and its associated container object
  35075. * @param jsonData Defines the data to parse
  35076. * @param scene Defines the scene to parse the data for
  35077. * @param container Defines the container attached to the parsing sequence
  35078. * @param rootUrl Defines the root url of the data
  35079. */
  35080. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35081. /**
  35082. * Gets the list of root nodes (ie. nodes with no parent)
  35083. */
  35084. rootNodes: Node[];
  35085. /** All of the cameras added to this scene
  35086. * @see http://doc.babylonjs.com/babylon101/cameras
  35087. */
  35088. cameras: Camera[];
  35089. /**
  35090. * All of the lights added to this scene
  35091. * @see http://doc.babylonjs.com/babylon101/lights
  35092. */
  35093. lights: Light[];
  35094. /**
  35095. * All of the (abstract) meshes added to this scene
  35096. */
  35097. meshes: AbstractMesh[];
  35098. /**
  35099. * The list of skeletons added to the scene
  35100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35101. */
  35102. skeletons: Skeleton[];
  35103. /**
  35104. * All of the particle systems added to this scene
  35105. * @see http://doc.babylonjs.com/babylon101/particles
  35106. */
  35107. particleSystems: IParticleSystem[];
  35108. /**
  35109. * Gets a list of Animations associated with the scene
  35110. */
  35111. animations: Animation[];
  35112. /**
  35113. * All of the animation groups added to this scene
  35114. * @see http://doc.babylonjs.com/how_to/group
  35115. */
  35116. animationGroups: AnimationGroup[];
  35117. /**
  35118. * All of the multi-materials added to this scene
  35119. * @see http://doc.babylonjs.com/how_to/multi_materials
  35120. */
  35121. multiMaterials: MultiMaterial[];
  35122. /**
  35123. * All of the materials added to this scene
  35124. * In the context of a Scene, it is not supposed to be modified manually.
  35125. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35126. * Note also that the order of the Material wihin the array is not significant and might change.
  35127. * @see http://doc.babylonjs.com/babylon101/materials
  35128. */
  35129. materials: Material[];
  35130. /**
  35131. * The list of morph target managers added to the scene
  35132. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35133. */
  35134. morphTargetManagers: MorphTargetManager[];
  35135. /**
  35136. * The list of geometries used in the scene.
  35137. */
  35138. geometries: Geometry[];
  35139. /**
  35140. * All of the tranform nodes added to this scene
  35141. * In the context of a Scene, it is not supposed to be modified manually.
  35142. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35143. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35144. * @see http://doc.babylonjs.com/how_to/transformnode
  35145. */
  35146. transformNodes: TransformNode[];
  35147. /**
  35148. * ActionManagers available on the scene.
  35149. */
  35150. actionManagers: AbstractActionManager[];
  35151. /**
  35152. * Textures to keep.
  35153. */
  35154. textures: BaseTexture[];
  35155. /**
  35156. * Environment texture for the scene
  35157. */
  35158. environmentTexture: Nullable<BaseTexture>;
  35159. }
  35160. }
  35161. declare module "babylonjs/Audio/sound" {
  35162. import { Observable } from "babylonjs/Misc/observable";
  35163. import { Vector3 } from "babylonjs/Maths/math";
  35164. import { Nullable } from "babylonjs/types";
  35165. import { Scene } from "babylonjs/scene";
  35166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35167. /**
  35168. * Interface used to define options for Sound class
  35169. */
  35170. export interface ISoundOptions {
  35171. /**
  35172. * Does the sound autoplay once loaded.
  35173. */
  35174. autoplay?: boolean;
  35175. /**
  35176. * Does the sound loop after it finishes playing once.
  35177. */
  35178. loop?: boolean;
  35179. /**
  35180. * Sound's volume
  35181. */
  35182. volume?: number;
  35183. /**
  35184. * Is it a spatial sound?
  35185. */
  35186. spatialSound?: boolean;
  35187. /**
  35188. * Maximum distance to hear that sound
  35189. */
  35190. maxDistance?: number;
  35191. /**
  35192. * Uses user defined attenuation function
  35193. */
  35194. useCustomAttenuation?: boolean;
  35195. /**
  35196. * Define the roll off factor of spatial sounds.
  35197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35198. */
  35199. rolloffFactor?: number;
  35200. /**
  35201. * Define the reference distance the sound should be heard perfectly.
  35202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35203. */
  35204. refDistance?: number;
  35205. /**
  35206. * Define the distance attenuation model the sound will follow.
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35208. */
  35209. distanceModel?: string;
  35210. /**
  35211. * Defines the playback speed (1 by default)
  35212. */
  35213. playbackRate?: number;
  35214. /**
  35215. * Defines if the sound is from a streaming source
  35216. */
  35217. streaming?: boolean;
  35218. /**
  35219. * Defines an optional length (in seconds) inside the sound file
  35220. */
  35221. length?: number;
  35222. /**
  35223. * Defines an optional offset (in seconds) inside the sound file
  35224. */
  35225. offset?: number;
  35226. /**
  35227. * If true, URLs will not be required to state the audio file codec to use.
  35228. */
  35229. skipCodecCheck?: boolean;
  35230. }
  35231. /**
  35232. * Defines a sound that can be played in the application.
  35233. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35235. */
  35236. export class Sound {
  35237. /**
  35238. * The name of the sound in the scene.
  35239. */
  35240. name: string;
  35241. /**
  35242. * Does the sound autoplay once loaded.
  35243. */
  35244. autoplay: boolean;
  35245. /**
  35246. * Does the sound loop after it finishes playing once.
  35247. */
  35248. loop: boolean;
  35249. /**
  35250. * Does the sound use a custom attenuation curve to simulate the falloff
  35251. * happening when the source gets further away from the camera.
  35252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35253. */
  35254. useCustomAttenuation: boolean;
  35255. /**
  35256. * The sound track id this sound belongs to.
  35257. */
  35258. soundTrackId: number;
  35259. /**
  35260. * Is this sound currently played.
  35261. */
  35262. isPlaying: boolean;
  35263. /**
  35264. * Is this sound currently paused.
  35265. */
  35266. isPaused: boolean;
  35267. /**
  35268. * Does this sound enables spatial sound.
  35269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35270. */
  35271. spatialSound: boolean;
  35272. /**
  35273. * Define the reference distance the sound should be heard perfectly.
  35274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35275. */
  35276. refDistance: number;
  35277. /**
  35278. * Define the roll off factor of spatial sounds.
  35279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35280. */
  35281. rolloffFactor: number;
  35282. /**
  35283. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35285. */
  35286. maxDistance: number;
  35287. /**
  35288. * Define the distance attenuation model the sound will follow.
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35290. */
  35291. distanceModel: string;
  35292. /**
  35293. * @hidden
  35294. * Back Compat
  35295. **/
  35296. onended: () => any;
  35297. /**
  35298. * Observable event when the current playing sound finishes.
  35299. */
  35300. onEndedObservable: Observable<Sound>;
  35301. private _panningModel;
  35302. private _playbackRate;
  35303. private _streaming;
  35304. private _startTime;
  35305. private _startOffset;
  35306. private _position;
  35307. /** @hidden */
  35308. _positionInEmitterSpace: boolean;
  35309. private _localDirection;
  35310. private _volume;
  35311. private _isReadyToPlay;
  35312. private _isDirectional;
  35313. private _readyToPlayCallback;
  35314. private _audioBuffer;
  35315. private _soundSource;
  35316. private _streamingSource;
  35317. private _soundPanner;
  35318. private _soundGain;
  35319. private _inputAudioNode;
  35320. private _outputAudioNode;
  35321. private _coneInnerAngle;
  35322. private _coneOuterAngle;
  35323. private _coneOuterGain;
  35324. private _scene;
  35325. private _connectedTransformNode;
  35326. private _customAttenuationFunction;
  35327. private _registerFunc;
  35328. private _isOutputConnected;
  35329. private _htmlAudioElement;
  35330. private _urlType;
  35331. private _length?;
  35332. private _offset?;
  35333. /** @hidden */
  35334. static _SceneComponentInitialization: (scene: Scene) => void;
  35335. /**
  35336. * Create a sound and attach it to a scene
  35337. * @param name Name of your sound
  35338. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35339. * @param scene defines the scene the sound belongs to
  35340. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35341. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35342. */
  35343. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35344. /**
  35345. * Release the sound and its associated resources
  35346. */
  35347. dispose(): void;
  35348. /**
  35349. * Gets if the sounds is ready to be played or not.
  35350. * @returns true if ready, otherwise false
  35351. */
  35352. isReady(): boolean;
  35353. private _soundLoaded;
  35354. /**
  35355. * Sets the data of the sound from an audiobuffer
  35356. * @param audioBuffer The audioBuffer containing the data
  35357. */
  35358. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35359. /**
  35360. * Updates the current sounds options such as maxdistance, loop...
  35361. * @param options A JSON object containing values named as the object properties
  35362. */
  35363. updateOptions(options: ISoundOptions): void;
  35364. private _createSpatialParameters;
  35365. private _updateSpatialParameters;
  35366. /**
  35367. * Switch the panning model to HRTF:
  35368. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35370. */
  35371. switchPanningModelToHRTF(): void;
  35372. /**
  35373. * Switch the panning model to Equal Power:
  35374. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35376. */
  35377. switchPanningModelToEqualPower(): void;
  35378. private _switchPanningModel;
  35379. /**
  35380. * Connect this sound to a sound track audio node like gain...
  35381. * @param soundTrackAudioNode the sound track audio node to connect to
  35382. */
  35383. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35384. /**
  35385. * Transform this sound into a directional source
  35386. * @param coneInnerAngle Size of the inner cone in degree
  35387. * @param coneOuterAngle Size of the outer cone in degree
  35388. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35389. */
  35390. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35391. /**
  35392. * Gets or sets the inner angle for the directional cone.
  35393. */
  35394. /**
  35395. * Gets or sets the inner angle for the directional cone.
  35396. */
  35397. directionalConeInnerAngle: number;
  35398. /**
  35399. * Gets or sets the outer angle for the directional cone.
  35400. */
  35401. /**
  35402. * Gets or sets the outer angle for the directional cone.
  35403. */
  35404. directionalConeOuterAngle: number;
  35405. /**
  35406. * Sets the position of the emitter if spatial sound is enabled
  35407. * @param newPosition Defines the new posisiton
  35408. */
  35409. setPosition(newPosition: Vector3): void;
  35410. /**
  35411. * Sets the local direction of the emitter if spatial sound is enabled
  35412. * @param newLocalDirection Defines the new local direction
  35413. */
  35414. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35415. private _updateDirection;
  35416. /** @hidden */
  35417. updateDistanceFromListener(): void;
  35418. /**
  35419. * Sets a new custom attenuation function for the sound.
  35420. * @param callback Defines the function used for the attenuation
  35421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35422. */
  35423. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35424. /**
  35425. * Play the sound
  35426. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35427. * @param offset (optional) Start the sound at a specific time in seconds
  35428. * @param length (optional) Sound duration (in seconds)
  35429. */
  35430. play(time?: number, offset?: number, length?: number): void;
  35431. private _onended;
  35432. /**
  35433. * Stop the sound
  35434. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35435. */
  35436. stop(time?: number): void;
  35437. /**
  35438. * Put the sound in pause
  35439. */
  35440. pause(): void;
  35441. /**
  35442. * Sets a dedicated volume for this sounds
  35443. * @param newVolume Define the new volume of the sound
  35444. * @param time Define time for gradual change to new volume
  35445. */
  35446. setVolume(newVolume: number, time?: number): void;
  35447. /**
  35448. * Set the sound play back rate
  35449. * @param newPlaybackRate Define the playback rate the sound should be played at
  35450. */
  35451. setPlaybackRate(newPlaybackRate: number): void;
  35452. /**
  35453. * Gets the volume of the sound.
  35454. * @returns the volume of the sound
  35455. */
  35456. getVolume(): number;
  35457. /**
  35458. * Attach the sound to a dedicated mesh
  35459. * @param transformNode The transform node to connect the sound with
  35460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35461. */
  35462. attachToMesh(transformNode: TransformNode): void;
  35463. /**
  35464. * Detach the sound from the previously attached mesh
  35465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35466. */
  35467. detachFromMesh(): void;
  35468. private _onRegisterAfterWorldMatrixUpdate;
  35469. /**
  35470. * Clone the current sound in the scene.
  35471. * @returns the new sound clone
  35472. */
  35473. clone(): Nullable<Sound>;
  35474. /**
  35475. * Gets the current underlying audio buffer containing the data
  35476. * @returns the audio buffer
  35477. */
  35478. getAudioBuffer(): Nullable<AudioBuffer>;
  35479. /**
  35480. * Serializes the Sound in a JSON representation
  35481. * @returns the JSON representation of the sound
  35482. */
  35483. serialize(): any;
  35484. /**
  35485. * Parse a JSON representation of a sound to innstantiate in a given scene
  35486. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35487. * @param scene Define the scene the new parsed sound should be created in
  35488. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35489. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35490. * @returns the newly parsed sound
  35491. */
  35492. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35493. }
  35494. }
  35495. declare module "babylonjs/Actions/directAudioActions" {
  35496. import { Action } from "babylonjs/Actions/action";
  35497. import { Condition } from "babylonjs/Actions/condition";
  35498. import { Sound } from "babylonjs/Audio/sound";
  35499. /**
  35500. * This defines an action helpful to play a defined sound on a triggered action.
  35501. */
  35502. export class PlaySoundAction extends Action {
  35503. private _sound;
  35504. /**
  35505. * Instantiate the action
  35506. * @param triggerOptions defines the trigger options
  35507. * @param sound defines the sound to play
  35508. * @param condition defines the trigger related conditions
  35509. */
  35510. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35511. /** @hidden */
  35512. _prepare(): void;
  35513. /**
  35514. * Execute the action and play the sound.
  35515. */
  35516. execute(): void;
  35517. /**
  35518. * Serializes the actions and its related information.
  35519. * @param parent defines the object to serialize in
  35520. * @returns the serialized object
  35521. */
  35522. serialize(parent: any): any;
  35523. }
  35524. /**
  35525. * This defines an action helpful to stop a defined sound on a triggered action.
  35526. */
  35527. export class StopSoundAction extends Action {
  35528. private _sound;
  35529. /**
  35530. * Instantiate the action
  35531. * @param triggerOptions defines the trigger options
  35532. * @param sound defines the sound to stop
  35533. * @param condition defines the trigger related conditions
  35534. */
  35535. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35536. /** @hidden */
  35537. _prepare(): void;
  35538. /**
  35539. * Execute the action and stop the sound.
  35540. */
  35541. execute(): void;
  35542. /**
  35543. * Serializes the actions and its related information.
  35544. * @param parent defines the object to serialize in
  35545. * @returns the serialized object
  35546. */
  35547. serialize(parent: any): any;
  35548. }
  35549. }
  35550. declare module "babylonjs/Actions/interpolateValueAction" {
  35551. import { Action } from "babylonjs/Actions/action";
  35552. import { Condition } from "babylonjs/Actions/condition";
  35553. import { Observable } from "babylonjs/Misc/observable";
  35554. /**
  35555. * This defines an action responsible to change the value of a property
  35556. * by interpolating between its current value and the newly set one once triggered.
  35557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35558. */
  35559. export class InterpolateValueAction extends Action {
  35560. /**
  35561. * Defines the path of the property where the value should be interpolated
  35562. */
  35563. propertyPath: string;
  35564. /**
  35565. * Defines the target value at the end of the interpolation.
  35566. */
  35567. value: any;
  35568. /**
  35569. * Defines the time it will take for the property to interpolate to the value.
  35570. */
  35571. duration: number;
  35572. /**
  35573. * Defines if the other scene animations should be stopped when the action has been triggered
  35574. */
  35575. stopOtherAnimations?: boolean;
  35576. /**
  35577. * Defines a callback raised once the interpolation animation has been done.
  35578. */
  35579. onInterpolationDone?: () => void;
  35580. /**
  35581. * Observable triggered once the interpolation animation has been done.
  35582. */
  35583. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35584. private _target;
  35585. private _effectiveTarget;
  35586. private _property;
  35587. /**
  35588. * Instantiate the action
  35589. * @param triggerOptions defines the trigger options
  35590. * @param target defines the object containing the value to interpolate
  35591. * @param propertyPath defines the path to the property in the target object
  35592. * @param value defines the target value at the end of the interpolation
  35593. * @param duration deines the time it will take for the property to interpolate to the value.
  35594. * @param condition defines the trigger related conditions
  35595. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35596. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35597. */
  35598. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35599. /** @hidden */
  35600. _prepare(): void;
  35601. /**
  35602. * Execute the action starts the value interpolation.
  35603. */
  35604. execute(): void;
  35605. /**
  35606. * Serializes the actions and its related information.
  35607. * @param parent defines the object to serialize in
  35608. * @returns the serialized object
  35609. */
  35610. serialize(parent: any): any;
  35611. }
  35612. }
  35613. declare module "babylonjs/Actions/index" {
  35614. export * from "babylonjs/Actions/action";
  35615. export * from "babylonjs/Actions/actionEvent";
  35616. export * from "babylonjs/Actions/actionManager";
  35617. export * from "babylonjs/Actions/condition";
  35618. export * from "babylonjs/Actions/directActions";
  35619. export * from "babylonjs/Actions/directAudioActions";
  35620. export * from "babylonjs/Actions/interpolateValueAction";
  35621. }
  35622. declare module "babylonjs/Animations/index" {
  35623. export * from "babylonjs/Animations/animatable";
  35624. export * from "babylonjs/Animations/animation";
  35625. export * from "babylonjs/Animations/animationGroup";
  35626. export * from "babylonjs/Animations/animationPropertiesOverride";
  35627. export * from "babylonjs/Animations/easing";
  35628. export * from "babylonjs/Animations/runtimeAnimation";
  35629. export * from "babylonjs/Animations/animationEvent";
  35630. export * from "babylonjs/Animations/animationGroup";
  35631. export * from "babylonjs/Animations/animationKey";
  35632. export * from "babylonjs/Animations/animationRange";
  35633. }
  35634. declare module "babylonjs/Audio/soundTrack" {
  35635. import { Sound } from "babylonjs/Audio/sound";
  35636. import { Analyser } from "babylonjs/Audio/analyser";
  35637. import { Scene } from "babylonjs/scene";
  35638. /**
  35639. * Options allowed during the creation of a sound track.
  35640. */
  35641. export interface ISoundTrackOptions {
  35642. /**
  35643. * The volume the sound track should take during creation
  35644. */
  35645. volume?: number;
  35646. /**
  35647. * Define if the sound track is the main sound track of the scene
  35648. */
  35649. mainTrack?: boolean;
  35650. }
  35651. /**
  35652. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35653. * It will be also used in a future release to apply effects on a specific track.
  35654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35655. */
  35656. export class SoundTrack {
  35657. /**
  35658. * The unique identifier of the sound track in the scene.
  35659. */
  35660. id: number;
  35661. /**
  35662. * The list of sounds included in the sound track.
  35663. */
  35664. soundCollection: Array<Sound>;
  35665. private _outputAudioNode;
  35666. private _scene;
  35667. private _isMainTrack;
  35668. private _connectedAnalyser;
  35669. private _options;
  35670. private _isInitialized;
  35671. /**
  35672. * Creates a new sound track.
  35673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35674. * @param scene Define the scene the sound track belongs to
  35675. * @param options
  35676. */
  35677. constructor(scene: Scene, options?: ISoundTrackOptions);
  35678. private _initializeSoundTrackAudioGraph;
  35679. /**
  35680. * Release the sound track and its associated resources
  35681. */
  35682. dispose(): void;
  35683. /**
  35684. * Adds a sound to this sound track
  35685. * @param sound define the cound to add
  35686. * @ignoreNaming
  35687. */
  35688. AddSound(sound: Sound): void;
  35689. /**
  35690. * Removes a sound to this sound track
  35691. * @param sound define the cound to remove
  35692. * @ignoreNaming
  35693. */
  35694. RemoveSound(sound: Sound): void;
  35695. /**
  35696. * Set a global volume for the full sound track.
  35697. * @param newVolume Define the new volume of the sound track
  35698. */
  35699. setVolume(newVolume: number): void;
  35700. /**
  35701. * Switch the panning model to HRTF:
  35702. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35704. */
  35705. switchPanningModelToHRTF(): void;
  35706. /**
  35707. * Switch the panning model to Equal Power:
  35708. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35710. */
  35711. switchPanningModelToEqualPower(): void;
  35712. /**
  35713. * Connect the sound track to an audio analyser allowing some amazing
  35714. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35716. * @param analyser The analyser to connect to the engine
  35717. */
  35718. connectToAnalyser(analyser: Analyser): void;
  35719. }
  35720. }
  35721. declare module "babylonjs/Audio/audioSceneComponent" {
  35722. import { Sound } from "babylonjs/Audio/sound";
  35723. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35724. import { Nullable } from "babylonjs/types";
  35725. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35726. import { Scene } from "babylonjs/scene";
  35727. import { AbstractScene } from "babylonjs/abstractScene";
  35728. module "babylonjs/abstractScene" {
  35729. interface AbstractScene {
  35730. /**
  35731. * The list of sounds used in the scene.
  35732. */
  35733. sounds: Nullable<Array<Sound>>;
  35734. }
  35735. }
  35736. module "babylonjs/scene" {
  35737. interface Scene {
  35738. /**
  35739. * @hidden
  35740. * Backing field
  35741. */
  35742. _mainSoundTrack: SoundTrack;
  35743. /**
  35744. * The main sound track played by the scene.
  35745. * It cotains your primary collection of sounds.
  35746. */
  35747. mainSoundTrack: SoundTrack;
  35748. /**
  35749. * The list of sound tracks added to the scene
  35750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35751. */
  35752. soundTracks: Nullable<Array<SoundTrack>>;
  35753. /**
  35754. * Gets a sound using a given name
  35755. * @param name defines the name to search for
  35756. * @return the found sound or null if not found at all.
  35757. */
  35758. getSoundByName(name: string): Nullable<Sound>;
  35759. /**
  35760. * Gets or sets if audio support is enabled
  35761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35762. */
  35763. audioEnabled: boolean;
  35764. /**
  35765. * Gets or sets if audio will be output to headphones
  35766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35767. */
  35768. headphone: boolean;
  35769. }
  35770. }
  35771. /**
  35772. * Defines the sound scene component responsible to manage any sounds
  35773. * in a given scene.
  35774. */
  35775. export class AudioSceneComponent implements ISceneSerializableComponent {
  35776. /**
  35777. * The component name helpfull to identify the component in the list of scene components.
  35778. */
  35779. readonly name: string;
  35780. /**
  35781. * The scene the component belongs to.
  35782. */
  35783. scene: Scene;
  35784. private _audioEnabled;
  35785. /**
  35786. * Gets whether audio is enabled or not.
  35787. * Please use related enable/disable method to switch state.
  35788. */
  35789. readonly audioEnabled: boolean;
  35790. private _headphone;
  35791. /**
  35792. * Gets whether audio is outputing to headphone or not.
  35793. * Please use the according Switch methods to change output.
  35794. */
  35795. readonly headphone: boolean;
  35796. /**
  35797. * Creates a new instance of the component for the given scene
  35798. * @param scene Defines the scene to register the component in
  35799. */
  35800. constructor(scene: Scene);
  35801. /**
  35802. * Registers the component in a given scene
  35803. */
  35804. register(): void;
  35805. /**
  35806. * Rebuilds the elements related to this component in case of
  35807. * context lost for instance.
  35808. */
  35809. rebuild(): void;
  35810. /**
  35811. * Serializes the component data to the specified json object
  35812. * @param serializationObject The object to serialize to
  35813. */
  35814. serialize(serializationObject: any): void;
  35815. /**
  35816. * Adds all the elements from the container to the scene
  35817. * @param container the container holding the elements
  35818. */
  35819. addFromContainer(container: AbstractScene): void;
  35820. /**
  35821. * Removes all the elements in the container from the scene
  35822. * @param container contains the elements to remove
  35823. * @param dispose if the removed element should be disposed (default: false)
  35824. */
  35825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35826. /**
  35827. * Disposes the component and the associated ressources.
  35828. */
  35829. dispose(): void;
  35830. /**
  35831. * Disables audio in the associated scene.
  35832. */
  35833. disableAudio(): void;
  35834. /**
  35835. * Enables audio in the associated scene.
  35836. */
  35837. enableAudio(): void;
  35838. /**
  35839. * Switch audio to headphone output.
  35840. */
  35841. switchAudioModeForHeadphones(): void;
  35842. /**
  35843. * Switch audio to normal speakers.
  35844. */
  35845. switchAudioModeForNormalSpeakers(): void;
  35846. private _afterRender;
  35847. }
  35848. }
  35849. declare module "babylonjs/Audio/weightedsound" {
  35850. import { Sound } from "babylonjs/Audio/sound";
  35851. /**
  35852. * Wraps one or more Sound objects and selects one with random weight for playback.
  35853. */
  35854. export class WeightedSound {
  35855. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35856. loop: boolean;
  35857. private _coneInnerAngle;
  35858. private _coneOuterAngle;
  35859. private _volume;
  35860. /** A Sound is currently playing. */
  35861. isPlaying: boolean;
  35862. /** A Sound is currently paused. */
  35863. isPaused: boolean;
  35864. private _sounds;
  35865. private _weights;
  35866. private _currentIndex?;
  35867. /**
  35868. * Creates a new WeightedSound from the list of sounds given.
  35869. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35870. * @param sounds Array of Sounds that will be selected from.
  35871. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35872. */
  35873. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35874. /**
  35875. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35876. */
  35877. /**
  35878. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35879. */
  35880. directionalConeInnerAngle: number;
  35881. /**
  35882. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35883. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35884. */
  35885. /**
  35886. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35887. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35888. */
  35889. directionalConeOuterAngle: number;
  35890. /**
  35891. * Playback volume.
  35892. */
  35893. /**
  35894. * Playback volume.
  35895. */
  35896. volume: number;
  35897. private _onended;
  35898. /**
  35899. * Suspend playback
  35900. */
  35901. pause(): void;
  35902. /**
  35903. * Stop playback
  35904. */
  35905. stop(): void;
  35906. /**
  35907. * Start playback.
  35908. * @param startOffset Position the clip head at a specific time in seconds.
  35909. */
  35910. play(startOffset?: number): void;
  35911. }
  35912. }
  35913. declare module "babylonjs/Audio/index" {
  35914. export * from "babylonjs/Audio/analyser";
  35915. export * from "babylonjs/Audio/audioEngine";
  35916. export * from "babylonjs/Audio/audioSceneComponent";
  35917. export * from "babylonjs/Audio/sound";
  35918. export * from "babylonjs/Audio/soundTrack";
  35919. export * from "babylonjs/Audio/weightedsound";
  35920. }
  35921. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35922. import { Behavior } from "babylonjs/Behaviors/behavior";
  35923. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35924. import { BackEase } from "babylonjs/Animations/easing";
  35925. /**
  35926. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35928. */
  35929. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35930. /**
  35931. * Gets the name of the behavior.
  35932. */
  35933. readonly name: string;
  35934. /**
  35935. * The easing function used by animations
  35936. */
  35937. static EasingFunction: BackEase;
  35938. /**
  35939. * The easing mode used by animations
  35940. */
  35941. static EasingMode: number;
  35942. /**
  35943. * The duration of the animation, in milliseconds
  35944. */
  35945. transitionDuration: number;
  35946. /**
  35947. * Length of the distance animated by the transition when lower radius is reached
  35948. */
  35949. lowerRadiusTransitionRange: number;
  35950. /**
  35951. * Length of the distance animated by the transition when upper radius is reached
  35952. */
  35953. upperRadiusTransitionRange: number;
  35954. private _autoTransitionRange;
  35955. /**
  35956. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35957. */
  35958. /**
  35959. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35960. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35961. */
  35962. autoTransitionRange: boolean;
  35963. private _attachedCamera;
  35964. private _onAfterCheckInputsObserver;
  35965. private _onMeshTargetChangedObserver;
  35966. /**
  35967. * Initializes the behavior.
  35968. */
  35969. init(): void;
  35970. /**
  35971. * Attaches the behavior to its arc rotate camera.
  35972. * @param camera Defines the camera to attach the behavior to
  35973. */
  35974. attach(camera: ArcRotateCamera): void;
  35975. /**
  35976. * Detaches the behavior from its current arc rotate camera.
  35977. */
  35978. detach(): void;
  35979. private _radiusIsAnimating;
  35980. private _radiusBounceTransition;
  35981. private _animatables;
  35982. private _cachedWheelPrecision;
  35983. /**
  35984. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35985. * @param radiusLimit The limit to check against.
  35986. * @return Bool to indicate if at limit.
  35987. */
  35988. private _isRadiusAtLimit;
  35989. /**
  35990. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35991. * @param radiusDelta The delta by which to animate to. Can be negative.
  35992. */
  35993. private _applyBoundRadiusAnimation;
  35994. /**
  35995. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35996. */
  35997. protected _clearAnimationLocks(): void;
  35998. /**
  35999. * Stops and removes all animations that have been applied to the camera
  36000. */
  36001. stopAllAnimations(): void;
  36002. }
  36003. }
  36004. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36005. import { Behavior } from "babylonjs/Behaviors/behavior";
  36006. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36007. import { ExponentialEase } from "babylonjs/Animations/easing";
  36008. import { Nullable } from "babylonjs/types";
  36009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36010. import { Vector3 } from "babylonjs/Maths/math";
  36011. /**
  36012. * 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.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36014. */
  36015. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36016. /**
  36017. * Gets the name of the behavior.
  36018. */
  36019. readonly name: string;
  36020. private _mode;
  36021. private _radiusScale;
  36022. private _positionScale;
  36023. private _defaultElevation;
  36024. private _elevationReturnTime;
  36025. private _elevationReturnWaitTime;
  36026. private _zoomStopsAnimation;
  36027. private _framingTime;
  36028. /**
  36029. * The easing function used by animations
  36030. */
  36031. static EasingFunction: ExponentialEase;
  36032. /**
  36033. * The easing mode used by animations
  36034. */
  36035. static EasingMode: number;
  36036. /**
  36037. * Sets the current mode used by the behavior
  36038. */
  36039. /**
  36040. * Gets current mode used by the behavior.
  36041. */
  36042. mode: number;
  36043. /**
  36044. * Sets the scale applied to the radius (1 by default)
  36045. */
  36046. /**
  36047. * Gets the scale applied to the radius
  36048. */
  36049. radiusScale: number;
  36050. /**
  36051. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36052. */
  36053. /**
  36054. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36055. */
  36056. positionScale: number;
  36057. /**
  36058. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36059. * behaviour is triggered, in radians.
  36060. */
  36061. /**
  36062. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36063. * behaviour is triggered, in radians.
  36064. */
  36065. defaultElevation: number;
  36066. /**
  36067. * Sets the time (in milliseconds) taken to return to the default beta position.
  36068. * Negative value indicates camera should not return to default.
  36069. */
  36070. /**
  36071. * Gets the time (in milliseconds) taken to return to the default beta position.
  36072. * Negative value indicates camera should not return to default.
  36073. */
  36074. elevationReturnTime: number;
  36075. /**
  36076. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36077. */
  36078. /**
  36079. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36080. */
  36081. elevationReturnWaitTime: number;
  36082. /**
  36083. * Sets the flag that indicates if user zooming should stop animation.
  36084. */
  36085. /**
  36086. * Gets the flag that indicates if user zooming should stop animation.
  36087. */
  36088. zoomStopsAnimation: boolean;
  36089. /**
  36090. * Sets the transition time when framing the mesh, in milliseconds
  36091. */
  36092. /**
  36093. * Gets the transition time when framing the mesh, in milliseconds
  36094. */
  36095. framingTime: number;
  36096. /**
  36097. * Define if the behavior should automatically change the configured
  36098. * camera limits and sensibilities.
  36099. */
  36100. autoCorrectCameraLimitsAndSensibility: boolean;
  36101. private _onPrePointerObservableObserver;
  36102. private _onAfterCheckInputsObserver;
  36103. private _onMeshTargetChangedObserver;
  36104. private _attachedCamera;
  36105. private _isPointerDown;
  36106. private _lastInteractionTime;
  36107. /**
  36108. * Initializes the behavior.
  36109. */
  36110. init(): void;
  36111. /**
  36112. * Attaches the behavior to its arc rotate camera.
  36113. * @param camera Defines the camera to attach the behavior to
  36114. */
  36115. attach(camera: ArcRotateCamera): void;
  36116. /**
  36117. * Detaches the behavior from its current arc rotate camera.
  36118. */
  36119. detach(): void;
  36120. private _animatables;
  36121. private _betaIsAnimating;
  36122. private _betaTransition;
  36123. private _radiusTransition;
  36124. private _vectorTransition;
  36125. /**
  36126. * Targets the given mesh and updates zoom level accordingly.
  36127. * @param mesh The mesh to target.
  36128. * @param radius Optional. If a cached radius position already exists, overrides default.
  36129. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36132. */
  36133. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36134. /**
  36135. * Targets the given mesh with its children and updates zoom level accordingly.
  36136. * @param mesh The mesh to target.
  36137. * @param radius Optional. If a cached radius position already exists, overrides default.
  36138. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36141. */
  36142. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36143. /**
  36144. * Targets the given meshes with their children and updates zoom level accordingly.
  36145. * @param meshes The mesh to target.
  36146. * @param radius Optional. If a cached radius position already exists, overrides default.
  36147. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36150. */
  36151. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36152. /**
  36153. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36154. * @param minimumWorld Determines the smaller position of the bounding box extend
  36155. * @param maximumWorld Determines the bigger position of the bounding box extend
  36156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36158. */
  36159. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36160. /**
  36161. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36162. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36163. * frustum width.
  36164. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36165. * to fully enclose the mesh in the viewing frustum.
  36166. */
  36167. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36168. /**
  36169. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36170. * is automatically returned to its default position (expected to be above ground plane).
  36171. */
  36172. private _maintainCameraAboveGround;
  36173. /**
  36174. * Returns the frustum slope based on the canvas ratio and camera FOV
  36175. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36176. */
  36177. private _getFrustumSlope;
  36178. /**
  36179. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36180. */
  36181. private _clearAnimationLocks;
  36182. /**
  36183. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36184. */
  36185. private _applyUserInteraction;
  36186. /**
  36187. * Stops and removes all animations that have been applied to the camera
  36188. */
  36189. stopAllAnimations(): void;
  36190. /**
  36191. * Gets a value indicating if the user is moving the camera
  36192. */
  36193. readonly isUserIsMoving: boolean;
  36194. /**
  36195. * The camera can move all the way towards the mesh.
  36196. */
  36197. static IgnoreBoundsSizeMode: number;
  36198. /**
  36199. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36200. */
  36201. static FitFrustumSidesMode: number;
  36202. }
  36203. }
  36204. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36205. import { Nullable } from "babylonjs/types";
  36206. import { Camera } from "babylonjs/Cameras/camera";
  36207. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36208. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36209. /**
  36210. * Base class for Camera Pointer Inputs.
  36211. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36212. * for example usage.
  36213. */
  36214. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36215. /**
  36216. * Defines the camera the input is attached to.
  36217. */
  36218. abstract camera: Camera;
  36219. /**
  36220. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36221. */
  36222. protected _altKey: boolean;
  36223. protected _ctrlKey: boolean;
  36224. protected _metaKey: boolean;
  36225. protected _shiftKey: boolean;
  36226. /**
  36227. * Which mouse buttons were pressed at time of last mouse event.
  36228. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36229. */
  36230. protected _buttonsPressed: number;
  36231. /**
  36232. * Defines the buttons associated with the input to handle camera move.
  36233. */
  36234. buttons: number[];
  36235. /**
  36236. * Attach the input controls to a specific dom element to get the input from.
  36237. * @param element Defines the element the controls should be listened from
  36238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36239. */
  36240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36241. /**
  36242. * Detach the current controls from the specified dom element.
  36243. * @param element Defines the element to stop listening the inputs from
  36244. */
  36245. detachControl(element: Nullable<HTMLElement>): void;
  36246. /**
  36247. * Gets the class name of the current input.
  36248. * @returns the class name
  36249. */
  36250. getClassName(): string;
  36251. /**
  36252. * Get the friendly name associated with the input class.
  36253. * @returns the input friendly name
  36254. */
  36255. getSimpleName(): string;
  36256. /**
  36257. * Called on pointer POINTERDOUBLETAP event.
  36258. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36259. */
  36260. protected onDoubleTap(type: string): void;
  36261. /**
  36262. * Called on pointer POINTERMOVE event if only a single touch is active.
  36263. * Override this method to provide functionality.
  36264. */
  36265. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36266. /**
  36267. * Called on pointer POINTERMOVE event if multiple touches are active.
  36268. * Override this method to provide functionality.
  36269. */
  36270. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36271. /**
  36272. * Called on JS contextmenu event.
  36273. * Override this method to provide functionality.
  36274. */
  36275. protected onContextMenu(evt: PointerEvent): void;
  36276. /**
  36277. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36278. * press.
  36279. * Override this method to provide functionality.
  36280. */
  36281. protected onButtonDown(evt: PointerEvent): void;
  36282. /**
  36283. * Called each time a new POINTERUP event occurs. Ie, for each button
  36284. * release.
  36285. * Override this method to provide functionality.
  36286. */
  36287. protected onButtonUp(evt: PointerEvent): void;
  36288. /**
  36289. * Called when window becomes inactive.
  36290. * Override this method to provide functionality.
  36291. */
  36292. protected onLostFocus(): void;
  36293. private _pointerInput;
  36294. private _observer;
  36295. private _onLostFocus;
  36296. private pointA;
  36297. private pointB;
  36298. }
  36299. }
  36300. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36301. import { Nullable } from "babylonjs/types";
  36302. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36303. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36304. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36305. /**
  36306. * Manage the pointers inputs to control an arc rotate camera.
  36307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36308. */
  36309. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36310. /**
  36311. * Defines the camera the input is attached to.
  36312. */
  36313. camera: ArcRotateCamera;
  36314. /**
  36315. * Gets the class name of the current input.
  36316. * @returns the class name
  36317. */
  36318. getClassName(): string;
  36319. /**
  36320. * Defines the buttons associated with the input to handle camera move.
  36321. */
  36322. buttons: number[];
  36323. /**
  36324. * Defines the pointer angular sensibility along the X axis or how fast is
  36325. * the camera rotating.
  36326. */
  36327. angularSensibilityX: number;
  36328. /**
  36329. * Defines the pointer angular sensibility along the Y axis or how fast is
  36330. * the camera rotating.
  36331. */
  36332. angularSensibilityY: number;
  36333. /**
  36334. * Defines the pointer pinch precision or how fast is the camera zooming.
  36335. */
  36336. pinchPrecision: number;
  36337. /**
  36338. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36339. * from 0.
  36340. * It defines the percentage of current camera.radius to use as delta when
  36341. * pinch zoom is used.
  36342. */
  36343. pinchDeltaPercentage: number;
  36344. /**
  36345. * Defines the pointer panning sensibility or how fast is the camera moving.
  36346. */
  36347. panningSensibility: number;
  36348. /**
  36349. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36350. */
  36351. multiTouchPanning: boolean;
  36352. /**
  36353. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36354. * zoom (pinch) through multitouch.
  36355. */
  36356. multiTouchPanAndZoom: boolean;
  36357. /**
  36358. * Revers pinch action direction.
  36359. */
  36360. pinchInwards: boolean;
  36361. private _isPanClick;
  36362. private _twoFingerActivityCount;
  36363. private _isPinching;
  36364. /**
  36365. * Called on pointer POINTERMOVE event if only a single touch is active.
  36366. */
  36367. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36368. /**
  36369. * Called on pointer POINTERDOUBLETAP event.
  36370. */
  36371. protected onDoubleTap(type: string): void;
  36372. /**
  36373. * Called on pointer POINTERMOVE event if multiple touches are active.
  36374. */
  36375. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36376. /**
  36377. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36378. * press.
  36379. */
  36380. protected onButtonDown(evt: PointerEvent): void;
  36381. /**
  36382. * Called each time a new POINTERUP event occurs. Ie, for each button
  36383. * release.
  36384. */
  36385. protected onButtonUp(evt: PointerEvent): void;
  36386. /**
  36387. * Called when window becomes inactive.
  36388. */
  36389. protected onLostFocus(): void;
  36390. }
  36391. }
  36392. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36393. import { Nullable } from "babylonjs/types";
  36394. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36395. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36396. /**
  36397. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36399. */
  36400. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36401. /**
  36402. * Defines the camera the input is attached to.
  36403. */
  36404. camera: ArcRotateCamera;
  36405. /**
  36406. * Defines the list of key codes associated with the up action (increase alpha)
  36407. */
  36408. keysUp: number[];
  36409. /**
  36410. * Defines the list of key codes associated with the down action (decrease alpha)
  36411. */
  36412. keysDown: number[];
  36413. /**
  36414. * Defines the list of key codes associated with the left action (increase beta)
  36415. */
  36416. keysLeft: number[];
  36417. /**
  36418. * Defines the list of key codes associated with the right action (decrease beta)
  36419. */
  36420. keysRight: number[];
  36421. /**
  36422. * Defines the list of key codes associated with the reset action.
  36423. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36424. */
  36425. keysReset: number[];
  36426. /**
  36427. * Defines the panning sensibility of the inputs.
  36428. * (How fast is the camera paning)
  36429. */
  36430. panningSensibility: number;
  36431. /**
  36432. * Defines the zooming sensibility of the inputs.
  36433. * (How fast is the camera zooming)
  36434. */
  36435. zoomingSensibility: number;
  36436. /**
  36437. * Defines wether maintaining the alt key down switch the movement mode from
  36438. * orientation to zoom.
  36439. */
  36440. useAltToZoom: boolean;
  36441. /**
  36442. * Rotation speed of the camera
  36443. */
  36444. angularSpeed: number;
  36445. private _keys;
  36446. private _ctrlPressed;
  36447. private _altPressed;
  36448. private _onCanvasBlurObserver;
  36449. private _onKeyboardObserver;
  36450. private _engine;
  36451. private _scene;
  36452. /**
  36453. * Attach the input controls to a specific dom element to get the input from.
  36454. * @param element Defines the element the controls should be listened from
  36455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36456. */
  36457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36458. /**
  36459. * Detach the current controls from the specified dom element.
  36460. * @param element Defines the element to stop listening the inputs from
  36461. */
  36462. detachControl(element: Nullable<HTMLElement>): void;
  36463. /**
  36464. * Update the current camera state depending on the inputs that have been used this frame.
  36465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36466. */
  36467. checkInputs(): void;
  36468. /**
  36469. * Gets the class name of the current intput.
  36470. * @returns the class name
  36471. */
  36472. getClassName(): string;
  36473. /**
  36474. * Get the friendly name associated with the input class.
  36475. * @returns the input friendly name
  36476. */
  36477. getSimpleName(): string;
  36478. }
  36479. }
  36480. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36481. import { Nullable } from "babylonjs/types";
  36482. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36483. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36484. /**
  36485. * Manage the mouse wheel inputs to control an arc rotate camera.
  36486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36487. */
  36488. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36489. /**
  36490. * Defines the camera the input is attached to.
  36491. */
  36492. camera: ArcRotateCamera;
  36493. /**
  36494. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36495. */
  36496. wheelPrecision: number;
  36497. /**
  36498. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36499. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36500. */
  36501. wheelDeltaPercentage: number;
  36502. private _wheel;
  36503. private _observer;
  36504. private computeDeltaFromMouseWheelLegacyEvent;
  36505. /**
  36506. * Attach the input controls to a specific dom element to get the input from.
  36507. * @param element Defines the element the controls should be listened from
  36508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36509. */
  36510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36511. /**
  36512. * Detach the current controls from the specified dom element.
  36513. * @param element Defines the element to stop listening the inputs from
  36514. */
  36515. detachControl(element: Nullable<HTMLElement>): void;
  36516. /**
  36517. * Gets the class name of the current intput.
  36518. * @returns the class name
  36519. */
  36520. getClassName(): string;
  36521. /**
  36522. * Get the friendly name associated with the input class.
  36523. * @returns the input friendly name
  36524. */
  36525. getSimpleName(): string;
  36526. }
  36527. }
  36528. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36529. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36530. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36531. /**
  36532. * Default Inputs manager for the ArcRotateCamera.
  36533. * It groups all the default supported inputs for ease of use.
  36534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36535. */
  36536. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36537. /**
  36538. * Instantiates a new ArcRotateCameraInputsManager.
  36539. * @param camera Defines the camera the inputs belong to
  36540. */
  36541. constructor(camera: ArcRotateCamera);
  36542. /**
  36543. * Add mouse wheel input support to the input manager.
  36544. * @returns the current input manager
  36545. */
  36546. addMouseWheel(): ArcRotateCameraInputsManager;
  36547. /**
  36548. * Add pointers input support to the input manager.
  36549. * @returns the current input manager
  36550. */
  36551. addPointers(): ArcRotateCameraInputsManager;
  36552. /**
  36553. * Add keyboard input support to the input manager.
  36554. * @returns the current input manager
  36555. */
  36556. addKeyboard(): ArcRotateCameraInputsManager;
  36557. }
  36558. }
  36559. declare module "babylonjs/Cameras/arcRotateCamera" {
  36560. import { Observable } from "babylonjs/Misc/observable";
  36561. import { Nullable } from "babylonjs/types";
  36562. import { Scene } from "babylonjs/scene";
  36563. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36565. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36566. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36567. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36568. import { Camera } from "babylonjs/Cameras/camera";
  36569. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36570. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36571. import { Collider } from "babylonjs/Collisions/collider";
  36572. /**
  36573. * This represents an orbital type of camera.
  36574. *
  36575. * 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.
  36576. * 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.
  36577. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36578. */
  36579. export class ArcRotateCamera extends TargetCamera {
  36580. /**
  36581. * Defines the rotation angle of the camera along the longitudinal axis.
  36582. */
  36583. alpha: number;
  36584. /**
  36585. * Defines the rotation angle of the camera along the latitudinal axis.
  36586. */
  36587. beta: number;
  36588. /**
  36589. * Defines the radius of the camera from it s target point.
  36590. */
  36591. radius: number;
  36592. protected _target: Vector3;
  36593. protected _targetHost: Nullable<AbstractMesh>;
  36594. /**
  36595. * Defines the target point of the camera.
  36596. * The camera looks towards it form the radius distance.
  36597. */
  36598. target: Vector3;
  36599. /**
  36600. * Define the current local position of the camera in the scene
  36601. */
  36602. position: Vector3;
  36603. protected _upVector: Vector3;
  36604. protected _upToYMatrix: Matrix;
  36605. protected _YToUpMatrix: Matrix;
  36606. /**
  36607. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36608. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36609. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36610. */
  36611. upVector: Vector3;
  36612. /**
  36613. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36614. */
  36615. setMatUp(): void;
  36616. /**
  36617. * Current inertia value on the longitudinal axis.
  36618. * The bigger this number the longer it will take for the camera to stop.
  36619. */
  36620. inertialAlphaOffset: number;
  36621. /**
  36622. * Current inertia value on the latitudinal axis.
  36623. * The bigger this number the longer it will take for the camera to stop.
  36624. */
  36625. inertialBetaOffset: number;
  36626. /**
  36627. * Current inertia value on the radius axis.
  36628. * The bigger this number the longer it will take for the camera to stop.
  36629. */
  36630. inertialRadiusOffset: number;
  36631. /**
  36632. * Minimum allowed angle on the longitudinal axis.
  36633. * This can help limiting how the Camera is able to move in the scene.
  36634. */
  36635. lowerAlphaLimit: Nullable<number>;
  36636. /**
  36637. * Maximum allowed angle on the longitudinal axis.
  36638. * This can help limiting how the Camera is able to move in the scene.
  36639. */
  36640. upperAlphaLimit: Nullable<number>;
  36641. /**
  36642. * Minimum allowed angle on the latitudinal axis.
  36643. * This can help limiting how the Camera is able to move in the scene.
  36644. */
  36645. lowerBetaLimit: number;
  36646. /**
  36647. * Maximum allowed angle on the latitudinal axis.
  36648. * This can help limiting how the Camera is able to move in the scene.
  36649. */
  36650. upperBetaLimit: number;
  36651. /**
  36652. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36653. * This can help limiting how the Camera is able to move in the scene.
  36654. */
  36655. lowerRadiusLimit: Nullable<number>;
  36656. /**
  36657. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36658. * This can help limiting how the Camera is able to move in the scene.
  36659. */
  36660. upperRadiusLimit: Nullable<number>;
  36661. /**
  36662. * Defines the current inertia value used during panning of the camera along the X axis.
  36663. */
  36664. inertialPanningX: number;
  36665. /**
  36666. * Defines the current inertia value used during panning of the camera along the Y axis.
  36667. */
  36668. inertialPanningY: number;
  36669. /**
  36670. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36671. * Basically if your fingers moves away from more than this distance you will be considered
  36672. * in pinch mode.
  36673. */
  36674. pinchToPanMaxDistance: number;
  36675. /**
  36676. * Defines the maximum distance the camera can pan.
  36677. * This could help keeping the cammera always in your scene.
  36678. */
  36679. panningDistanceLimit: Nullable<number>;
  36680. /**
  36681. * Defines the target of the camera before paning.
  36682. */
  36683. panningOriginTarget: Vector3;
  36684. /**
  36685. * Defines the value of the inertia used during panning.
  36686. * 0 would mean stop inertia and one would mean no decelleration at all.
  36687. */
  36688. panningInertia: number;
  36689. /**
  36690. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36691. */
  36692. angularSensibilityX: number;
  36693. /**
  36694. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36695. */
  36696. angularSensibilityY: number;
  36697. /**
  36698. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36699. */
  36700. pinchPrecision: number;
  36701. /**
  36702. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36703. * It will be used instead of pinchDeltaPrecision if different from 0.
  36704. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36705. */
  36706. pinchDeltaPercentage: number;
  36707. /**
  36708. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36709. */
  36710. panningSensibility: number;
  36711. /**
  36712. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36713. */
  36714. keysUp: number[];
  36715. /**
  36716. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36717. */
  36718. keysDown: number[];
  36719. /**
  36720. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36721. */
  36722. keysLeft: number[];
  36723. /**
  36724. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36725. */
  36726. keysRight: number[];
  36727. /**
  36728. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36729. */
  36730. wheelPrecision: number;
  36731. /**
  36732. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36733. * It will be used instead of pinchDeltaPrecision if different from 0.
  36734. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36735. */
  36736. wheelDeltaPercentage: number;
  36737. /**
  36738. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36739. */
  36740. zoomOnFactor: number;
  36741. /**
  36742. * Defines a screen offset for the camera position.
  36743. */
  36744. targetScreenOffset: Vector2;
  36745. /**
  36746. * Allows the camera to be completely reversed.
  36747. * If false the camera can not arrive upside down.
  36748. */
  36749. allowUpsideDown: boolean;
  36750. /**
  36751. * Define if double tap/click is used to restore the previously saved state of the camera.
  36752. */
  36753. useInputToRestoreState: boolean;
  36754. /** @hidden */
  36755. _viewMatrix: Matrix;
  36756. /** @hidden */
  36757. _useCtrlForPanning: boolean;
  36758. /** @hidden */
  36759. _panningMouseButton: number;
  36760. /**
  36761. * Defines the input associated to the camera.
  36762. */
  36763. inputs: ArcRotateCameraInputsManager;
  36764. /** @hidden */
  36765. _reset: () => void;
  36766. /**
  36767. * Defines the allowed panning axis.
  36768. */
  36769. panningAxis: Vector3;
  36770. protected _localDirection: Vector3;
  36771. protected _transformedDirection: Vector3;
  36772. private _bouncingBehavior;
  36773. /**
  36774. * Gets the bouncing behavior of the camera if it has been enabled.
  36775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36776. */
  36777. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36778. /**
  36779. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36781. */
  36782. useBouncingBehavior: boolean;
  36783. private _framingBehavior;
  36784. /**
  36785. * Gets the framing behavior of the camera if it has been enabled.
  36786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36787. */
  36788. readonly framingBehavior: Nullable<FramingBehavior>;
  36789. /**
  36790. * Defines if the framing behavior of the camera is enabled on the camera.
  36791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36792. */
  36793. useFramingBehavior: boolean;
  36794. private _autoRotationBehavior;
  36795. /**
  36796. * Gets the auto rotation behavior of the camera if it has been enabled.
  36797. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36798. */
  36799. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36800. /**
  36801. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36803. */
  36804. useAutoRotationBehavior: boolean;
  36805. /**
  36806. * Observable triggered when the mesh target has been changed on the camera.
  36807. */
  36808. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36809. /**
  36810. * Event raised when the camera is colliding with a mesh.
  36811. */
  36812. onCollide: (collidedMesh: AbstractMesh) => void;
  36813. /**
  36814. * Defines whether the camera should check collision with the objects oh the scene.
  36815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36816. */
  36817. checkCollisions: boolean;
  36818. /**
  36819. * Defines the collision radius of the camera.
  36820. * This simulates a sphere around the camera.
  36821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36822. */
  36823. collisionRadius: Vector3;
  36824. protected _collider: Collider;
  36825. protected _previousPosition: Vector3;
  36826. protected _collisionVelocity: Vector3;
  36827. protected _newPosition: Vector3;
  36828. protected _previousAlpha: number;
  36829. protected _previousBeta: number;
  36830. protected _previousRadius: number;
  36831. protected _collisionTriggered: boolean;
  36832. protected _targetBoundingCenter: Nullable<Vector3>;
  36833. private _computationVector;
  36834. /**
  36835. * Instantiates a new ArcRotateCamera in a given scene
  36836. * @param name Defines the name of the camera
  36837. * @param alpha Defines the camera rotation along the logitudinal axis
  36838. * @param beta Defines the camera rotation along the latitudinal axis
  36839. * @param radius Defines the camera distance from its target
  36840. * @param target Defines the camera target
  36841. * @param scene Defines the scene the camera belongs to
  36842. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36843. */
  36844. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36845. /** @hidden */
  36846. _initCache(): void;
  36847. /** @hidden */
  36848. _updateCache(ignoreParentClass?: boolean): void;
  36849. protected _getTargetPosition(): Vector3;
  36850. private _storedAlpha;
  36851. private _storedBeta;
  36852. private _storedRadius;
  36853. private _storedTarget;
  36854. /**
  36855. * Stores the current state of the camera (alpha, beta, radius and target)
  36856. * @returns the camera itself
  36857. */
  36858. storeState(): Camera;
  36859. /**
  36860. * @hidden
  36861. * Restored camera state. You must call storeState() first
  36862. */
  36863. _restoreStateValues(): boolean;
  36864. /** @hidden */
  36865. _isSynchronizedViewMatrix(): boolean;
  36866. /**
  36867. * Attached controls to the current camera.
  36868. * @param element Defines the element the controls should be listened from
  36869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36870. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36871. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36872. */
  36873. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36874. /**
  36875. * Detach the current controls from the camera.
  36876. * The camera will stop reacting to inputs.
  36877. * @param element Defines the element to stop listening the inputs from
  36878. */
  36879. detachControl(element: HTMLElement): void;
  36880. /** @hidden */
  36881. _checkInputs(): void;
  36882. protected _checkLimits(): void;
  36883. /**
  36884. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36885. */
  36886. rebuildAnglesAndRadius(): void;
  36887. /**
  36888. * Use a position to define the current camera related information like aplha, beta and radius
  36889. * @param position Defines the position to set the camera at
  36890. */
  36891. setPosition(position: Vector3): void;
  36892. /**
  36893. * Defines the target the camera should look at.
  36894. * This will automatically adapt alpha beta and radius to fit within the new target.
  36895. * @param target Defines the new target as a Vector or a mesh
  36896. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36897. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36898. */
  36899. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36900. /** @hidden */
  36901. _getViewMatrix(): Matrix;
  36902. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36903. /**
  36904. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36905. * @param meshes Defines the mesh to zoom on
  36906. * @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)
  36907. */
  36908. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36909. /**
  36910. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36911. * The target will be changed but the radius
  36912. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36913. * @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)
  36914. */
  36915. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36916. min: Vector3;
  36917. max: Vector3;
  36918. distance: number;
  36919. }, doNotUpdateMaxZ?: boolean): void;
  36920. /**
  36921. * @override
  36922. * Override Camera.createRigCamera
  36923. */
  36924. createRigCamera(name: string, cameraIndex: number): Camera;
  36925. /**
  36926. * @hidden
  36927. * @override
  36928. * Override Camera._updateRigCameras
  36929. */
  36930. _updateRigCameras(): void;
  36931. /**
  36932. * Destroy the camera and release the current resources hold by it.
  36933. */
  36934. dispose(): void;
  36935. /**
  36936. * Gets the current object class name.
  36937. * @return the class name
  36938. */
  36939. getClassName(): string;
  36940. }
  36941. }
  36942. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36943. import { Behavior } from "babylonjs/Behaviors/behavior";
  36944. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36945. /**
  36946. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36948. */
  36949. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36950. /**
  36951. * Gets the name of the behavior.
  36952. */
  36953. readonly name: string;
  36954. private _zoomStopsAnimation;
  36955. private _idleRotationSpeed;
  36956. private _idleRotationWaitTime;
  36957. private _idleRotationSpinupTime;
  36958. /**
  36959. * Sets the flag that indicates if user zooming should stop animation.
  36960. */
  36961. /**
  36962. * Gets the flag that indicates if user zooming should stop animation.
  36963. */
  36964. zoomStopsAnimation: boolean;
  36965. /**
  36966. * Sets the default speed at which the camera rotates around the model.
  36967. */
  36968. /**
  36969. * Gets the default speed at which the camera rotates around the model.
  36970. */
  36971. idleRotationSpeed: number;
  36972. /**
  36973. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36974. */
  36975. /**
  36976. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36977. */
  36978. idleRotationWaitTime: number;
  36979. /**
  36980. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36981. */
  36982. /**
  36983. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36984. */
  36985. idleRotationSpinupTime: number;
  36986. /**
  36987. * Gets a value indicating if the camera is currently rotating because of this behavior
  36988. */
  36989. readonly rotationInProgress: boolean;
  36990. private _onPrePointerObservableObserver;
  36991. private _onAfterCheckInputsObserver;
  36992. private _attachedCamera;
  36993. private _isPointerDown;
  36994. private _lastFrameTime;
  36995. private _lastInteractionTime;
  36996. private _cameraRotationSpeed;
  36997. /**
  36998. * Initializes the behavior.
  36999. */
  37000. init(): void;
  37001. /**
  37002. * Attaches the behavior to its arc rotate camera.
  37003. * @param camera Defines the camera to attach the behavior to
  37004. */
  37005. attach(camera: ArcRotateCamera): void;
  37006. /**
  37007. * Detaches the behavior from its current arc rotate camera.
  37008. */
  37009. detach(): void;
  37010. /**
  37011. * Returns true if user is scrolling.
  37012. * @return true if user is scrolling.
  37013. */
  37014. private _userIsZooming;
  37015. private _lastFrameRadius;
  37016. private _shouldAnimationStopForInteraction;
  37017. /**
  37018. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37019. */
  37020. private _applyUserInteraction;
  37021. private _userIsMoving;
  37022. }
  37023. }
  37024. declare module "babylonjs/Behaviors/Cameras/index" {
  37025. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37026. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37027. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37028. }
  37029. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37030. import { Mesh } from "babylonjs/Meshes/mesh";
  37031. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37032. import { Behavior } from "babylonjs/Behaviors/behavior";
  37033. /**
  37034. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37035. */
  37036. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37037. private ui;
  37038. /**
  37039. * The name of the behavior
  37040. */
  37041. name: string;
  37042. /**
  37043. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37044. */
  37045. distanceAwayFromFace: number;
  37046. /**
  37047. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37048. */
  37049. distanceAwayFromBottomOfFace: number;
  37050. private _faceVectors;
  37051. private _target;
  37052. private _scene;
  37053. private _onRenderObserver;
  37054. private _tmpMatrix;
  37055. private _tmpVector;
  37056. /**
  37057. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37058. * @param ui The transform node that should be attched to the mesh
  37059. */
  37060. constructor(ui: TransformNode);
  37061. /**
  37062. * Initializes the behavior
  37063. */
  37064. init(): void;
  37065. private _closestFace;
  37066. private _zeroVector;
  37067. private _lookAtTmpMatrix;
  37068. private _lookAtToRef;
  37069. /**
  37070. * Attaches the AttachToBoxBehavior to the passed in mesh
  37071. * @param target The mesh that the specified node will be attached to
  37072. */
  37073. attach(target: Mesh): void;
  37074. /**
  37075. * Detaches the behavior from the mesh
  37076. */
  37077. detach(): void;
  37078. }
  37079. }
  37080. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37081. import { Behavior } from "babylonjs/Behaviors/behavior";
  37082. import { Mesh } from "babylonjs/Meshes/mesh";
  37083. /**
  37084. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37085. */
  37086. export class FadeInOutBehavior implements Behavior<Mesh> {
  37087. /**
  37088. * Time in milliseconds to delay before fading in (Default: 0)
  37089. */
  37090. delay: number;
  37091. /**
  37092. * Time in milliseconds for the mesh to fade in (Default: 300)
  37093. */
  37094. fadeInTime: number;
  37095. private _millisecondsPerFrame;
  37096. private _hovered;
  37097. private _hoverValue;
  37098. private _ownerNode;
  37099. /**
  37100. * Instatiates the FadeInOutBehavior
  37101. */
  37102. constructor();
  37103. /**
  37104. * The name of the behavior
  37105. */
  37106. readonly name: string;
  37107. /**
  37108. * Initializes the behavior
  37109. */
  37110. init(): void;
  37111. /**
  37112. * Attaches the fade behavior on the passed in mesh
  37113. * @param ownerNode The mesh that will be faded in/out once attached
  37114. */
  37115. attach(ownerNode: Mesh): void;
  37116. /**
  37117. * Detaches the behavior from the mesh
  37118. */
  37119. detach(): void;
  37120. /**
  37121. * Triggers the mesh to begin fading in or out
  37122. * @param value if the object should fade in or out (true to fade in)
  37123. */
  37124. fadeIn(value: boolean): void;
  37125. private _update;
  37126. private _setAllVisibility;
  37127. }
  37128. }
  37129. declare module "babylonjs/Misc/pivotTools" {
  37130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37131. /**
  37132. * Class containing a set of static utilities functions for managing Pivots
  37133. * @hidden
  37134. */
  37135. export class PivotTools {
  37136. private static _PivotCached;
  37137. private static _OldPivotPoint;
  37138. private static _PivotTranslation;
  37139. private static _PivotTmpVector;
  37140. /** @hidden */
  37141. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37142. /** @hidden */
  37143. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37144. }
  37145. }
  37146. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37147. import { Scene } from "babylonjs/scene";
  37148. import { Vector4, Plane } from "babylonjs/Maths/math";
  37149. import { Mesh } from "babylonjs/Meshes/mesh";
  37150. import { Nullable } from "babylonjs/types";
  37151. /**
  37152. * Class containing static functions to help procedurally build meshes
  37153. */
  37154. export class PlaneBuilder {
  37155. /**
  37156. * Creates a plane mesh
  37157. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37158. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37159. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37163. * @param name defines the name of the mesh
  37164. * @param options defines the options used to create the mesh
  37165. * @param scene defines the hosting scene
  37166. * @returns the plane mesh
  37167. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37168. */
  37169. static CreatePlane(name: string, options: {
  37170. size?: number;
  37171. width?: number;
  37172. height?: number;
  37173. sideOrientation?: number;
  37174. frontUVs?: Vector4;
  37175. backUVs?: Vector4;
  37176. updatable?: boolean;
  37177. sourcePlane?: Plane;
  37178. }, scene?: Nullable<Scene>): Mesh;
  37179. }
  37180. }
  37181. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37182. import { Behavior } from "babylonjs/Behaviors/behavior";
  37183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37184. import { Observable } from "babylonjs/Misc/observable";
  37185. import { Vector3 } from "babylonjs/Maths/math";
  37186. import { Ray } from "babylonjs/Culling/ray";
  37187. import "babylonjs/Meshes/Builders/planeBuilder";
  37188. /**
  37189. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37190. */
  37191. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37192. private static _AnyMouseID;
  37193. /**
  37194. * Abstract mesh the behavior is set on
  37195. */
  37196. attachedNode: AbstractMesh;
  37197. private _dragPlane;
  37198. private _scene;
  37199. private _pointerObserver;
  37200. private _beforeRenderObserver;
  37201. private static _planeScene;
  37202. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37203. /**
  37204. * 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)
  37205. */
  37206. maxDragAngle: number;
  37207. /**
  37208. * @hidden
  37209. */
  37210. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37211. /**
  37212. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37213. */
  37214. currentDraggingPointerID: number;
  37215. /**
  37216. * The last position where the pointer hit the drag plane in world space
  37217. */
  37218. lastDragPosition: Vector3;
  37219. /**
  37220. * If the behavior is currently in a dragging state
  37221. */
  37222. dragging: boolean;
  37223. /**
  37224. * 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)
  37225. */
  37226. dragDeltaRatio: number;
  37227. /**
  37228. * If the drag plane orientation should be updated during the dragging (Default: true)
  37229. */
  37230. updateDragPlane: boolean;
  37231. private _debugMode;
  37232. private _moving;
  37233. /**
  37234. * Fires each time the attached mesh is dragged with the pointer
  37235. * * delta between last drag position and current drag position in world space
  37236. * * dragDistance along the drag axis
  37237. * * dragPlaneNormal normal of the current drag plane used during the drag
  37238. * * dragPlanePoint in world space where the drag intersects the drag plane
  37239. */
  37240. onDragObservable: Observable<{
  37241. delta: Vector3;
  37242. dragPlanePoint: Vector3;
  37243. dragPlaneNormal: Vector3;
  37244. dragDistance: number;
  37245. pointerId: number;
  37246. }>;
  37247. /**
  37248. * Fires each time a drag begins (eg. mouse down on mesh)
  37249. */
  37250. onDragStartObservable: Observable<{
  37251. dragPlanePoint: Vector3;
  37252. pointerId: number;
  37253. }>;
  37254. /**
  37255. * Fires each time a drag ends (eg. mouse release after drag)
  37256. */
  37257. onDragEndObservable: Observable<{
  37258. dragPlanePoint: Vector3;
  37259. pointerId: number;
  37260. }>;
  37261. /**
  37262. * If the attached mesh should be moved when dragged
  37263. */
  37264. moveAttached: boolean;
  37265. /**
  37266. * If the drag behavior will react to drag events (Default: true)
  37267. */
  37268. enabled: boolean;
  37269. /**
  37270. * If pointer events should start and release the drag (Default: true)
  37271. */
  37272. startAndReleaseDragOnPointerEvents: boolean;
  37273. /**
  37274. * If camera controls should be detached during the drag
  37275. */
  37276. detachCameraControls: boolean;
  37277. /**
  37278. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37279. */
  37280. useObjectOrienationForDragging: boolean;
  37281. private _options;
  37282. /**
  37283. * Creates a pointer drag behavior that can be attached to a mesh
  37284. * @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)
  37285. */
  37286. constructor(options?: {
  37287. dragAxis?: Vector3;
  37288. dragPlaneNormal?: Vector3;
  37289. });
  37290. /**
  37291. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37292. */
  37293. validateDrag: (targetPosition: Vector3) => boolean;
  37294. /**
  37295. * The name of the behavior
  37296. */
  37297. readonly name: string;
  37298. /**
  37299. * Initializes the behavior
  37300. */
  37301. init(): void;
  37302. private _tmpVector;
  37303. private _alternatePickedPoint;
  37304. private _worldDragAxis;
  37305. private _targetPosition;
  37306. private _attachedElement;
  37307. /**
  37308. * Attaches the drag behavior the passed in mesh
  37309. * @param ownerNode The mesh that will be dragged around once attached
  37310. */
  37311. attach(ownerNode: AbstractMesh): void;
  37312. /**
  37313. * Force relase the drag action by code.
  37314. */
  37315. releaseDrag(): void;
  37316. private _startDragRay;
  37317. private _lastPointerRay;
  37318. /**
  37319. * Simulates the start of a pointer drag event on the behavior
  37320. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37321. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37322. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37323. */
  37324. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37325. private _startDrag;
  37326. private _dragDelta;
  37327. private _moveDrag;
  37328. private _pickWithRayOnDragPlane;
  37329. private _pointA;
  37330. private _pointB;
  37331. private _pointC;
  37332. private _lineA;
  37333. private _lineB;
  37334. private _localAxis;
  37335. private _lookAt;
  37336. private _updateDragPlanePosition;
  37337. /**
  37338. * Detaches the behavior from the mesh
  37339. */
  37340. detach(): void;
  37341. }
  37342. }
  37343. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37344. import { Mesh } from "babylonjs/Meshes/mesh";
  37345. import { Behavior } from "babylonjs/Behaviors/behavior";
  37346. /**
  37347. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37348. */
  37349. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37350. private _dragBehaviorA;
  37351. private _dragBehaviorB;
  37352. private _startDistance;
  37353. private _initialScale;
  37354. private _targetScale;
  37355. private _ownerNode;
  37356. private _sceneRenderObserver;
  37357. /**
  37358. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37359. */
  37360. constructor();
  37361. /**
  37362. * The name of the behavior
  37363. */
  37364. readonly name: string;
  37365. /**
  37366. * Initializes the behavior
  37367. */
  37368. init(): void;
  37369. private _getCurrentDistance;
  37370. /**
  37371. * Attaches the scale behavior the passed in mesh
  37372. * @param ownerNode The mesh that will be scaled around once attached
  37373. */
  37374. attach(ownerNode: Mesh): void;
  37375. /**
  37376. * Detaches the behavior from the mesh
  37377. */
  37378. detach(): void;
  37379. }
  37380. }
  37381. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37382. import { Behavior } from "babylonjs/Behaviors/behavior";
  37383. import { Mesh } from "babylonjs/Meshes/mesh";
  37384. import { Observable } from "babylonjs/Misc/observable";
  37385. /**
  37386. * 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
  37387. */
  37388. export class SixDofDragBehavior implements Behavior<Mesh> {
  37389. private static _virtualScene;
  37390. private _ownerNode;
  37391. private _sceneRenderObserver;
  37392. private _scene;
  37393. private _targetPosition;
  37394. private _virtualOriginMesh;
  37395. private _virtualDragMesh;
  37396. private _pointerObserver;
  37397. private _moving;
  37398. private _startingOrientation;
  37399. /**
  37400. * 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)
  37401. */
  37402. private zDragFactor;
  37403. /**
  37404. * If the object should rotate to face the drag origin
  37405. */
  37406. rotateDraggedObject: boolean;
  37407. /**
  37408. * If the behavior is currently in a dragging state
  37409. */
  37410. dragging: boolean;
  37411. /**
  37412. * 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)
  37413. */
  37414. dragDeltaRatio: number;
  37415. /**
  37416. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37417. */
  37418. currentDraggingPointerID: number;
  37419. /**
  37420. * If camera controls should be detached during the drag
  37421. */
  37422. detachCameraControls: boolean;
  37423. /**
  37424. * Fires each time a drag starts
  37425. */
  37426. onDragStartObservable: Observable<{}>;
  37427. /**
  37428. * Fires each time a drag ends (eg. mouse release after drag)
  37429. */
  37430. onDragEndObservable: Observable<{}>;
  37431. /**
  37432. * 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
  37433. */
  37434. constructor();
  37435. /**
  37436. * The name of the behavior
  37437. */
  37438. readonly name: string;
  37439. /**
  37440. * Initializes the behavior
  37441. */
  37442. init(): void;
  37443. /**
  37444. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37445. */
  37446. private readonly _pointerCamera;
  37447. /**
  37448. * Attaches the scale behavior the passed in mesh
  37449. * @param ownerNode The mesh that will be scaled around once attached
  37450. */
  37451. attach(ownerNode: Mesh): void;
  37452. /**
  37453. * Detaches the behavior from the mesh
  37454. */
  37455. detach(): void;
  37456. }
  37457. }
  37458. declare module "babylonjs/Behaviors/Meshes/index" {
  37459. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37460. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37461. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37462. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37463. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37464. }
  37465. declare module "babylonjs/Behaviors/index" {
  37466. export * from "babylonjs/Behaviors/behavior";
  37467. export * from "babylonjs/Behaviors/Cameras/index";
  37468. export * from "babylonjs/Behaviors/Meshes/index";
  37469. }
  37470. declare module "babylonjs/Bones/boneIKController" {
  37471. import { Bone } from "babylonjs/Bones/bone";
  37472. import { Vector3 } from "babylonjs/Maths/math";
  37473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37474. import { Nullable } from "babylonjs/types";
  37475. /**
  37476. * Class used to apply inverse kinematics to bones
  37477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37478. */
  37479. export class BoneIKController {
  37480. private static _tmpVecs;
  37481. private static _tmpQuat;
  37482. private static _tmpMats;
  37483. /**
  37484. * Gets or sets the target mesh
  37485. */
  37486. targetMesh: AbstractMesh;
  37487. /** Gets or sets the mesh used as pole */
  37488. poleTargetMesh: AbstractMesh;
  37489. /**
  37490. * Gets or sets the bone used as pole
  37491. */
  37492. poleTargetBone: Nullable<Bone>;
  37493. /**
  37494. * Gets or sets the target position
  37495. */
  37496. targetPosition: Vector3;
  37497. /**
  37498. * Gets or sets the pole target position
  37499. */
  37500. poleTargetPosition: Vector3;
  37501. /**
  37502. * Gets or sets the pole target local offset
  37503. */
  37504. poleTargetLocalOffset: Vector3;
  37505. /**
  37506. * Gets or sets the pole angle
  37507. */
  37508. poleAngle: number;
  37509. /**
  37510. * Gets or sets the mesh associated with the controller
  37511. */
  37512. mesh: AbstractMesh;
  37513. /**
  37514. * 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)
  37515. */
  37516. slerpAmount: number;
  37517. private _bone1Quat;
  37518. private _bone1Mat;
  37519. private _bone2Ang;
  37520. private _bone1;
  37521. private _bone2;
  37522. private _bone1Length;
  37523. private _bone2Length;
  37524. private _maxAngle;
  37525. private _maxReach;
  37526. private _rightHandedSystem;
  37527. private _bendAxis;
  37528. private _slerping;
  37529. private _adjustRoll;
  37530. /**
  37531. * Gets or sets maximum allowed angle
  37532. */
  37533. maxAngle: number;
  37534. /**
  37535. * Creates a new BoneIKController
  37536. * @param mesh defines the mesh to control
  37537. * @param bone defines the bone to control
  37538. * @param options defines options to set up the controller
  37539. */
  37540. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37541. targetMesh?: AbstractMesh;
  37542. poleTargetMesh?: AbstractMesh;
  37543. poleTargetBone?: Bone;
  37544. poleTargetLocalOffset?: Vector3;
  37545. poleAngle?: number;
  37546. bendAxis?: Vector3;
  37547. maxAngle?: number;
  37548. slerpAmount?: number;
  37549. });
  37550. private _setMaxAngle;
  37551. /**
  37552. * Force the controller to update the bones
  37553. */
  37554. update(): void;
  37555. }
  37556. }
  37557. declare module "babylonjs/Bones/boneLookController" {
  37558. import { Vector3, Space } from "babylonjs/Maths/math";
  37559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37560. import { Bone } from "babylonjs/Bones/bone";
  37561. /**
  37562. * Class used to make a bone look toward a point in space
  37563. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37564. */
  37565. export class BoneLookController {
  37566. private static _tmpVecs;
  37567. private static _tmpQuat;
  37568. private static _tmpMats;
  37569. /**
  37570. * The target Vector3 that the bone will look at
  37571. */
  37572. target: Vector3;
  37573. /**
  37574. * The mesh that the bone is attached to
  37575. */
  37576. mesh: AbstractMesh;
  37577. /**
  37578. * The bone that will be looking to the target
  37579. */
  37580. bone: Bone;
  37581. /**
  37582. * The up axis of the coordinate system that is used when the bone is rotated
  37583. */
  37584. upAxis: Vector3;
  37585. /**
  37586. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37587. */
  37588. upAxisSpace: Space;
  37589. /**
  37590. * Used to make an adjustment to the yaw of the bone
  37591. */
  37592. adjustYaw: number;
  37593. /**
  37594. * Used to make an adjustment to the pitch of the bone
  37595. */
  37596. adjustPitch: number;
  37597. /**
  37598. * Used to make an adjustment to the roll of the bone
  37599. */
  37600. adjustRoll: number;
  37601. /**
  37602. * 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)
  37603. */
  37604. slerpAmount: number;
  37605. private _minYaw;
  37606. private _maxYaw;
  37607. private _minPitch;
  37608. private _maxPitch;
  37609. private _minYawSin;
  37610. private _minYawCos;
  37611. private _maxYawSin;
  37612. private _maxYawCos;
  37613. private _midYawConstraint;
  37614. private _minPitchTan;
  37615. private _maxPitchTan;
  37616. private _boneQuat;
  37617. private _slerping;
  37618. private _transformYawPitch;
  37619. private _transformYawPitchInv;
  37620. private _firstFrameSkipped;
  37621. private _yawRange;
  37622. private _fowardAxis;
  37623. /**
  37624. * Gets or sets the minimum yaw angle that the bone can look to
  37625. */
  37626. minYaw: number;
  37627. /**
  37628. * Gets or sets the maximum yaw angle that the bone can look to
  37629. */
  37630. maxYaw: number;
  37631. /**
  37632. * Gets or sets the minimum pitch angle that the bone can look to
  37633. */
  37634. minPitch: number;
  37635. /**
  37636. * Gets or sets the maximum pitch angle that the bone can look to
  37637. */
  37638. maxPitch: number;
  37639. /**
  37640. * Create a BoneLookController
  37641. * @param mesh the mesh that the bone belongs to
  37642. * @param bone the bone that will be looking to the target
  37643. * @param target the target Vector3 to look at
  37644. * @param options optional settings:
  37645. * * maxYaw: the maximum angle the bone will yaw to
  37646. * * minYaw: the minimum angle the bone will yaw to
  37647. * * maxPitch: the maximum angle the bone will pitch to
  37648. * * minPitch: the minimum angle the bone will yaw to
  37649. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37650. * * upAxis: the up axis of the coordinate system
  37651. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37652. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37653. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37654. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37655. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37656. * * adjustRoll: used to make an adjustment to the roll of the bone
  37657. **/
  37658. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37659. maxYaw?: number;
  37660. minYaw?: number;
  37661. maxPitch?: number;
  37662. minPitch?: number;
  37663. slerpAmount?: number;
  37664. upAxis?: Vector3;
  37665. upAxisSpace?: Space;
  37666. yawAxis?: Vector3;
  37667. pitchAxis?: Vector3;
  37668. adjustYaw?: number;
  37669. adjustPitch?: number;
  37670. adjustRoll?: number;
  37671. });
  37672. /**
  37673. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37674. */
  37675. update(): void;
  37676. private _getAngleDiff;
  37677. private _getAngleBetween;
  37678. private _isAngleBetween;
  37679. }
  37680. }
  37681. declare module "babylonjs/Bones/index" {
  37682. export * from "babylonjs/Bones/bone";
  37683. export * from "babylonjs/Bones/boneIKController";
  37684. export * from "babylonjs/Bones/boneLookController";
  37685. export * from "babylonjs/Bones/skeleton";
  37686. }
  37687. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37688. import { Nullable } from "babylonjs/types";
  37689. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37690. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37691. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37692. /**
  37693. * Manage the gamepad inputs to control an arc rotate camera.
  37694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37695. */
  37696. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37697. /**
  37698. * Defines the camera the input is attached to.
  37699. */
  37700. camera: ArcRotateCamera;
  37701. /**
  37702. * Defines the gamepad the input is gathering event from.
  37703. */
  37704. gamepad: Nullable<Gamepad>;
  37705. /**
  37706. * Defines the gamepad rotation sensiblity.
  37707. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37708. */
  37709. gamepadRotationSensibility: number;
  37710. /**
  37711. * Defines the gamepad move sensiblity.
  37712. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37713. */
  37714. gamepadMoveSensibility: number;
  37715. private _onGamepadConnectedObserver;
  37716. private _onGamepadDisconnectedObserver;
  37717. /**
  37718. * Attach the input controls to a specific dom element to get the input from.
  37719. * @param element Defines the element the controls should be listened from
  37720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37721. */
  37722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37723. /**
  37724. * Detach the current controls from the specified dom element.
  37725. * @param element Defines the element to stop listening the inputs from
  37726. */
  37727. detachControl(element: Nullable<HTMLElement>): void;
  37728. /**
  37729. * Update the current camera state depending on the inputs that have been used this frame.
  37730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37731. */
  37732. checkInputs(): void;
  37733. /**
  37734. * Gets the class name of the current intput.
  37735. * @returns the class name
  37736. */
  37737. getClassName(): string;
  37738. /**
  37739. * Get the friendly name associated with the input class.
  37740. * @returns the input friendly name
  37741. */
  37742. getSimpleName(): string;
  37743. }
  37744. }
  37745. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37746. import { Nullable } from "babylonjs/types";
  37747. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37749. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37750. interface ArcRotateCameraInputsManager {
  37751. /**
  37752. * Add orientation input support to the input manager.
  37753. * @returns the current input manager
  37754. */
  37755. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37756. }
  37757. }
  37758. /**
  37759. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37761. */
  37762. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37763. /**
  37764. * Defines the camera the input is attached to.
  37765. */
  37766. camera: ArcRotateCamera;
  37767. /**
  37768. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37769. */
  37770. alphaCorrection: number;
  37771. /**
  37772. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37773. */
  37774. gammaCorrection: number;
  37775. private _alpha;
  37776. private _gamma;
  37777. private _dirty;
  37778. private _deviceOrientationHandler;
  37779. /**
  37780. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37781. */
  37782. constructor();
  37783. /**
  37784. * Attach the input controls to a specific dom element to get the input from.
  37785. * @param element Defines the element the controls should be listened from
  37786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37787. */
  37788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37789. /** @hidden */
  37790. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37791. /**
  37792. * Update the current camera state depending on the inputs that have been used this frame.
  37793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37794. */
  37795. checkInputs(): void;
  37796. /**
  37797. * Detach the current controls from the specified dom element.
  37798. * @param element Defines the element to stop listening the inputs from
  37799. */
  37800. detachControl(element: Nullable<HTMLElement>): void;
  37801. /**
  37802. * Gets the class name of the current intput.
  37803. * @returns the class name
  37804. */
  37805. getClassName(): string;
  37806. /**
  37807. * Get the friendly name associated with the input class.
  37808. * @returns the input friendly name
  37809. */
  37810. getSimpleName(): string;
  37811. }
  37812. }
  37813. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37814. import { Nullable } from "babylonjs/types";
  37815. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37816. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37817. /**
  37818. * Listen to mouse events to control the camera.
  37819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37820. */
  37821. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37822. /**
  37823. * Defines the camera the input is attached to.
  37824. */
  37825. camera: FlyCamera;
  37826. /**
  37827. * Defines if touch is enabled. (Default is true.)
  37828. */
  37829. touchEnabled: boolean;
  37830. /**
  37831. * Defines the buttons associated with the input to handle camera rotation.
  37832. */
  37833. buttons: number[];
  37834. /**
  37835. * Assign buttons for Yaw control.
  37836. */
  37837. buttonsYaw: number[];
  37838. /**
  37839. * Assign buttons for Pitch control.
  37840. */
  37841. buttonsPitch: number[];
  37842. /**
  37843. * Assign buttons for Roll control.
  37844. */
  37845. buttonsRoll: number[];
  37846. /**
  37847. * Detect if any button is being pressed while mouse is moved.
  37848. * -1 = Mouse locked.
  37849. * 0 = Left button.
  37850. * 1 = Middle Button.
  37851. * 2 = Right Button.
  37852. */
  37853. activeButton: number;
  37854. /**
  37855. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37856. * Higher values reduce its sensitivity.
  37857. */
  37858. angularSensibility: number;
  37859. private _mousemoveCallback;
  37860. private _observer;
  37861. private _rollObserver;
  37862. private previousPosition;
  37863. private noPreventDefault;
  37864. private element;
  37865. /**
  37866. * Listen to mouse events to control the camera.
  37867. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37869. */
  37870. constructor(touchEnabled?: boolean);
  37871. /**
  37872. * Attach the mouse control to the HTML DOM element.
  37873. * @param element Defines the element that listens to the input events.
  37874. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37875. */
  37876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37877. /**
  37878. * Detach the current controls from the specified dom element.
  37879. * @param element Defines the element to stop listening the inputs from
  37880. */
  37881. detachControl(element: Nullable<HTMLElement>): void;
  37882. /**
  37883. * Gets the class name of the current input.
  37884. * @returns the class name.
  37885. */
  37886. getClassName(): string;
  37887. /**
  37888. * Get the friendly name associated with the input class.
  37889. * @returns the input's friendly name.
  37890. */
  37891. getSimpleName(): string;
  37892. private _pointerInput;
  37893. private _onMouseMove;
  37894. /**
  37895. * Rotate camera by mouse offset.
  37896. */
  37897. private rotateCamera;
  37898. }
  37899. }
  37900. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37901. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37902. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37903. /**
  37904. * Default Inputs manager for the FlyCamera.
  37905. * It groups all the default supported inputs for ease of use.
  37906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37907. */
  37908. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37909. /**
  37910. * Instantiates a new FlyCameraInputsManager.
  37911. * @param camera Defines the camera the inputs belong to.
  37912. */
  37913. constructor(camera: FlyCamera);
  37914. /**
  37915. * Add keyboard input support to the input manager.
  37916. * @returns the new FlyCameraKeyboardMoveInput().
  37917. */
  37918. addKeyboard(): FlyCameraInputsManager;
  37919. /**
  37920. * Add mouse input support to the input manager.
  37921. * @param touchEnabled Enable touch screen support.
  37922. * @returns the new FlyCameraMouseInput().
  37923. */
  37924. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37925. }
  37926. }
  37927. declare module "babylonjs/Cameras/flyCamera" {
  37928. import { Scene } from "babylonjs/scene";
  37929. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37931. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37932. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37933. /**
  37934. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37935. * such as in a 3D Space Shooter or a Flight Simulator.
  37936. */
  37937. export class FlyCamera extends TargetCamera {
  37938. /**
  37939. * Define the collision ellipsoid of the camera.
  37940. * This is helpful for simulating a camera body, like a player's body.
  37941. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37942. */
  37943. ellipsoid: Vector3;
  37944. /**
  37945. * Define an offset for the position of the ellipsoid around the camera.
  37946. * This can be helpful if the camera is attached away from the player's body center,
  37947. * such as at its head.
  37948. */
  37949. ellipsoidOffset: Vector3;
  37950. /**
  37951. * Enable or disable collisions of the camera with the rest of the scene objects.
  37952. */
  37953. checkCollisions: boolean;
  37954. /**
  37955. * Enable or disable gravity on the camera.
  37956. */
  37957. applyGravity: boolean;
  37958. /**
  37959. * Define the current direction the camera is moving to.
  37960. */
  37961. cameraDirection: Vector3;
  37962. /**
  37963. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37964. * This overrides and empties cameraRotation.
  37965. */
  37966. rotationQuaternion: Quaternion;
  37967. /**
  37968. * Track Roll to maintain the wanted Rolling when looking around.
  37969. */
  37970. _trackRoll: number;
  37971. /**
  37972. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37973. */
  37974. rollCorrect: number;
  37975. /**
  37976. * Mimic a banked turn, Rolling the camera when Yawing.
  37977. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37978. */
  37979. bankedTurn: boolean;
  37980. /**
  37981. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37982. */
  37983. bankedTurnLimit: number;
  37984. /**
  37985. * Value of 0 disables the banked Roll.
  37986. * Value of 1 is equal to the Yaw angle in radians.
  37987. */
  37988. bankedTurnMultiplier: number;
  37989. /**
  37990. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37991. */
  37992. inputs: FlyCameraInputsManager;
  37993. /**
  37994. * Gets the input sensibility for mouse input.
  37995. * Higher values reduce sensitivity.
  37996. */
  37997. /**
  37998. * Sets the input sensibility for a mouse input.
  37999. * Higher values reduce sensitivity.
  38000. */
  38001. angularSensibility: number;
  38002. /**
  38003. * Get the keys for camera movement forward.
  38004. */
  38005. /**
  38006. * Set the keys for camera movement forward.
  38007. */
  38008. keysForward: number[];
  38009. /**
  38010. * Get the keys for camera movement backward.
  38011. */
  38012. keysBackward: number[];
  38013. /**
  38014. * Get the keys for camera movement up.
  38015. */
  38016. /**
  38017. * Set the keys for camera movement up.
  38018. */
  38019. keysUp: number[];
  38020. /**
  38021. * Get the keys for camera movement down.
  38022. */
  38023. /**
  38024. * Set the keys for camera movement down.
  38025. */
  38026. keysDown: number[];
  38027. /**
  38028. * Get the keys for camera movement left.
  38029. */
  38030. /**
  38031. * Set the keys for camera movement left.
  38032. */
  38033. keysLeft: number[];
  38034. /**
  38035. * Set the keys for camera movement right.
  38036. */
  38037. /**
  38038. * Set the keys for camera movement right.
  38039. */
  38040. keysRight: number[];
  38041. /**
  38042. * Event raised when the camera collides with a mesh in the scene.
  38043. */
  38044. onCollide: (collidedMesh: AbstractMesh) => void;
  38045. private _collider;
  38046. private _needMoveForGravity;
  38047. private _oldPosition;
  38048. private _diffPosition;
  38049. private _newPosition;
  38050. /** @hidden */
  38051. _localDirection: Vector3;
  38052. /** @hidden */
  38053. _transformedDirection: Vector3;
  38054. /**
  38055. * Instantiates a FlyCamera.
  38056. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38057. * such as in a 3D Space Shooter or a Flight Simulator.
  38058. * @param name Define the name of the camera in the scene.
  38059. * @param position Define the starting position of the camera in the scene.
  38060. * @param scene Define the scene the camera belongs to.
  38061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38062. */
  38063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38064. /**
  38065. * Attach a control to the HTML DOM element.
  38066. * @param element Defines the element that listens to the input events.
  38067. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38068. */
  38069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38070. /**
  38071. * Detach a control from the HTML DOM element.
  38072. * The camera will stop reacting to that input.
  38073. * @param element Defines the element that listens to the input events.
  38074. */
  38075. detachControl(element: HTMLElement): void;
  38076. private _collisionMask;
  38077. /**
  38078. * Get the mask that the camera ignores in collision events.
  38079. */
  38080. /**
  38081. * Set the mask that the camera ignores in collision events.
  38082. */
  38083. collisionMask: number;
  38084. /** @hidden */
  38085. _collideWithWorld(displacement: Vector3): void;
  38086. /** @hidden */
  38087. private _onCollisionPositionChange;
  38088. /** @hidden */
  38089. _checkInputs(): void;
  38090. /** @hidden */
  38091. _decideIfNeedsToMove(): boolean;
  38092. /** @hidden */
  38093. _updatePosition(): void;
  38094. /**
  38095. * Restore the Roll to its target value at the rate specified.
  38096. * @param rate - Higher means slower restoring.
  38097. * @hidden
  38098. */
  38099. restoreRoll(rate: number): void;
  38100. /**
  38101. * Destroy the camera and release the current resources held by it.
  38102. */
  38103. dispose(): void;
  38104. /**
  38105. * Get the current object class name.
  38106. * @returns the class name.
  38107. */
  38108. getClassName(): string;
  38109. }
  38110. }
  38111. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38112. import { Nullable } from "babylonjs/types";
  38113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38114. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38115. /**
  38116. * Listen to keyboard events to control the camera.
  38117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38118. */
  38119. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38120. /**
  38121. * Defines the camera the input is attached to.
  38122. */
  38123. camera: FlyCamera;
  38124. /**
  38125. * The list of keyboard keys used to control the forward move of the camera.
  38126. */
  38127. keysForward: number[];
  38128. /**
  38129. * The list of keyboard keys used to control the backward move of the camera.
  38130. */
  38131. keysBackward: number[];
  38132. /**
  38133. * The list of keyboard keys used to control the forward move of the camera.
  38134. */
  38135. keysUp: number[];
  38136. /**
  38137. * The list of keyboard keys used to control the backward move of the camera.
  38138. */
  38139. keysDown: number[];
  38140. /**
  38141. * The list of keyboard keys used to control the right strafe move of the camera.
  38142. */
  38143. keysRight: number[];
  38144. /**
  38145. * The list of keyboard keys used to control the left strafe move of the camera.
  38146. */
  38147. keysLeft: number[];
  38148. private _keys;
  38149. private _onCanvasBlurObserver;
  38150. private _onKeyboardObserver;
  38151. private _engine;
  38152. private _scene;
  38153. /**
  38154. * Attach the input controls to a specific dom element to get the input from.
  38155. * @param element Defines the element the controls should be listened from
  38156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38157. */
  38158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38159. /**
  38160. * Detach the current controls from the specified dom element.
  38161. * @param element Defines the element to stop listening the inputs from
  38162. */
  38163. detachControl(element: Nullable<HTMLElement>): void;
  38164. /**
  38165. * Gets the class name of the current intput.
  38166. * @returns the class name
  38167. */
  38168. getClassName(): string;
  38169. /** @hidden */
  38170. _onLostFocus(e: FocusEvent): void;
  38171. /**
  38172. * Get the friendly name associated with the input class.
  38173. * @returns the input friendly name
  38174. */
  38175. getSimpleName(): string;
  38176. /**
  38177. * Update the current camera state depending on the inputs that have been used this frame.
  38178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38179. */
  38180. checkInputs(): void;
  38181. }
  38182. }
  38183. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38184. import { Nullable } from "babylonjs/types";
  38185. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38187. /**
  38188. * Manage the mouse wheel inputs to control a follow camera.
  38189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38190. */
  38191. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38192. /**
  38193. * Defines the camera the input is attached to.
  38194. */
  38195. camera: FollowCamera;
  38196. /**
  38197. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38198. */
  38199. axisControlRadius: boolean;
  38200. /**
  38201. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38202. */
  38203. axisControlHeight: boolean;
  38204. /**
  38205. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38206. */
  38207. axisControlRotation: boolean;
  38208. /**
  38209. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38210. * relation to mouseWheel events.
  38211. */
  38212. wheelPrecision: number;
  38213. /**
  38214. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38215. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38216. */
  38217. wheelDeltaPercentage: number;
  38218. private _wheel;
  38219. private _observer;
  38220. /**
  38221. * Attach the input controls to a specific dom element to get the input from.
  38222. * @param element Defines the element the controls should be listened from
  38223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38224. */
  38225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38226. /**
  38227. * Detach the current controls from the specified dom element.
  38228. * @param element Defines the element to stop listening the inputs from
  38229. */
  38230. detachControl(element: Nullable<HTMLElement>): void;
  38231. /**
  38232. * Gets the class name of the current intput.
  38233. * @returns the class name
  38234. */
  38235. getClassName(): string;
  38236. /**
  38237. * Get the friendly name associated with the input class.
  38238. * @returns the input friendly name
  38239. */
  38240. getSimpleName(): string;
  38241. }
  38242. }
  38243. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38244. import { Nullable } from "babylonjs/types";
  38245. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38246. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38247. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38248. /**
  38249. * Manage the pointers inputs to control an follow camera.
  38250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38251. */
  38252. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38253. /**
  38254. * Defines the camera the input is attached to.
  38255. */
  38256. camera: FollowCamera;
  38257. /**
  38258. * Gets the class name of the current input.
  38259. * @returns the class name
  38260. */
  38261. getClassName(): string;
  38262. /**
  38263. * Defines the pointer angular sensibility along the X axis or how fast is
  38264. * the camera rotating.
  38265. * A negative number will reverse the axis direction.
  38266. */
  38267. angularSensibilityX: number;
  38268. /**
  38269. * Defines the pointer angular sensibility along the Y axis or how fast is
  38270. * the camera rotating.
  38271. * A negative number will reverse the axis direction.
  38272. */
  38273. angularSensibilityY: number;
  38274. /**
  38275. * Defines the pointer pinch precision or how fast is the camera zooming.
  38276. * A negative number will reverse the axis direction.
  38277. */
  38278. pinchPrecision: number;
  38279. /**
  38280. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38281. * from 0.
  38282. * It defines the percentage of current camera.radius to use as delta when
  38283. * pinch zoom is used.
  38284. */
  38285. pinchDeltaPercentage: number;
  38286. /**
  38287. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38288. */
  38289. axisXControlRadius: boolean;
  38290. /**
  38291. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38292. */
  38293. axisXControlHeight: boolean;
  38294. /**
  38295. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38296. */
  38297. axisXControlRotation: boolean;
  38298. /**
  38299. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38300. */
  38301. axisYControlRadius: boolean;
  38302. /**
  38303. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38304. */
  38305. axisYControlHeight: boolean;
  38306. /**
  38307. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38308. */
  38309. axisYControlRotation: boolean;
  38310. /**
  38311. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38312. */
  38313. axisPinchControlRadius: boolean;
  38314. /**
  38315. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38316. */
  38317. axisPinchControlHeight: boolean;
  38318. /**
  38319. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38320. */
  38321. axisPinchControlRotation: boolean;
  38322. /**
  38323. * Log error messages if basic misconfiguration has occurred.
  38324. */
  38325. warningEnable: boolean;
  38326. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38327. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38328. private _warningCounter;
  38329. private _warning;
  38330. }
  38331. }
  38332. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38333. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38334. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38335. /**
  38336. * Default Inputs manager for the FollowCamera.
  38337. * It groups all the default supported inputs for ease of use.
  38338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38339. */
  38340. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38341. /**
  38342. * Instantiates a new FollowCameraInputsManager.
  38343. * @param camera Defines the camera the inputs belong to
  38344. */
  38345. constructor(camera: FollowCamera);
  38346. /**
  38347. * Add keyboard input support to the input manager.
  38348. * @returns the current input manager
  38349. */
  38350. addKeyboard(): FollowCameraInputsManager;
  38351. /**
  38352. * Add mouse wheel input support to the input manager.
  38353. * @returns the current input manager
  38354. */
  38355. addMouseWheel(): FollowCameraInputsManager;
  38356. /**
  38357. * Add pointers input support to the input manager.
  38358. * @returns the current input manager
  38359. */
  38360. addPointers(): FollowCameraInputsManager;
  38361. /**
  38362. * Add orientation input support to the input manager.
  38363. * @returns the current input manager
  38364. */
  38365. addVRDeviceOrientation(): FollowCameraInputsManager;
  38366. }
  38367. }
  38368. declare module "babylonjs/Cameras/followCamera" {
  38369. import { Nullable } from "babylonjs/types";
  38370. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38371. import { Scene } from "babylonjs/scene";
  38372. import { Vector3 } from "babylonjs/Maths/math";
  38373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38374. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38375. /**
  38376. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38377. * an arc rotate version arcFollowCamera are available.
  38378. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38379. */
  38380. export class FollowCamera extends TargetCamera {
  38381. /**
  38382. * Distance the follow camera should follow an object at
  38383. */
  38384. radius: number;
  38385. /**
  38386. * Minimum allowed distance of the camera to the axis of rotation
  38387. * (The camera can not get closer).
  38388. * This can help limiting how the Camera is able to move in the scene.
  38389. */
  38390. lowerRadiusLimit: Nullable<number>;
  38391. /**
  38392. * Maximum allowed distance of the camera to the axis of rotation
  38393. * (The camera can not get further).
  38394. * This can help limiting how the Camera is able to move in the scene.
  38395. */
  38396. upperRadiusLimit: Nullable<number>;
  38397. /**
  38398. * Define a rotation offset between the camera and the object it follows
  38399. */
  38400. rotationOffset: number;
  38401. /**
  38402. * Minimum allowed angle to camera position relative to target object.
  38403. * This can help limiting how the Camera is able to move in the scene.
  38404. */
  38405. lowerRotationOffsetLimit: Nullable<number>;
  38406. /**
  38407. * Maximum allowed angle to camera position relative to target object.
  38408. * This can help limiting how the Camera is able to move in the scene.
  38409. */
  38410. upperRotationOffsetLimit: Nullable<number>;
  38411. /**
  38412. * Define a height offset between the camera and the object it follows.
  38413. * It can help following an object from the top (like a car chaing a plane)
  38414. */
  38415. heightOffset: number;
  38416. /**
  38417. * Minimum allowed height of camera position relative to target object.
  38418. * This can help limiting how the Camera is able to move in the scene.
  38419. */
  38420. lowerHeightOffsetLimit: Nullable<number>;
  38421. /**
  38422. * Maximum allowed height of camera position relative to target object.
  38423. * This can help limiting how the Camera is able to move in the scene.
  38424. */
  38425. upperHeightOffsetLimit: Nullable<number>;
  38426. /**
  38427. * Define how fast the camera can accelerate to follow it s target.
  38428. */
  38429. cameraAcceleration: number;
  38430. /**
  38431. * Define the speed limit of the camera following an object.
  38432. */
  38433. maxCameraSpeed: number;
  38434. /**
  38435. * Define the target of the camera.
  38436. */
  38437. lockedTarget: Nullable<AbstractMesh>;
  38438. /**
  38439. * Defines the input associated with the camera.
  38440. */
  38441. inputs: FollowCameraInputsManager;
  38442. /**
  38443. * Instantiates the follow camera.
  38444. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38445. * @param name Define the name of the camera in the scene
  38446. * @param position Define the position of the camera
  38447. * @param scene Define the scene the camera belong to
  38448. * @param lockedTarget Define the target of the camera
  38449. */
  38450. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38451. private _follow;
  38452. /**
  38453. * Attached controls to the current camera.
  38454. * @param element Defines the element the controls should be listened from
  38455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38456. */
  38457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38458. /**
  38459. * Detach the current controls from the camera.
  38460. * The camera will stop reacting to inputs.
  38461. * @param element Defines the element to stop listening the inputs from
  38462. */
  38463. detachControl(element: HTMLElement): void;
  38464. /** @hidden */
  38465. _checkInputs(): void;
  38466. private _checkLimits;
  38467. /**
  38468. * Gets the camera class name.
  38469. * @returns the class name
  38470. */
  38471. getClassName(): string;
  38472. }
  38473. /**
  38474. * Arc Rotate version of the follow camera.
  38475. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38476. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38477. */
  38478. export class ArcFollowCamera extends TargetCamera {
  38479. /** The longitudinal angle of the camera */
  38480. alpha: number;
  38481. /** The latitudinal angle of the camera */
  38482. beta: number;
  38483. /** The radius of the camera from its target */
  38484. radius: number;
  38485. /** Define the camera target (the messh it should follow) */
  38486. target: Nullable<AbstractMesh>;
  38487. private _cartesianCoordinates;
  38488. /**
  38489. * Instantiates a new ArcFollowCamera
  38490. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38491. * @param name Define the name of the camera
  38492. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38493. * @param beta Define the rotation angle of the camera around the elevation axis
  38494. * @param radius Define the radius of the camera from its target point
  38495. * @param target Define the target of the camera
  38496. * @param scene Define the scene the camera belongs to
  38497. */
  38498. constructor(name: string,
  38499. /** The longitudinal angle of the camera */
  38500. alpha: number,
  38501. /** The latitudinal angle of the camera */
  38502. beta: number,
  38503. /** The radius of the camera from its target */
  38504. radius: number,
  38505. /** Define the camera target (the messh it should follow) */
  38506. target: Nullable<AbstractMesh>, scene: Scene);
  38507. private _follow;
  38508. /** @hidden */
  38509. _checkInputs(): void;
  38510. /**
  38511. * Returns the class name of the object.
  38512. * It is mostly used internally for serialization purposes.
  38513. */
  38514. getClassName(): string;
  38515. }
  38516. }
  38517. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38518. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38519. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38520. import { Nullable } from "babylonjs/types";
  38521. /**
  38522. * Manage the keyboard inputs to control the movement of a follow camera.
  38523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38524. */
  38525. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38526. /**
  38527. * Defines the camera the input is attached to.
  38528. */
  38529. camera: FollowCamera;
  38530. /**
  38531. * Defines the list of key codes associated with the up action (increase heightOffset)
  38532. */
  38533. keysHeightOffsetIncr: number[];
  38534. /**
  38535. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38536. */
  38537. keysHeightOffsetDecr: number[];
  38538. /**
  38539. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38540. */
  38541. keysHeightOffsetModifierAlt: boolean;
  38542. /**
  38543. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38544. */
  38545. keysHeightOffsetModifierCtrl: boolean;
  38546. /**
  38547. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38548. */
  38549. keysHeightOffsetModifierShift: boolean;
  38550. /**
  38551. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38552. */
  38553. keysRotationOffsetIncr: number[];
  38554. /**
  38555. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38556. */
  38557. keysRotationOffsetDecr: number[];
  38558. /**
  38559. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38560. */
  38561. keysRotationOffsetModifierAlt: boolean;
  38562. /**
  38563. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38564. */
  38565. keysRotationOffsetModifierCtrl: boolean;
  38566. /**
  38567. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38568. */
  38569. keysRotationOffsetModifierShift: boolean;
  38570. /**
  38571. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38572. */
  38573. keysRadiusIncr: number[];
  38574. /**
  38575. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38576. */
  38577. keysRadiusDecr: number[];
  38578. /**
  38579. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38580. */
  38581. keysRadiusModifierAlt: boolean;
  38582. /**
  38583. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38584. */
  38585. keysRadiusModifierCtrl: boolean;
  38586. /**
  38587. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38588. */
  38589. keysRadiusModifierShift: boolean;
  38590. /**
  38591. * Defines the rate of change of heightOffset.
  38592. */
  38593. heightSensibility: number;
  38594. /**
  38595. * Defines the rate of change of rotationOffset.
  38596. */
  38597. rotationSensibility: number;
  38598. /**
  38599. * Defines the rate of change of radius.
  38600. */
  38601. radiusSensibility: number;
  38602. private _keys;
  38603. private _ctrlPressed;
  38604. private _altPressed;
  38605. private _shiftPressed;
  38606. private _onCanvasBlurObserver;
  38607. private _onKeyboardObserver;
  38608. private _engine;
  38609. private _scene;
  38610. /**
  38611. * Attach the input controls to a specific dom element to get the input from.
  38612. * @param element Defines the element the controls should be listened from
  38613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38614. */
  38615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38616. /**
  38617. * Detach the current controls from the specified dom element.
  38618. * @param element Defines the element to stop listening the inputs from
  38619. */
  38620. detachControl(element: Nullable<HTMLElement>): void;
  38621. /**
  38622. * Update the current camera state depending on the inputs that have been used this frame.
  38623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38624. */
  38625. checkInputs(): void;
  38626. /**
  38627. * Gets the class name of the current input.
  38628. * @returns the class name
  38629. */
  38630. getClassName(): string;
  38631. /**
  38632. * Get the friendly name associated with the input class.
  38633. * @returns the input friendly name
  38634. */
  38635. getSimpleName(): string;
  38636. /**
  38637. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38638. * allow modification of the heightOffset value.
  38639. */
  38640. private _modifierHeightOffset;
  38641. /**
  38642. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38643. * allow modification of the rotationOffset value.
  38644. */
  38645. private _modifierRotationOffset;
  38646. /**
  38647. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38648. * allow modification of the radius value.
  38649. */
  38650. private _modifierRadius;
  38651. }
  38652. }
  38653. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38654. import { Nullable } from "babylonjs/types";
  38655. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38657. import { Observable } from "babylonjs/Misc/observable";
  38658. module "babylonjs/Cameras/freeCameraInputsManager" {
  38659. interface FreeCameraInputsManager {
  38660. /**
  38661. * @hidden
  38662. */
  38663. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38664. /**
  38665. * Add orientation input support to the input manager.
  38666. * @returns the current input manager
  38667. */
  38668. addDeviceOrientation(): FreeCameraInputsManager;
  38669. }
  38670. }
  38671. /**
  38672. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38673. * Screen rotation is taken into account.
  38674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38675. */
  38676. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38677. private _camera;
  38678. private _screenOrientationAngle;
  38679. private _constantTranform;
  38680. private _screenQuaternion;
  38681. private _alpha;
  38682. private _beta;
  38683. private _gamma;
  38684. /**
  38685. * Can be used to detect if a device orientation sensor is availible on a device
  38686. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38687. * @returns a promise that will resolve on orientation change
  38688. */
  38689. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38690. /**
  38691. * @hidden
  38692. */
  38693. _onDeviceOrientationChangedObservable: Observable<void>;
  38694. /**
  38695. * Instantiates a new input
  38696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38697. */
  38698. constructor();
  38699. /**
  38700. * Define the camera controlled by the input.
  38701. */
  38702. camera: FreeCamera;
  38703. /**
  38704. * Attach the input controls to a specific dom element to get the input from.
  38705. * @param element Defines the element the controls should be listened from
  38706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38707. */
  38708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38709. private _orientationChanged;
  38710. private _deviceOrientation;
  38711. /**
  38712. * Detach the current controls from the specified dom element.
  38713. * @param element Defines the element to stop listening the inputs from
  38714. */
  38715. detachControl(element: Nullable<HTMLElement>): void;
  38716. /**
  38717. * Update the current camera state depending on the inputs that have been used this frame.
  38718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38719. */
  38720. checkInputs(): void;
  38721. /**
  38722. * Gets the class name of the current intput.
  38723. * @returns the class name
  38724. */
  38725. getClassName(): string;
  38726. /**
  38727. * Get the friendly name associated with the input class.
  38728. * @returns the input friendly name
  38729. */
  38730. getSimpleName(): string;
  38731. }
  38732. }
  38733. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38734. import { Nullable } from "babylonjs/types";
  38735. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38736. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38737. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38738. /**
  38739. * Manage the gamepad inputs to control a free camera.
  38740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38741. */
  38742. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38743. /**
  38744. * Define the camera the input is attached to.
  38745. */
  38746. camera: FreeCamera;
  38747. /**
  38748. * Define the Gamepad controlling the input
  38749. */
  38750. gamepad: Nullable<Gamepad>;
  38751. /**
  38752. * Defines the gamepad rotation sensiblity.
  38753. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38754. */
  38755. gamepadAngularSensibility: number;
  38756. /**
  38757. * Defines the gamepad move sensiblity.
  38758. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38759. */
  38760. gamepadMoveSensibility: number;
  38761. private _onGamepadConnectedObserver;
  38762. private _onGamepadDisconnectedObserver;
  38763. private _cameraTransform;
  38764. private _deltaTransform;
  38765. private _vector3;
  38766. private _vector2;
  38767. /**
  38768. * Attach the input controls to a specific dom element to get the input from.
  38769. * @param element Defines the element the controls should be listened from
  38770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38771. */
  38772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38773. /**
  38774. * Detach the current controls from the specified dom element.
  38775. * @param element Defines the element to stop listening the inputs from
  38776. */
  38777. detachControl(element: Nullable<HTMLElement>): void;
  38778. /**
  38779. * Update the current camera state depending on the inputs that have been used this frame.
  38780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38781. */
  38782. checkInputs(): void;
  38783. /**
  38784. * Gets the class name of the current intput.
  38785. * @returns the class name
  38786. */
  38787. getClassName(): string;
  38788. /**
  38789. * Get the friendly name associated with the input class.
  38790. * @returns the input friendly name
  38791. */
  38792. getSimpleName(): string;
  38793. }
  38794. }
  38795. declare module "babylonjs/Misc/virtualJoystick" {
  38796. import { Nullable } from "babylonjs/types";
  38797. import { Vector3 } from "babylonjs/Maths/math";
  38798. /**
  38799. * Defines the potential axis of a Joystick
  38800. */
  38801. export enum JoystickAxis {
  38802. /** X axis */
  38803. X = 0,
  38804. /** Y axis */
  38805. Y = 1,
  38806. /** Z axis */
  38807. Z = 2
  38808. }
  38809. /**
  38810. * Class used to define virtual joystick (used in touch mode)
  38811. */
  38812. export class VirtualJoystick {
  38813. /**
  38814. * Gets or sets a boolean indicating that left and right values must be inverted
  38815. */
  38816. reverseLeftRight: boolean;
  38817. /**
  38818. * Gets or sets a boolean indicating that up and down values must be inverted
  38819. */
  38820. reverseUpDown: boolean;
  38821. /**
  38822. * Gets the offset value for the position (ie. the change of the position value)
  38823. */
  38824. deltaPosition: Vector3;
  38825. /**
  38826. * Gets a boolean indicating if the virtual joystick was pressed
  38827. */
  38828. pressed: boolean;
  38829. /**
  38830. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38831. */
  38832. static Canvas: Nullable<HTMLCanvasElement>;
  38833. private static _globalJoystickIndex;
  38834. private static vjCanvasContext;
  38835. private static vjCanvasWidth;
  38836. private static vjCanvasHeight;
  38837. private static halfWidth;
  38838. private _action;
  38839. private _axisTargetedByLeftAndRight;
  38840. private _axisTargetedByUpAndDown;
  38841. private _joystickSensibility;
  38842. private _inversedSensibility;
  38843. private _joystickPointerID;
  38844. private _joystickColor;
  38845. private _joystickPointerPos;
  38846. private _joystickPreviousPointerPos;
  38847. private _joystickPointerStartPos;
  38848. private _deltaJoystickVector;
  38849. private _leftJoystick;
  38850. private _touches;
  38851. private _onPointerDownHandlerRef;
  38852. private _onPointerMoveHandlerRef;
  38853. private _onPointerUpHandlerRef;
  38854. private _onResize;
  38855. /**
  38856. * Creates a new virtual joystick
  38857. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38858. */
  38859. constructor(leftJoystick?: boolean);
  38860. /**
  38861. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38862. * @param newJoystickSensibility defines the new sensibility
  38863. */
  38864. setJoystickSensibility(newJoystickSensibility: number): void;
  38865. private _onPointerDown;
  38866. private _onPointerMove;
  38867. private _onPointerUp;
  38868. /**
  38869. * Change the color of the virtual joystick
  38870. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38871. */
  38872. setJoystickColor(newColor: string): void;
  38873. /**
  38874. * Defines a callback to call when the joystick is touched
  38875. * @param action defines the callback
  38876. */
  38877. setActionOnTouch(action: () => any): void;
  38878. /**
  38879. * Defines which axis you'd like to control for left & right
  38880. * @param axis defines the axis to use
  38881. */
  38882. setAxisForLeftRight(axis: JoystickAxis): void;
  38883. /**
  38884. * Defines which axis you'd like to control for up & down
  38885. * @param axis defines the axis to use
  38886. */
  38887. setAxisForUpDown(axis: JoystickAxis): void;
  38888. private _drawVirtualJoystick;
  38889. /**
  38890. * Release internal HTML canvas
  38891. */
  38892. releaseCanvas(): void;
  38893. }
  38894. }
  38895. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38896. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38897. import { Nullable } from "babylonjs/types";
  38898. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38899. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38900. module "babylonjs/Cameras/freeCameraInputsManager" {
  38901. interface FreeCameraInputsManager {
  38902. /**
  38903. * Add virtual joystick input support to the input manager.
  38904. * @returns the current input manager
  38905. */
  38906. addVirtualJoystick(): FreeCameraInputsManager;
  38907. }
  38908. }
  38909. /**
  38910. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38912. */
  38913. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38914. /**
  38915. * Defines the camera the input is attached to.
  38916. */
  38917. camera: FreeCamera;
  38918. private _leftjoystick;
  38919. private _rightjoystick;
  38920. /**
  38921. * Gets the left stick of the virtual joystick.
  38922. * @returns The virtual Joystick
  38923. */
  38924. getLeftJoystick(): VirtualJoystick;
  38925. /**
  38926. * Gets the right stick of the virtual joystick.
  38927. * @returns The virtual Joystick
  38928. */
  38929. getRightJoystick(): VirtualJoystick;
  38930. /**
  38931. * Update the current camera state depending on the inputs that have been used this frame.
  38932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38933. */
  38934. checkInputs(): void;
  38935. /**
  38936. * Attach the input controls to a specific dom element to get the input from.
  38937. * @param element Defines the element the controls should be listened from
  38938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38939. */
  38940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38941. /**
  38942. * Detach the current controls from the specified dom element.
  38943. * @param element Defines the element to stop listening the inputs from
  38944. */
  38945. detachControl(element: Nullable<HTMLElement>): void;
  38946. /**
  38947. * Gets the class name of the current intput.
  38948. * @returns the class name
  38949. */
  38950. getClassName(): string;
  38951. /**
  38952. * Get the friendly name associated with the input class.
  38953. * @returns the input friendly name
  38954. */
  38955. getSimpleName(): string;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/Inputs/index" {
  38959. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38960. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38961. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38962. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38963. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38964. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38965. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38966. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38967. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38968. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38969. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38970. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38971. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38972. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38973. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38974. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38975. }
  38976. declare module "babylonjs/Cameras/touchCamera" {
  38977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38978. import { Scene } from "babylonjs/scene";
  38979. import { Vector3 } from "babylonjs/Maths/math";
  38980. /**
  38981. * This represents a FPS type of camera controlled by touch.
  38982. * This is like a universal camera minus the Gamepad controls.
  38983. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38984. */
  38985. export class TouchCamera extends FreeCamera {
  38986. /**
  38987. * Defines the touch sensibility for rotation.
  38988. * The higher the faster.
  38989. */
  38990. touchAngularSensibility: number;
  38991. /**
  38992. * Defines the touch sensibility for move.
  38993. * The higher the faster.
  38994. */
  38995. touchMoveSensibility: number;
  38996. /**
  38997. * Instantiates a new touch camera.
  38998. * This represents a FPS type of camera controlled by touch.
  38999. * This is like a universal camera minus the Gamepad controls.
  39000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39001. * @param name Define the name of the camera in the scene
  39002. * @param position Define the start position of the camera in the scene
  39003. * @param scene Define the scene the camera belongs to
  39004. */
  39005. constructor(name: string, position: Vector3, scene: Scene);
  39006. /**
  39007. * Gets the current object class name.
  39008. * @return the class name
  39009. */
  39010. getClassName(): string;
  39011. /** @hidden */
  39012. _setupInputs(): void;
  39013. }
  39014. }
  39015. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39017. import { Scene } from "babylonjs/scene";
  39018. import { Vector3, Axis } from "babylonjs/Maths/math";
  39019. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39020. /**
  39021. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39022. * being tilted forward or back and left or right.
  39023. */
  39024. export class DeviceOrientationCamera extends FreeCamera {
  39025. private _initialQuaternion;
  39026. private _quaternionCache;
  39027. private _tmpDragQuaternion;
  39028. /**
  39029. * Creates a new device orientation camera
  39030. * @param name The name of the camera
  39031. * @param position The start position camera
  39032. * @param scene The scene the camera belongs to
  39033. */
  39034. constructor(name: string, position: Vector3, scene: Scene);
  39035. /**
  39036. * @hidden
  39037. * Disabled pointer input on first orientation sensor update (Default: true)
  39038. */
  39039. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39040. private _dragFactor;
  39041. /**
  39042. * Enabled turning on the y axis when the orientation sensor is active
  39043. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39044. */
  39045. enableHorizontalDragging(dragFactor?: number): void;
  39046. /**
  39047. * Gets the current instance class name ("DeviceOrientationCamera").
  39048. * This helps avoiding instanceof at run time.
  39049. * @returns the class name
  39050. */
  39051. getClassName(): string;
  39052. /**
  39053. * @hidden
  39054. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39055. */
  39056. _checkInputs(): void;
  39057. /**
  39058. * Reset the camera to its default orientation on the specified axis only.
  39059. * @param axis The axis to reset
  39060. */
  39061. resetToCurrentRotation(axis?: Axis): void;
  39062. }
  39063. }
  39064. declare module "babylonjs/Gamepads/xboxGamepad" {
  39065. import { Observable } from "babylonjs/Misc/observable";
  39066. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39067. /**
  39068. * Defines supported buttons for XBox360 compatible gamepads
  39069. */
  39070. export enum Xbox360Button {
  39071. /** A */
  39072. A = 0,
  39073. /** B */
  39074. B = 1,
  39075. /** X */
  39076. X = 2,
  39077. /** Y */
  39078. Y = 3,
  39079. /** Start */
  39080. Start = 4,
  39081. /** Back */
  39082. Back = 5,
  39083. /** Left button */
  39084. LB = 6,
  39085. /** Right button */
  39086. RB = 7,
  39087. /** Left stick */
  39088. LeftStick = 8,
  39089. /** Right stick */
  39090. RightStick = 9
  39091. }
  39092. /** Defines values for XBox360 DPad */
  39093. export enum Xbox360Dpad {
  39094. /** Up */
  39095. Up = 0,
  39096. /** Down */
  39097. Down = 1,
  39098. /** Left */
  39099. Left = 2,
  39100. /** Right */
  39101. Right = 3
  39102. }
  39103. /**
  39104. * Defines a XBox360 gamepad
  39105. */
  39106. export class Xbox360Pad extends Gamepad {
  39107. private _leftTrigger;
  39108. private _rightTrigger;
  39109. private _onlefttriggerchanged;
  39110. private _onrighttriggerchanged;
  39111. private _onbuttondown;
  39112. private _onbuttonup;
  39113. private _ondpaddown;
  39114. private _ondpadup;
  39115. /** Observable raised when a button is pressed */
  39116. onButtonDownObservable: Observable<Xbox360Button>;
  39117. /** Observable raised when a button is released */
  39118. onButtonUpObservable: Observable<Xbox360Button>;
  39119. /** Observable raised when a pad is pressed */
  39120. onPadDownObservable: Observable<Xbox360Dpad>;
  39121. /** Observable raised when a pad is released */
  39122. onPadUpObservable: Observable<Xbox360Dpad>;
  39123. private _buttonA;
  39124. private _buttonB;
  39125. private _buttonX;
  39126. private _buttonY;
  39127. private _buttonBack;
  39128. private _buttonStart;
  39129. private _buttonLB;
  39130. private _buttonRB;
  39131. private _buttonLeftStick;
  39132. private _buttonRightStick;
  39133. private _dPadUp;
  39134. private _dPadDown;
  39135. private _dPadLeft;
  39136. private _dPadRight;
  39137. private _isXboxOnePad;
  39138. /**
  39139. * Creates a new XBox360 gamepad object
  39140. * @param id defines the id of this gamepad
  39141. * @param index defines its index
  39142. * @param gamepad defines the internal HTML gamepad object
  39143. * @param xboxOne defines if it is a XBox One gamepad
  39144. */
  39145. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39146. /**
  39147. * Defines the callback to call when left trigger is pressed
  39148. * @param callback defines the callback to use
  39149. */
  39150. onlefttriggerchanged(callback: (value: number) => void): void;
  39151. /**
  39152. * Defines the callback to call when right trigger is pressed
  39153. * @param callback defines the callback to use
  39154. */
  39155. onrighttriggerchanged(callback: (value: number) => void): void;
  39156. /**
  39157. * Gets the left trigger value
  39158. */
  39159. /**
  39160. * Sets the left trigger value
  39161. */
  39162. leftTrigger: number;
  39163. /**
  39164. * Gets the right trigger value
  39165. */
  39166. /**
  39167. * Sets the right trigger value
  39168. */
  39169. rightTrigger: number;
  39170. /**
  39171. * Defines the callback to call when a button is pressed
  39172. * @param callback defines the callback to use
  39173. */
  39174. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39175. /**
  39176. * Defines the callback to call when a button is released
  39177. * @param callback defines the callback to use
  39178. */
  39179. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39180. /**
  39181. * Defines the callback to call when a pad is pressed
  39182. * @param callback defines the callback to use
  39183. */
  39184. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39185. /**
  39186. * Defines the callback to call when a pad is released
  39187. * @param callback defines the callback to use
  39188. */
  39189. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39190. private _setButtonValue;
  39191. private _setDPadValue;
  39192. /**
  39193. * Gets the value of the `A` button
  39194. */
  39195. /**
  39196. * Sets the value of the `A` button
  39197. */
  39198. buttonA: number;
  39199. /**
  39200. * Gets the value of the `B` button
  39201. */
  39202. /**
  39203. * Sets the value of the `B` button
  39204. */
  39205. buttonB: number;
  39206. /**
  39207. * Gets the value of the `X` button
  39208. */
  39209. /**
  39210. * Sets the value of the `X` button
  39211. */
  39212. buttonX: number;
  39213. /**
  39214. * Gets the value of the `Y` button
  39215. */
  39216. /**
  39217. * Sets the value of the `Y` button
  39218. */
  39219. buttonY: number;
  39220. /**
  39221. * Gets the value of the `Start` button
  39222. */
  39223. /**
  39224. * Sets the value of the `Start` button
  39225. */
  39226. buttonStart: number;
  39227. /**
  39228. * Gets the value of the `Back` button
  39229. */
  39230. /**
  39231. * Sets the value of the `Back` button
  39232. */
  39233. buttonBack: number;
  39234. /**
  39235. * Gets the value of the `Left` button
  39236. */
  39237. /**
  39238. * Sets the value of the `Left` button
  39239. */
  39240. buttonLB: number;
  39241. /**
  39242. * Gets the value of the `Right` button
  39243. */
  39244. /**
  39245. * Sets the value of the `Right` button
  39246. */
  39247. buttonRB: number;
  39248. /**
  39249. * Gets the value of the Left joystick
  39250. */
  39251. /**
  39252. * Sets the value of the Left joystick
  39253. */
  39254. buttonLeftStick: number;
  39255. /**
  39256. * Gets the value of the Right joystick
  39257. */
  39258. /**
  39259. * Sets the value of the Right joystick
  39260. */
  39261. buttonRightStick: number;
  39262. /**
  39263. * Gets the value of D-pad up
  39264. */
  39265. /**
  39266. * Sets the value of D-pad up
  39267. */
  39268. dPadUp: number;
  39269. /**
  39270. * Gets the value of D-pad down
  39271. */
  39272. /**
  39273. * Sets the value of D-pad down
  39274. */
  39275. dPadDown: number;
  39276. /**
  39277. * Gets the value of D-pad left
  39278. */
  39279. /**
  39280. * Sets the value of D-pad left
  39281. */
  39282. dPadLeft: number;
  39283. /**
  39284. * Gets the value of D-pad right
  39285. */
  39286. /**
  39287. * Sets the value of D-pad right
  39288. */
  39289. dPadRight: number;
  39290. /**
  39291. * Force the gamepad to synchronize with device values
  39292. */
  39293. update(): void;
  39294. /**
  39295. * Disposes the gamepad
  39296. */
  39297. dispose(): void;
  39298. }
  39299. }
  39300. declare module "babylonjs/Gamepads/gamepadManager" {
  39301. import { Observable } from "babylonjs/Misc/observable";
  39302. import { Nullable } from "babylonjs/types";
  39303. import { Scene } from "babylonjs/scene";
  39304. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39305. /**
  39306. * Manager for handling gamepads
  39307. */
  39308. export class GamepadManager {
  39309. private _scene?;
  39310. private _babylonGamepads;
  39311. private _oneGamepadConnected;
  39312. /** @hidden */
  39313. _isMonitoring: boolean;
  39314. private _gamepadEventSupported;
  39315. private _gamepadSupport;
  39316. /**
  39317. * observable to be triggered when the gamepad controller has been connected
  39318. */
  39319. onGamepadConnectedObservable: Observable<Gamepad>;
  39320. /**
  39321. * observable to be triggered when the gamepad controller has been disconnected
  39322. */
  39323. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39324. private _onGamepadConnectedEvent;
  39325. private _onGamepadDisconnectedEvent;
  39326. /**
  39327. * Initializes the gamepad manager
  39328. * @param _scene BabylonJS scene
  39329. */
  39330. constructor(_scene?: Scene | undefined);
  39331. /**
  39332. * The gamepads in the game pad manager
  39333. */
  39334. readonly gamepads: Gamepad[];
  39335. /**
  39336. * Get the gamepad controllers based on type
  39337. * @param type The type of gamepad controller
  39338. * @returns Nullable gamepad
  39339. */
  39340. getGamepadByType(type?: number): Nullable<Gamepad>;
  39341. /**
  39342. * Disposes the gamepad manager
  39343. */
  39344. dispose(): void;
  39345. private _addNewGamepad;
  39346. private _startMonitoringGamepads;
  39347. private _stopMonitoringGamepads;
  39348. /** @hidden */
  39349. _checkGamepadsStatus(): void;
  39350. private _updateGamepadObjects;
  39351. }
  39352. }
  39353. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39354. import { Nullable } from "babylonjs/types";
  39355. import { Scene } from "babylonjs/scene";
  39356. import { ISceneComponent } from "babylonjs/sceneComponent";
  39357. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39358. module "babylonjs/scene" {
  39359. interface Scene {
  39360. /** @hidden */
  39361. _gamepadManager: Nullable<GamepadManager>;
  39362. /**
  39363. * Gets the gamepad manager associated with the scene
  39364. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39365. */
  39366. gamepadManager: GamepadManager;
  39367. }
  39368. }
  39369. module "babylonjs/Cameras/freeCameraInputsManager" {
  39370. /**
  39371. * Interface representing a free camera inputs manager
  39372. */
  39373. interface FreeCameraInputsManager {
  39374. /**
  39375. * Adds gamepad input support to the FreeCameraInputsManager.
  39376. * @returns the FreeCameraInputsManager
  39377. */
  39378. addGamepad(): FreeCameraInputsManager;
  39379. }
  39380. }
  39381. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39382. /**
  39383. * Interface representing an arc rotate camera inputs manager
  39384. */
  39385. interface ArcRotateCameraInputsManager {
  39386. /**
  39387. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39388. * @returns the camera inputs manager
  39389. */
  39390. addGamepad(): ArcRotateCameraInputsManager;
  39391. }
  39392. }
  39393. /**
  39394. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39395. */
  39396. export class GamepadSystemSceneComponent implements ISceneComponent {
  39397. /**
  39398. * The component name helpfull to identify the component in the list of scene components.
  39399. */
  39400. readonly name: string;
  39401. /**
  39402. * The scene the component belongs to.
  39403. */
  39404. scene: Scene;
  39405. /**
  39406. * Creates a new instance of the component for the given scene
  39407. * @param scene Defines the scene to register the component in
  39408. */
  39409. constructor(scene: Scene);
  39410. /**
  39411. * Registers the component in a given scene
  39412. */
  39413. register(): void;
  39414. /**
  39415. * Rebuilds the elements related to this component in case of
  39416. * context lost for instance.
  39417. */
  39418. rebuild(): void;
  39419. /**
  39420. * Disposes the component and the associated ressources
  39421. */
  39422. dispose(): void;
  39423. private _beforeCameraUpdate;
  39424. }
  39425. }
  39426. declare module "babylonjs/Cameras/universalCamera" {
  39427. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39428. import { Scene } from "babylonjs/scene";
  39429. import { Vector3 } from "babylonjs/Maths/math";
  39430. import "babylonjs/Gamepads/gamepadSceneComponent";
  39431. /**
  39432. * 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,
  39433. * which still works and will still be found in many Playgrounds.
  39434. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39435. */
  39436. export class UniversalCamera extends TouchCamera {
  39437. /**
  39438. * Defines the gamepad rotation sensiblity.
  39439. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39440. */
  39441. gamepadAngularSensibility: number;
  39442. /**
  39443. * Defines the gamepad move sensiblity.
  39444. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39445. */
  39446. gamepadMoveSensibility: number;
  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. * @param name Define the name of the camera in the scene
  39452. * @param position Define the start position of the camera in the scene
  39453. * @param scene Define the scene the camera belongs to
  39454. */
  39455. constructor(name: string, position: Vector3, scene: Scene);
  39456. /**
  39457. * Gets the current object class name.
  39458. * @return the class name
  39459. */
  39460. getClassName(): string;
  39461. }
  39462. }
  39463. declare module "babylonjs/Cameras/gamepadCamera" {
  39464. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39465. import { Scene } from "babylonjs/scene";
  39466. import { Vector3 } from "babylonjs/Maths/math";
  39467. /**
  39468. * This represents a FPS type of camera. This is only here for back compat purpose.
  39469. * Please use the UniversalCamera instead as both are identical.
  39470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39471. */
  39472. export class GamepadCamera extends UniversalCamera {
  39473. /**
  39474. * Instantiates a new Gamepad Camera
  39475. * This represents a FPS type of camera. This is only here for back compat purpose.
  39476. * Please use the UniversalCamera instead as both are identical.
  39477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39478. * @param name Define the name of the camera in the scene
  39479. * @param position Define the start position of the camera in the scene
  39480. * @param scene Define the scene the camera belongs to
  39481. */
  39482. constructor(name: string, position: Vector3, scene: Scene);
  39483. /**
  39484. * Gets the current object class name.
  39485. * @return the class name
  39486. */
  39487. getClassName(): string;
  39488. }
  39489. }
  39490. declare module "babylonjs/Shaders/pass.fragment" {
  39491. /** @hidden */
  39492. export var passPixelShader: {
  39493. name: string;
  39494. shader: string;
  39495. };
  39496. }
  39497. declare module "babylonjs/Shaders/passCube.fragment" {
  39498. /** @hidden */
  39499. export var passCubePixelShader: {
  39500. name: string;
  39501. shader: string;
  39502. };
  39503. }
  39504. declare module "babylonjs/PostProcesses/passPostProcess" {
  39505. import { Nullable } from "babylonjs/types";
  39506. import { Camera } from "babylonjs/Cameras/camera";
  39507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39508. import { Engine } from "babylonjs/Engines/engine";
  39509. import "babylonjs/Shaders/pass.fragment";
  39510. import "babylonjs/Shaders/passCube.fragment";
  39511. /**
  39512. * PassPostProcess which produces an output the same as it's input
  39513. */
  39514. export class PassPostProcess extends PostProcess {
  39515. /**
  39516. * Creates the PassPostProcess
  39517. * @param name The name of the effect.
  39518. * @param options The required width/height ratio to downsize to before computing the render pass.
  39519. * @param camera The camera to apply the render pass to.
  39520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39521. * @param engine The engine which the post process will be applied. (default: current engine)
  39522. * @param reusable If the post process can be reused on the same frame. (default: false)
  39523. * @param textureType The type of texture to be used when performing the post processing.
  39524. * @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)
  39525. */
  39526. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39527. }
  39528. /**
  39529. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39530. */
  39531. export class PassCubePostProcess extends PostProcess {
  39532. private _face;
  39533. /**
  39534. * Gets or sets the cube face to display.
  39535. * * 0 is +X
  39536. * * 1 is -X
  39537. * * 2 is +Y
  39538. * * 3 is -Y
  39539. * * 4 is +Z
  39540. * * 5 is -Z
  39541. */
  39542. face: number;
  39543. /**
  39544. * Creates the PassCubePostProcess
  39545. * @param name The name of the effect.
  39546. * @param options The required width/height ratio to downsize to before computing the render pass.
  39547. * @param camera The camera to apply the render pass to.
  39548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39549. * @param engine The engine which the post process will be applied. (default: current engine)
  39550. * @param reusable If the post process can be reused on the same frame. (default: false)
  39551. * @param textureType The type of texture to be used when performing the post processing.
  39552. * @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)
  39553. */
  39554. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39555. }
  39556. }
  39557. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39558. /** @hidden */
  39559. export var anaglyphPixelShader: {
  39560. name: string;
  39561. shader: string;
  39562. };
  39563. }
  39564. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39565. import { Engine } from "babylonjs/Engines/engine";
  39566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39567. import { Camera } from "babylonjs/Cameras/camera";
  39568. import "babylonjs/Shaders/anaglyph.fragment";
  39569. /**
  39570. * Postprocess used to generate anaglyphic rendering
  39571. */
  39572. export class AnaglyphPostProcess extends PostProcess {
  39573. private _passedProcess;
  39574. /**
  39575. * Creates a new AnaglyphPostProcess
  39576. * @param name defines postprocess name
  39577. * @param options defines creation options or target ratio scale
  39578. * @param rigCameras defines cameras using this postprocess
  39579. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39580. * @param engine defines hosting engine
  39581. * @param reusable defines if the postprocess will be reused multiple times per frame
  39582. */
  39583. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39584. }
  39585. }
  39586. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39587. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39588. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39589. import { Scene } from "babylonjs/scene";
  39590. import { Vector3 } from "babylonjs/Maths/math";
  39591. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39592. /**
  39593. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39594. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39595. */
  39596. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39597. /**
  39598. * Creates a new AnaglyphArcRotateCamera
  39599. * @param name defines camera name
  39600. * @param alpha defines alpha angle (in radians)
  39601. * @param beta defines beta angle (in radians)
  39602. * @param radius defines radius
  39603. * @param target defines camera target
  39604. * @param interaxialDistance defines distance between each color axis
  39605. * @param scene defines the hosting scene
  39606. */
  39607. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39608. /**
  39609. * Gets camera class name
  39610. * @returns AnaglyphArcRotateCamera
  39611. */
  39612. getClassName(): string;
  39613. }
  39614. }
  39615. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39616. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39617. import { Scene } from "babylonjs/scene";
  39618. import { Vector3 } from "babylonjs/Maths/math";
  39619. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39620. /**
  39621. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39622. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39623. */
  39624. export class AnaglyphFreeCamera extends FreeCamera {
  39625. /**
  39626. * Creates a new AnaglyphFreeCamera
  39627. * @param name defines camera name
  39628. * @param position defines initial position
  39629. * @param interaxialDistance defines distance between each color axis
  39630. * @param scene defines the hosting scene
  39631. */
  39632. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39633. /**
  39634. * Gets camera class name
  39635. * @returns AnaglyphFreeCamera
  39636. */
  39637. getClassName(): string;
  39638. }
  39639. }
  39640. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39641. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39642. import { Scene } from "babylonjs/scene";
  39643. import { Vector3 } from "babylonjs/Maths/math";
  39644. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39645. /**
  39646. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39647. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39648. */
  39649. export class AnaglyphGamepadCamera extends GamepadCamera {
  39650. /**
  39651. * Creates a new AnaglyphGamepadCamera
  39652. * @param name defines camera name
  39653. * @param position defines initial position
  39654. * @param interaxialDistance defines distance between each color axis
  39655. * @param scene defines the hosting scene
  39656. */
  39657. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39658. /**
  39659. * Gets camera class name
  39660. * @returns AnaglyphGamepadCamera
  39661. */
  39662. getClassName(): string;
  39663. }
  39664. }
  39665. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39666. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39667. import { Scene } from "babylonjs/scene";
  39668. import { Vector3 } from "babylonjs/Maths/math";
  39669. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39670. /**
  39671. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39672. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39673. */
  39674. export class AnaglyphUniversalCamera extends UniversalCamera {
  39675. /**
  39676. * Creates a new AnaglyphUniversalCamera
  39677. * @param name defines camera name
  39678. * @param position defines initial position
  39679. * @param interaxialDistance defines distance between each color axis
  39680. * @param scene defines the hosting scene
  39681. */
  39682. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39683. /**
  39684. * Gets camera class name
  39685. * @returns AnaglyphUniversalCamera
  39686. */
  39687. getClassName(): string;
  39688. }
  39689. }
  39690. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39691. /** @hidden */
  39692. export var stereoscopicInterlacePixelShader: {
  39693. name: string;
  39694. shader: string;
  39695. };
  39696. }
  39697. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39698. import { Camera } from "babylonjs/Cameras/camera";
  39699. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39700. import { Engine } from "babylonjs/Engines/engine";
  39701. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39702. /**
  39703. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39704. */
  39705. export class StereoscopicInterlacePostProcess extends PostProcess {
  39706. private _stepSize;
  39707. private _passedProcess;
  39708. /**
  39709. * Initializes a StereoscopicInterlacePostProcess
  39710. * @param name The name of the effect.
  39711. * @param rigCameras The rig cameras to be appled to the post process
  39712. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39714. * @param engine The engine which the post process will be applied. (default: current engine)
  39715. * @param reusable If the post process can be reused on the same frame. (default: false)
  39716. */
  39717. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39718. }
  39719. }
  39720. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39721. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39723. import { Scene } from "babylonjs/scene";
  39724. import { Vector3 } from "babylonjs/Maths/math";
  39725. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39726. /**
  39727. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39728. * @see http://doc.babylonjs.com/features/cameras
  39729. */
  39730. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39731. /**
  39732. * Creates a new StereoscopicArcRotateCamera
  39733. * @param name defines camera name
  39734. * @param alpha defines alpha angle (in radians)
  39735. * @param beta defines beta angle (in radians)
  39736. * @param radius defines radius
  39737. * @param target defines camera target
  39738. * @param interaxialDistance defines distance between each color axis
  39739. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39740. * @param scene defines the hosting scene
  39741. */
  39742. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39743. /**
  39744. * Gets camera class name
  39745. * @returns StereoscopicArcRotateCamera
  39746. */
  39747. getClassName(): string;
  39748. }
  39749. }
  39750. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39751. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39752. import { Scene } from "babylonjs/scene";
  39753. import { Vector3 } from "babylonjs/Maths/math";
  39754. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39755. /**
  39756. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39757. * @see http://doc.babylonjs.com/features/cameras
  39758. */
  39759. export class StereoscopicFreeCamera extends FreeCamera {
  39760. /**
  39761. * Creates a new StereoscopicFreeCamera
  39762. * @param name defines camera name
  39763. * @param position defines initial position
  39764. * @param interaxialDistance defines distance between each color axis
  39765. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39766. * @param scene defines the hosting scene
  39767. */
  39768. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39769. /**
  39770. * Gets camera class name
  39771. * @returns StereoscopicFreeCamera
  39772. */
  39773. getClassName(): string;
  39774. }
  39775. }
  39776. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39777. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39778. import { Scene } from "babylonjs/scene";
  39779. import { Vector3 } from "babylonjs/Maths/math";
  39780. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39781. /**
  39782. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39783. * @see http://doc.babylonjs.com/features/cameras
  39784. */
  39785. export class StereoscopicGamepadCamera extends GamepadCamera {
  39786. /**
  39787. * Creates a new StereoscopicGamepadCamera
  39788. * @param name defines camera name
  39789. * @param position defines initial position
  39790. * @param interaxialDistance defines distance between each color axis
  39791. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39792. * @param scene defines the hosting scene
  39793. */
  39794. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39795. /**
  39796. * Gets camera class name
  39797. * @returns StereoscopicGamepadCamera
  39798. */
  39799. getClassName(): string;
  39800. }
  39801. }
  39802. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39803. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39804. import { Scene } from "babylonjs/scene";
  39805. import { Vector3 } from "babylonjs/Maths/math";
  39806. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39807. /**
  39808. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39809. * @see http://doc.babylonjs.com/features/cameras
  39810. */
  39811. export class StereoscopicUniversalCamera extends UniversalCamera {
  39812. /**
  39813. * Creates a new StereoscopicUniversalCamera
  39814. * @param name defines camera name
  39815. * @param position defines initial position
  39816. * @param interaxialDistance defines distance between each color axis
  39817. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39818. * @param scene defines the hosting scene
  39819. */
  39820. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39821. /**
  39822. * Gets camera class name
  39823. * @returns StereoscopicUniversalCamera
  39824. */
  39825. getClassName(): string;
  39826. }
  39827. }
  39828. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39829. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39830. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39831. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39832. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39833. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39834. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39835. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39836. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39837. }
  39838. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39839. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39840. import { Scene } from "babylonjs/scene";
  39841. import { Vector3 } from "babylonjs/Maths/math";
  39842. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39843. /**
  39844. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39845. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39846. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39847. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39848. */
  39849. export class VirtualJoysticksCamera extends FreeCamera {
  39850. /**
  39851. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39852. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39853. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39854. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39855. * @param name Define the name of the camera in the scene
  39856. * @param position Define the start position of the camera in the scene
  39857. * @param scene Define the scene the camera belongs to
  39858. */
  39859. constructor(name: string, position: Vector3, scene: Scene);
  39860. /**
  39861. * Gets the current object class name.
  39862. * @return the class name
  39863. */
  39864. getClassName(): string;
  39865. }
  39866. }
  39867. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39868. import { Matrix } from "babylonjs/Maths/math";
  39869. /**
  39870. * This represents all the required metrics to create a VR camera.
  39871. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39872. */
  39873. export class VRCameraMetrics {
  39874. /**
  39875. * Define the horizontal resolution off the screen.
  39876. */
  39877. hResolution: number;
  39878. /**
  39879. * Define the vertical resolution off the screen.
  39880. */
  39881. vResolution: number;
  39882. /**
  39883. * Define the horizontal screen size.
  39884. */
  39885. hScreenSize: number;
  39886. /**
  39887. * Define the vertical screen size.
  39888. */
  39889. vScreenSize: number;
  39890. /**
  39891. * Define the vertical screen center position.
  39892. */
  39893. vScreenCenter: number;
  39894. /**
  39895. * Define the distance of the eyes to the screen.
  39896. */
  39897. eyeToScreenDistance: number;
  39898. /**
  39899. * Define the distance between both lenses
  39900. */
  39901. lensSeparationDistance: number;
  39902. /**
  39903. * Define the distance between both viewer's eyes.
  39904. */
  39905. interpupillaryDistance: number;
  39906. /**
  39907. * Define the distortion factor of the VR postprocess.
  39908. * Please, touch with care.
  39909. */
  39910. distortionK: number[];
  39911. /**
  39912. * Define the chromatic aberration correction factors for the VR post process.
  39913. */
  39914. chromaAbCorrection: number[];
  39915. /**
  39916. * Define the scale factor of the post process.
  39917. * The smaller the better but the slower.
  39918. */
  39919. postProcessScaleFactor: number;
  39920. /**
  39921. * Define an offset for the lens center.
  39922. */
  39923. lensCenterOffset: number;
  39924. /**
  39925. * Define if the current vr camera should compensate the distortion of the lense or not.
  39926. */
  39927. compensateDistortion: boolean;
  39928. /**
  39929. * Defines if multiview should be enabled when rendering (Default: false)
  39930. */
  39931. multiviewEnabled: boolean;
  39932. /**
  39933. * Gets the rendering aspect ratio based on the provided resolutions.
  39934. */
  39935. readonly aspectRatio: number;
  39936. /**
  39937. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39938. */
  39939. readonly aspectRatioFov: number;
  39940. /**
  39941. * @hidden
  39942. */
  39943. readonly leftHMatrix: Matrix;
  39944. /**
  39945. * @hidden
  39946. */
  39947. readonly rightHMatrix: Matrix;
  39948. /**
  39949. * @hidden
  39950. */
  39951. readonly leftPreViewMatrix: Matrix;
  39952. /**
  39953. * @hidden
  39954. */
  39955. readonly rightPreViewMatrix: Matrix;
  39956. /**
  39957. * Get the default VRMetrics based on the most generic setup.
  39958. * @returns the default vr metrics
  39959. */
  39960. static GetDefault(): VRCameraMetrics;
  39961. }
  39962. }
  39963. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39964. /** @hidden */
  39965. export var vrDistortionCorrectionPixelShader: {
  39966. name: string;
  39967. shader: string;
  39968. };
  39969. }
  39970. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39971. import { Camera } from "babylonjs/Cameras/camera";
  39972. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39974. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39975. /**
  39976. * VRDistortionCorrectionPostProcess used for mobile VR
  39977. */
  39978. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39979. private _isRightEye;
  39980. private _distortionFactors;
  39981. private _postProcessScaleFactor;
  39982. private _lensCenterOffset;
  39983. private _scaleIn;
  39984. private _scaleFactor;
  39985. private _lensCenter;
  39986. /**
  39987. * Initializes the VRDistortionCorrectionPostProcess
  39988. * @param name The name of the effect.
  39989. * @param camera The camera to apply the render pass to.
  39990. * @param isRightEye If this is for the right eye distortion
  39991. * @param vrMetrics All the required metrics for the VR camera
  39992. */
  39993. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39994. }
  39995. }
  39996. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39997. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39998. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39999. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40000. import { Scene } from "babylonjs/scene";
  40001. import { Vector3 } from "babylonjs/Maths/math";
  40002. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40003. import "babylonjs/Cameras/RigModes/vrRigMode";
  40004. /**
  40005. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40006. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40007. */
  40008. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40009. /**
  40010. * Creates a new VRDeviceOrientationArcRotateCamera
  40011. * @param name defines camera name
  40012. * @param alpha defines the camera rotation along the logitudinal axis
  40013. * @param beta defines the camera rotation along the latitudinal axis
  40014. * @param radius defines the camera distance from its target
  40015. * @param target defines the camera target
  40016. * @param scene defines the scene the camera belongs to
  40017. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40018. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40019. */
  40020. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40021. /**
  40022. * Gets camera class name
  40023. * @returns VRDeviceOrientationArcRotateCamera
  40024. */
  40025. getClassName(): string;
  40026. }
  40027. }
  40028. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40029. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40030. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40031. import { Scene } from "babylonjs/scene";
  40032. import { Vector3 } from "babylonjs/Maths/math";
  40033. import "babylonjs/Cameras/RigModes/vrRigMode";
  40034. /**
  40035. * Camera used to simulate VR rendering (based on FreeCamera)
  40036. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40037. */
  40038. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40039. /**
  40040. * Creates a new VRDeviceOrientationFreeCamera
  40041. * @param name defines camera name
  40042. * @param position defines the start position of the camera
  40043. * @param scene defines the scene the camera belongs to
  40044. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40045. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40046. */
  40047. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40048. /**
  40049. * Gets camera class name
  40050. * @returns VRDeviceOrientationFreeCamera
  40051. */
  40052. getClassName(): string;
  40053. }
  40054. }
  40055. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40056. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40057. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40058. import { Scene } from "babylonjs/scene";
  40059. import { Vector3 } from "babylonjs/Maths/math";
  40060. import "babylonjs/Gamepads/gamepadSceneComponent";
  40061. /**
  40062. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40063. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40064. */
  40065. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40066. /**
  40067. * Creates a new VRDeviceOrientationGamepadCamera
  40068. * @param name defines camera name
  40069. * @param position defines the start position of the camera
  40070. * @param scene defines the scene the camera belongs to
  40071. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40072. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40073. */
  40074. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40075. /**
  40076. * Gets camera class name
  40077. * @returns VRDeviceOrientationGamepadCamera
  40078. */
  40079. getClassName(): string;
  40080. }
  40081. }
  40082. declare module "babylonjs/Materials/pushMaterial" {
  40083. import { Nullable } from "babylonjs/types";
  40084. import { Scene } from "babylonjs/scene";
  40085. import { Matrix } from "babylonjs/Maths/math";
  40086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40087. import { Mesh } from "babylonjs/Meshes/mesh";
  40088. import { Material } from "babylonjs/Materials/material";
  40089. import { Effect } from "babylonjs/Materials/effect";
  40090. /**
  40091. * Base class of materials working in push mode in babylon JS
  40092. * @hidden
  40093. */
  40094. export class PushMaterial extends Material {
  40095. protected _activeEffect: Effect;
  40096. protected _normalMatrix: Matrix;
  40097. /**
  40098. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40099. * This means that the material can keep using a previous shader while a new one is being compiled.
  40100. * This is mostly used when shader parallel compilation is supported (true by default)
  40101. */
  40102. allowShaderHotSwapping: boolean;
  40103. constructor(name: string, scene: Scene);
  40104. getEffect(): Effect;
  40105. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40106. /**
  40107. * Binds the given world matrix to the active effect
  40108. *
  40109. * @param world the matrix to bind
  40110. */
  40111. bindOnlyWorldMatrix(world: Matrix): void;
  40112. /**
  40113. * Binds the given normal matrix to the active effect
  40114. *
  40115. * @param normalMatrix the matrix to bind
  40116. */
  40117. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40118. bind(world: Matrix, mesh?: Mesh): void;
  40119. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40120. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40121. }
  40122. }
  40123. declare module "babylonjs/Materials/materialFlags" {
  40124. /**
  40125. * This groups all the flags used to control the materials channel.
  40126. */
  40127. export class MaterialFlags {
  40128. private static _DiffuseTextureEnabled;
  40129. /**
  40130. * Are diffuse textures enabled in the application.
  40131. */
  40132. static DiffuseTextureEnabled: boolean;
  40133. private static _AmbientTextureEnabled;
  40134. /**
  40135. * Are ambient textures enabled in the application.
  40136. */
  40137. static AmbientTextureEnabled: boolean;
  40138. private static _OpacityTextureEnabled;
  40139. /**
  40140. * Are opacity textures enabled in the application.
  40141. */
  40142. static OpacityTextureEnabled: boolean;
  40143. private static _ReflectionTextureEnabled;
  40144. /**
  40145. * Are reflection textures enabled in the application.
  40146. */
  40147. static ReflectionTextureEnabled: boolean;
  40148. private static _EmissiveTextureEnabled;
  40149. /**
  40150. * Are emissive textures enabled in the application.
  40151. */
  40152. static EmissiveTextureEnabled: boolean;
  40153. private static _SpecularTextureEnabled;
  40154. /**
  40155. * Are specular textures enabled in the application.
  40156. */
  40157. static SpecularTextureEnabled: boolean;
  40158. private static _BumpTextureEnabled;
  40159. /**
  40160. * Are bump textures enabled in the application.
  40161. */
  40162. static BumpTextureEnabled: boolean;
  40163. private static _LightmapTextureEnabled;
  40164. /**
  40165. * Are lightmap textures enabled in the application.
  40166. */
  40167. static LightmapTextureEnabled: boolean;
  40168. private static _RefractionTextureEnabled;
  40169. /**
  40170. * Are refraction textures enabled in the application.
  40171. */
  40172. static RefractionTextureEnabled: boolean;
  40173. private static _ColorGradingTextureEnabled;
  40174. /**
  40175. * Are color grading textures enabled in the application.
  40176. */
  40177. static ColorGradingTextureEnabled: boolean;
  40178. private static _FresnelEnabled;
  40179. /**
  40180. * Are fresnels enabled in the application.
  40181. */
  40182. static FresnelEnabled: boolean;
  40183. private static _ClearCoatTextureEnabled;
  40184. /**
  40185. * Are clear coat textures enabled in the application.
  40186. */
  40187. static ClearCoatTextureEnabled: boolean;
  40188. private static _ClearCoatBumpTextureEnabled;
  40189. /**
  40190. * Are clear coat bump textures enabled in the application.
  40191. */
  40192. static ClearCoatBumpTextureEnabled: boolean;
  40193. private static _ClearCoatTintTextureEnabled;
  40194. /**
  40195. * Are clear coat tint textures enabled in the application.
  40196. */
  40197. static ClearCoatTintTextureEnabled: boolean;
  40198. private static _SheenTextureEnabled;
  40199. /**
  40200. * Are sheen textures enabled in the application.
  40201. */
  40202. static SheenTextureEnabled: boolean;
  40203. private static _AnisotropicTextureEnabled;
  40204. /**
  40205. * Are anisotropic textures enabled in the application.
  40206. */
  40207. static AnisotropicTextureEnabled: boolean;
  40208. private static _ThicknessTextureEnabled;
  40209. /**
  40210. * Are thickness textures enabled in the application.
  40211. */
  40212. static ThicknessTextureEnabled: boolean;
  40213. }
  40214. }
  40215. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40216. /** @hidden */
  40217. export var defaultFragmentDeclaration: {
  40218. name: string;
  40219. shader: string;
  40220. };
  40221. }
  40222. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40223. /** @hidden */
  40224. export var defaultUboDeclaration: {
  40225. name: string;
  40226. shader: string;
  40227. };
  40228. }
  40229. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40230. /** @hidden */
  40231. export var lightFragmentDeclaration: {
  40232. name: string;
  40233. shader: string;
  40234. };
  40235. }
  40236. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40237. /** @hidden */
  40238. export var lightUboDeclaration: {
  40239. name: string;
  40240. shader: string;
  40241. };
  40242. }
  40243. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40244. /** @hidden */
  40245. export var lightsFragmentFunctions: {
  40246. name: string;
  40247. shader: string;
  40248. };
  40249. }
  40250. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40251. /** @hidden */
  40252. export var shadowsFragmentFunctions: {
  40253. name: string;
  40254. shader: string;
  40255. };
  40256. }
  40257. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40258. /** @hidden */
  40259. export var fresnelFunction: {
  40260. name: string;
  40261. shader: string;
  40262. };
  40263. }
  40264. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40265. /** @hidden */
  40266. export var reflectionFunction: {
  40267. name: string;
  40268. shader: string;
  40269. };
  40270. }
  40271. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40272. /** @hidden */
  40273. export var bumpFragmentFunctions: {
  40274. name: string;
  40275. shader: string;
  40276. };
  40277. }
  40278. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40279. /** @hidden */
  40280. export var logDepthDeclaration: {
  40281. name: string;
  40282. shader: string;
  40283. };
  40284. }
  40285. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40286. /** @hidden */
  40287. export var bumpFragment: {
  40288. name: string;
  40289. shader: string;
  40290. };
  40291. }
  40292. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40293. /** @hidden */
  40294. export var depthPrePass: {
  40295. name: string;
  40296. shader: string;
  40297. };
  40298. }
  40299. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40300. /** @hidden */
  40301. export var lightFragment: {
  40302. name: string;
  40303. shader: string;
  40304. };
  40305. }
  40306. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40307. /** @hidden */
  40308. export var logDepthFragment: {
  40309. name: string;
  40310. shader: string;
  40311. };
  40312. }
  40313. declare module "babylonjs/Shaders/default.fragment" {
  40314. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40315. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40316. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40317. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40318. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40319. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40320. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40321. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40322. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40323. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40324. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40325. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40327. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40328. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40329. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40330. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40331. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40332. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40333. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40334. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40335. /** @hidden */
  40336. export var defaultPixelShader: {
  40337. name: string;
  40338. shader: string;
  40339. };
  40340. }
  40341. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40342. /** @hidden */
  40343. export var defaultVertexDeclaration: {
  40344. name: string;
  40345. shader: string;
  40346. };
  40347. }
  40348. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40349. /** @hidden */
  40350. export var bumpVertexDeclaration: {
  40351. name: string;
  40352. shader: string;
  40353. };
  40354. }
  40355. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40356. /** @hidden */
  40357. export var bumpVertex: {
  40358. name: string;
  40359. shader: string;
  40360. };
  40361. }
  40362. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40363. /** @hidden */
  40364. export var fogVertex: {
  40365. name: string;
  40366. shader: string;
  40367. };
  40368. }
  40369. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40370. /** @hidden */
  40371. export var shadowsVertex: {
  40372. name: string;
  40373. shader: string;
  40374. };
  40375. }
  40376. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40377. /** @hidden */
  40378. export var pointCloudVertex: {
  40379. name: string;
  40380. shader: string;
  40381. };
  40382. }
  40383. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40384. /** @hidden */
  40385. export var logDepthVertex: {
  40386. name: string;
  40387. shader: string;
  40388. };
  40389. }
  40390. declare module "babylonjs/Shaders/default.vertex" {
  40391. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40392. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40393. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40394. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40395. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40396. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40398. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40399. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40400. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40403. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40405. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40406. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40407. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40408. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40409. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40410. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40411. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40412. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40413. /** @hidden */
  40414. export var defaultVertexShader: {
  40415. name: string;
  40416. shader: string;
  40417. };
  40418. }
  40419. declare module "babylonjs/Materials/standardMaterial" {
  40420. import { SmartArray } from "babylonjs/Misc/smartArray";
  40421. import { IAnimatable } from "babylonjs/Misc/tools";
  40422. import { Nullable } from "babylonjs/types";
  40423. import { Scene } from "babylonjs/scene";
  40424. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40427. import { Mesh } from "babylonjs/Meshes/mesh";
  40428. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40429. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40430. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40431. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40432. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40434. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40435. import "babylonjs/Shaders/default.fragment";
  40436. import "babylonjs/Shaders/default.vertex";
  40437. /** @hidden */
  40438. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40439. MAINUV1: boolean;
  40440. MAINUV2: boolean;
  40441. DIFFUSE: boolean;
  40442. DIFFUSEDIRECTUV: number;
  40443. AMBIENT: boolean;
  40444. AMBIENTDIRECTUV: number;
  40445. OPACITY: boolean;
  40446. OPACITYDIRECTUV: number;
  40447. OPACITYRGB: boolean;
  40448. REFLECTION: boolean;
  40449. EMISSIVE: boolean;
  40450. EMISSIVEDIRECTUV: number;
  40451. SPECULAR: boolean;
  40452. SPECULARDIRECTUV: number;
  40453. BUMP: boolean;
  40454. BUMPDIRECTUV: number;
  40455. PARALLAX: boolean;
  40456. PARALLAXOCCLUSION: boolean;
  40457. SPECULAROVERALPHA: boolean;
  40458. CLIPPLANE: boolean;
  40459. CLIPPLANE2: boolean;
  40460. CLIPPLANE3: boolean;
  40461. CLIPPLANE4: boolean;
  40462. ALPHATEST: boolean;
  40463. DEPTHPREPASS: boolean;
  40464. ALPHAFROMDIFFUSE: boolean;
  40465. POINTSIZE: boolean;
  40466. FOG: boolean;
  40467. SPECULARTERM: boolean;
  40468. DIFFUSEFRESNEL: boolean;
  40469. OPACITYFRESNEL: boolean;
  40470. REFLECTIONFRESNEL: boolean;
  40471. REFRACTIONFRESNEL: boolean;
  40472. EMISSIVEFRESNEL: boolean;
  40473. FRESNEL: boolean;
  40474. NORMAL: boolean;
  40475. UV1: boolean;
  40476. UV2: boolean;
  40477. VERTEXCOLOR: boolean;
  40478. VERTEXALPHA: boolean;
  40479. NUM_BONE_INFLUENCERS: number;
  40480. BonesPerMesh: number;
  40481. BONETEXTURE: boolean;
  40482. INSTANCES: boolean;
  40483. GLOSSINESS: boolean;
  40484. ROUGHNESS: boolean;
  40485. EMISSIVEASILLUMINATION: boolean;
  40486. LINKEMISSIVEWITHDIFFUSE: boolean;
  40487. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40488. LIGHTMAP: boolean;
  40489. LIGHTMAPDIRECTUV: number;
  40490. OBJECTSPACE_NORMALMAP: boolean;
  40491. USELIGHTMAPASSHADOWMAP: boolean;
  40492. REFLECTIONMAP_3D: boolean;
  40493. REFLECTIONMAP_SPHERICAL: boolean;
  40494. REFLECTIONMAP_PLANAR: boolean;
  40495. REFLECTIONMAP_CUBIC: boolean;
  40496. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40497. REFLECTIONMAP_PROJECTION: boolean;
  40498. REFLECTIONMAP_SKYBOX: boolean;
  40499. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40500. REFLECTIONMAP_EXPLICIT: boolean;
  40501. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40502. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40503. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40504. INVERTCUBICMAP: boolean;
  40505. LOGARITHMICDEPTH: boolean;
  40506. REFRACTION: boolean;
  40507. REFRACTIONMAP_3D: boolean;
  40508. REFLECTIONOVERALPHA: boolean;
  40509. TWOSIDEDLIGHTING: boolean;
  40510. SHADOWFLOAT: boolean;
  40511. MORPHTARGETS: boolean;
  40512. MORPHTARGETS_NORMAL: boolean;
  40513. MORPHTARGETS_TANGENT: boolean;
  40514. MORPHTARGETS_UV: boolean;
  40515. NUM_MORPH_INFLUENCERS: number;
  40516. NONUNIFORMSCALING: boolean;
  40517. PREMULTIPLYALPHA: boolean;
  40518. IMAGEPROCESSING: boolean;
  40519. VIGNETTE: boolean;
  40520. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40521. VIGNETTEBLENDMODEOPAQUE: boolean;
  40522. TONEMAPPING: boolean;
  40523. TONEMAPPING_ACES: boolean;
  40524. CONTRAST: boolean;
  40525. COLORCURVES: boolean;
  40526. COLORGRADING: boolean;
  40527. COLORGRADING3D: boolean;
  40528. SAMPLER3DGREENDEPTH: boolean;
  40529. SAMPLER3DBGRMAP: boolean;
  40530. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40531. MULTIVIEW: boolean;
  40532. /**
  40533. * If the reflection texture on this material is in linear color space
  40534. * @hidden
  40535. */
  40536. IS_REFLECTION_LINEAR: boolean;
  40537. /**
  40538. * If the refraction texture on this material is in linear color space
  40539. * @hidden
  40540. */
  40541. IS_REFRACTION_LINEAR: boolean;
  40542. EXPOSURE: boolean;
  40543. constructor();
  40544. setReflectionMode(modeToEnable: string): void;
  40545. }
  40546. /**
  40547. * This is the default material used in Babylon. It is the best trade off between quality
  40548. * and performances.
  40549. * @see http://doc.babylonjs.com/babylon101/materials
  40550. */
  40551. export class StandardMaterial extends PushMaterial {
  40552. private _diffuseTexture;
  40553. /**
  40554. * The basic texture of the material as viewed under a light.
  40555. */
  40556. diffuseTexture: Nullable<BaseTexture>;
  40557. private _ambientTexture;
  40558. /**
  40559. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40560. */
  40561. ambientTexture: Nullable<BaseTexture>;
  40562. private _opacityTexture;
  40563. /**
  40564. * Define the transparency of the material from a texture.
  40565. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40566. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40567. */
  40568. opacityTexture: Nullable<BaseTexture>;
  40569. private _reflectionTexture;
  40570. /**
  40571. * Define the texture used to display the reflection.
  40572. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40573. */
  40574. reflectionTexture: Nullable<BaseTexture>;
  40575. private _emissiveTexture;
  40576. /**
  40577. * Define texture of the material as if self lit.
  40578. * This will be mixed in the final result even in the absence of light.
  40579. */
  40580. emissiveTexture: Nullable<BaseTexture>;
  40581. private _specularTexture;
  40582. /**
  40583. * Define how the color and intensity of the highlight given by the light in the material.
  40584. */
  40585. specularTexture: Nullable<BaseTexture>;
  40586. private _bumpTexture;
  40587. /**
  40588. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40589. * 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.
  40590. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40591. */
  40592. bumpTexture: Nullable<BaseTexture>;
  40593. private _lightmapTexture;
  40594. /**
  40595. * Complex lighting can be computationally expensive to compute at runtime.
  40596. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40597. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40598. */
  40599. lightmapTexture: Nullable<BaseTexture>;
  40600. private _refractionTexture;
  40601. /**
  40602. * Define the texture used to display the refraction.
  40603. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40604. */
  40605. refractionTexture: Nullable<BaseTexture>;
  40606. /**
  40607. * The color of the material lit by the environmental background lighting.
  40608. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40609. */
  40610. ambientColor: Color3;
  40611. /**
  40612. * The basic color of the material as viewed under a light.
  40613. */
  40614. diffuseColor: Color3;
  40615. /**
  40616. * Define how the color and intensity of the highlight given by the light in the material.
  40617. */
  40618. specularColor: Color3;
  40619. /**
  40620. * Define the color of the material as if self lit.
  40621. * This will be mixed in the final result even in the absence of light.
  40622. */
  40623. emissiveColor: Color3;
  40624. /**
  40625. * Defines how sharp are the highlights in the material.
  40626. * The bigger the value the sharper giving a more glossy feeling to the result.
  40627. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40628. */
  40629. specularPower: number;
  40630. private _useAlphaFromDiffuseTexture;
  40631. /**
  40632. * Does the transparency come from the diffuse texture alpha channel.
  40633. */
  40634. useAlphaFromDiffuseTexture: boolean;
  40635. private _useEmissiveAsIllumination;
  40636. /**
  40637. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40638. */
  40639. useEmissiveAsIllumination: boolean;
  40640. private _linkEmissiveWithDiffuse;
  40641. /**
  40642. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40643. * the emissive level when the final color is close to one.
  40644. */
  40645. linkEmissiveWithDiffuse: boolean;
  40646. private _useSpecularOverAlpha;
  40647. /**
  40648. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40649. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40650. */
  40651. useSpecularOverAlpha: boolean;
  40652. private _useReflectionOverAlpha;
  40653. /**
  40654. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40655. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40656. */
  40657. useReflectionOverAlpha: boolean;
  40658. private _disableLighting;
  40659. /**
  40660. * Does lights from the scene impacts this material.
  40661. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40662. */
  40663. disableLighting: boolean;
  40664. private _useObjectSpaceNormalMap;
  40665. /**
  40666. * Allows using an object space normal map (instead of tangent space).
  40667. */
  40668. useObjectSpaceNormalMap: boolean;
  40669. private _useParallax;
  40670. /**
  40671. * Is parallax enabled or not.
  40672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40673. */
  40674. useParallax: boolean;
  40675. private _useParallaxOcclusion;
  40676. /**
  40677. * Is parallax occlusion enabled or not.
  40678. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40679. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40680. */
  40681. useParallaxOcclusion: boolean;
  40682. /**
  40683. * 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.
  40684. */
  40685. parallaxScaleBias: number;
  40686. private _roughness;
  40687. /**
  40688. * Helps to define how blurry the reflections should appears in the material.
  40689. */
  40690. roughness: number;
  40691. /**
  40692. * In case of refraction, define the value of the index of refraction.
  40693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40694. */
  40695. indexOfRefraction: number;
  40696. /**
  40697. * Invert the refraction texture alongside the y axis.
  40698. * It can be useful with procedural textures or probe for instance.
  40699. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40700. */
  40701. invertRefractionY: boolean;
  40702. /**
  40703. * Defines the alpha limits in alpha test mode.
  40704. */
  40705. alphaCutOff: number;
  40706. private _useLightmapAsShadowmap;
  40707. /**
  40708. * In case of light mapping, define whether the map contains light or shadow informations.
  40709. */
  40710. useLightmapAsShadowmap: boolean;
  40711. private _diffuseFresnelParameters;
  40712. /**
  40713. * Define the diffuse fresnel parameters of the material.
  40714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40715. */
  40716. diffuseFresnelParameters: FresnelParameters;
  40717. private _opacityFresnelParameters;
  40718. /**
  40719. * Define the opacity fresnel parameters of the material.
  40720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40721. */
  40722. opacityFresnelParameters: FresnelParameters;
  40723. private _reflectionFresnelParameters;
  40724. /**
  40725. * Define the reflection fresnel parameters of the material.
  40726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40727. */
  40728. reflectionFresnelParameters: FresnelParameters;
  40729. private _refractionFresnelParameters;
  40730. /**
  40731. * Define the refraction fresnel parameters of the material.
  40732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40733. */
  40734. refractionFresnelParameters: FresnelParameters;
  40735. private _emissiveFresnelParameters;
  40736. /**
  40737. * Define the emissive fresnel parameters of the material.
  40738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40739. */
  40740. emissiveFresnelParameters: FresnelParameters;
  40741. private _useReflectionFresnelFromSpecular;
  40742. /**
  40743. * If true automatically deducts the fresnels values from the material specularity.
  40744. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40745. */
  40746. useReflectionFresnelFromSpecular: boolean;
  40747. private _useGlossinessFromSpecularMapAlpha;
  40748. /**
  40749. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40750. */
  40751. useGlossinessFromSpecularMapAlpha: boolean;
  40752. private _maxSimultaneousLights;
  40753. /**
  40754. * Defines the maximum number of lights that can be used in the material
  40755. */
  40756. maxSimultaneousLights: number;
  40757. private _invertNormalMapX;
  40758. /**
  40759. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40760. */
  40761. invertNormalMapX: boolean;
  40762. private _invertNormalMapY;
  40763. /**
  40764. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40765. */
  40766. invertNormalMapY: boolean;
  40767. private _twoSidedLighting;
  40768. /**
  40769. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40770. */
  40771. twoSidedLighting: boolean;
  40772. /**
  40773. * Default configuration related to image processing available in the standard Material.
  40774. */
  40775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40776. /**
  40777. * Gets the image processing configuration used either in this material.
  40778. */
  40779. /**
  40780. * Sets the Default image processing configuration used either in the this material.
  40781. *
  40782. * If sets to null, the scene one is in use.
  40783. */
  40784. imageProcessingConfiguration: ImageProcessingConfiguration;
  40785. /**
  40786. * Keep track of the image processing observer to allow dispose and replace.
  40787. */
  40788. private _imageProcessingObserver;
  40789. /**
  40790. * Attaches a new image processing configuration to the Standard Material.
  40791. * @param configuration
  40792. */
  40793. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40794. /**
  40795. * Gets wether the color curves effect is enabled.
  40796. */
  40797. /**
  40798. * Sets wether the color curves effect is enabled.
  40799. */
  40800. cameraColorCurvesEnabled: boolean;
  40801. /**
  40802. * Gets wether the color grading effect is enabled.
  40803. */
  40804. /**
  40805. * Gets wether the color grading effect is enabled.
  40806. */
  40807. cameraColorGradingEnabled: boolean;
  40808. /**
  40809. * Gets wether tonemapping is enabled or not.
  40810. */
  40811. /**
  40812. * Sets wether tonemapping is enabled or not
  40813. */
  40814. cameraToneMappingEnabled: boolean;
  40815. /**
  40816. * The camera exposure used on this material.
  40817. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40818. * This corresponds to a photographic exposure.
  40819. */
  40820. /**
  40821. * The camera exposure used on this material.
  40822. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40823. * This corresponds to a photographic exposure.
  40824. */
  40825. cameraExposure: number;
  40826. /**
  40827. * Gets The camera contrast used on this material.
  40828. */
  40829. /**
  40830. * Sets The camera contrast used on this material.
  40831. */
  40832. cameraContrast: number;
  40833. /**
  40834. * Gets the Color Grading 2D Lookup Texture.
  40835. */
  40836. /**
  40837. * Sets the Color Grading 2D Lookup Texture.
  40838. */
  40839. cameraColorGradingTexture: Nullable<BaseTexture>;
  40840. /**
  40841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40843. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  40844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40845. */
  40846. /**
  40847. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40848. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40849. * 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;
  40850. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40851. */
  40852. cameraColorCurves: Nullable<ColorCurves>;
  40853. /**
  40854. * Custom callback helping to override the default shader used in the material.
  40855. */
  40856. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40857. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40858. protected _worldViewProjectionMatrix: Matrix;
  40859. protected _globalAmbientColor: Color3;
  40860. protected _useLogarithmicDepth: boolean;
  40861. /**
  40862. * Instantiates a new standard material.
  40863. * This is the default material used in Babylon. It is the best trade off between quality
  40864. * and performances.
  40865. * @see http://doc.babylonjs.com/babylon101/materials
  40866. * @param name Define the name of the material in the scene
  40867. * @param scene Define the scene the material belong to
  40868. */
  40869. constructor(name: string, scene: Scene);
  40870. /**
  40871. * Gets a boolean indicating that current material needs to register RTT
  40872. */
  40873. readonly hasRenderTargetTextures: boolean;
  40874. /**
  40875. * Gets the current class name of the material e.g. "StandardMaterial"
  40876. * Mainly use in serialization.
  40877. * @returns the class name
  40878. */
  40879. getClassName(): string;
  40880. /**
  40881. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40882. * You can try switching to logarithmic depth.
  40883. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40884. */
  40885. useLogarithmicDepth: boolean;
  40886. /**
  40887. * Specifies if the material will require alpha blending
  40888. * @returns a boolean specifying if alpha blending is needed
  40889. */
  40890. needAlphaBlending(): boolean;
  40891. /**
  40892. * Specifies if this material should be rendered in alpha test mode
  40893. * @returns a boolean specifying if an alpha test is needed.
  40894. */
  40895. needAlphaTesting(): boolean;
  40896. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40897. /**
  40898. * Get the texture used for alpha test purpose.
  40899. * @returns the diffuse texture in case of the standard material.
  40900. */
  40901. getAlphaTestTexture(): Nullable<BaseTexture>;
  40902. /**
  40903. * Get if the submesh is ready to be used and all its information available.
  40904. * Child classes can use it to update shaders
  40905. * @param mesh defines the mesh to check
  40906. * @param subMesh defines which submesh to check
  40907. * @param useInstances specifies that instances should be used
  40908. * @returns a boolean indicating that the submesh is ready or not
  40909. */
  40910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40911. /**
  40912. * Builds the material UBO layouts.
  40913. * Used internally during the effect preparation.
  40914. */
  40915. buildUniformLayout(): void;
  40916. /**
  40917. * Unbinds the material from the mesh
  40918. */
  40919. unbind(): void;
  40920. /**
  40921. * Binds the submesh to this material by preparing the effect and shader to draw
  40922. * @param world defines the world transformation matrix
  40923. * @param mesh defines the mesh containing the submesh
  40924. * @param subMesh defines the submesh to bind the material to
  40925. */
  40926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40927. /**
  40928. * Get the list of animatables in the material.
  40929. * @returns the list of animatables object used in the material
  40930. */
  40931. getAnimatables(): IAnimatable[];
  40932. /**
  40933. * Gets the active textures from the material
  40934. * @returns an array of textures
  40935. */
  40936. getActiveTextures(): BaseTexture[];
  40937. /**
  40938. * Specifies if the material uses a texture
  40939. * @param texture defines the texture to check against the material
  40940. * @returns a boolean specifying if the material uses the texture
  40941. */
  40942. hasTexture(texture: BaseTexture): boolean;
  40943. /**
  40944. * Disposes the material
  40945. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40946. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40947. */
  40948. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40949. /**
  40950. * Makes a duplicate of the material, and gives it a new name
  40951. * @param name defines the new name for the duplicated material
  40952. * @returns the cloned material
  40953. */
  40954. clone(name: string): StandardMaterial;
  40955. /**
  40956. * Serializes this material in a JSON representation
  40957. * @returns the serialized material object
  40958. */
  40959. serialize(): any;
  40960. /**
  40961. * Creates a standard material from parsed material data
  40962. * @param source defines the JSON representation of the material
  40963. * @param scene defines the hosting scene
  40964. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40965. * @returns a new standard material
  40966. */
  40967. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40968. /**
  40969. * Are diffuse textures enabled in the application.
  40970. */
  40971. static DiffuseTextureEnabled: boolean;
  40972. /**
  40973. * Are ambient textures enabled in the application.
  40974. */
  40975. static AmbientTextureEnabled: boolean;
  40976. /**
  40977. * Are opacity textures enabled in the application.
  40978. */
  40979. static OpacityTextureEnabled: boolean;
  40980. /**
  40981. * Are reflection textures enabled in the application.
  40982. */
  40983. static ReflectionTextureEnabled: boolean;
  40984. /**
  40985. * Are emissive textures enabled in the application.
  40986. */
  40987. static EmissiveTextureEnabled: boolean;
  40988. /**
  40989. * Are specular textures enabled in the application.
  40990. */
  40991. static SpecularTextureEnabled: boolean;
  40992. /**
  40993. * Are bump textures enabled in the application.
  40994. */
  40995. static BumpTextureEnabled: boolean;
  40996. /**
  40997. * Are lightmap textures enabled in the application.
  40998. */
  40999. static LightmapTextureEnabled: boolean;
  41000. /**
  41001. * Are refraction textures enabled in the application.
  41002. */
  41003. static RefractionTextureEnabled: boolean;
  41004. /**
  41005. * Are color grading textures enabled in the application.
  41006. */
  41007. static ColorGradingTextureEnabled: boolean;
  41008. /**
  41009. * Are fresnels enabled in the application.
  41010. */
  41011. static FresnelEnabled: boolean;
  41012. }
  41013. }
  41014. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41015. import { Scene } from "babylonjs/scene";
  41016. import { Texture } from "babylonjs/Materials/Textures/texture";
  41017. /**
  41018. * A class extending Texture allowing drawing on a texture
  41019. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41020. */
  41021. export class DynamicTexture extends Texture {
  41022. private _generateMipMaps;
  41023. private _canvas;
  41024. private _context;
  41025. private _engine;
  41026. /**
  41027. * Creates a DynamicTexture
  41028. * @param name defines the name of the texture
  41029. * @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
  41030. * @param scene defines the scene where you want the texture
  41031. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41032. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41033. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41034. */
  41035. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41036. /**
  41037. * Get the current class name of the texture useful for serialization or dynamic coding.
  41038. * @returns "DynamicTexture"
  41039. */
  41040. getClassName(): string;
  41041. /**
  41042. * Gets the current state of canRescale
  41043. */
  41044. readonly canRescale: boolean;
  41045. private _recreate;
  41046. /**
  41047. * Scales the texture
  41048. * @param ratio the scale factor to apply to both width and height
  41049. */
  41050. scale(ratio: number): void;
  41051. /**
  41052. * Resizes the texture
  41053. * @param width the new width
  41054. * @param height the new height
  41055. */
  41056. scaleTo(width: number, height: number): void;
  41057. /**
  41058. * Gets the context of the canvas used by the texture
  41059. * @returns the canvas context of the dynamic texture
  41060. */
  41061. getContext(): CanvasRenderingContext2D;
  41062. /**
  41063. * Clears the texture
  41064. */
  41065. clear(): void;
  41066. /**
  41067. * Updates the texture
  41068. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41069. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41070. */
  41071. update(invertY?: boolean, premulAlpha?: boolean): void;
  41072. /**
  41073. * Draws text onto the texture
  41074. * @param text defines the text to be drawn
  41075. * @param x defines the placement of the text from the left
  41076. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41077. * @param font defines the font to be used with font-style, font-size, font-name
  41078. * @param color defines the color used for the text
  41079. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41080. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41081. * @param update defines whether texture is immediately update (default is true)
  41082. */
  41083. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41084. /**
  41085. * Clones the texture
  41086. * @returns the clone of the texture.
  41087. */
  41088. clone(): DynamicTexture;
  41089. /**
  41090. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41091. * @returns a serialized dynamic texture object
  41092. */
  41093. serialize(): any;
  41094. /** @hidden */
  41095. _rebuild(): void;
  41096. }
  41097. }
  41098. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41099. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41100. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41101. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41102. /** @hidden */
  41103. export var imageProcessingPixelShader: {
  41104. name: string;
  41105. shader: string;
  41106. };
  41107. }
  41108. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41109. import { Nullable } from "babylonjs/types";
  41110. import { Color4 } from "babylonjs/Maths/math";
  41111. import { Camera } from "babylonjs/Cameras/camera";
  41112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41113. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41114. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41116. import { Engine } from "babylonjs/Engines/engine";
  41117. import "babylonjs/Shaders/imageProcessing.fragment";
  41118. import "babylonjs/Shaders/postprocess.vertex";
  41119. /**
  41120. * ImageProcessingPostProcess
  41121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41122. */
  41123. export class ImageProcessingPostProcess extends PostProcess {
  41124. /**
  41125. * Default configuration related to image processing available in the PBR Material.
  41126. */
  41127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41128. /**
  41129. * Gets the image processing configuration used either in this material.
  41130. */
  41131. /**
  41132. * Sets the Default image processing configuration used either in the this material.
  41133. *
  41134. * If sets to null, the scene one is in use.
  41135. */
  41136. imageProcessingConfiguration: ImageProcessingConfiguration;
  41137. /**
  41138. * Keep track of the image processing observer to allow dispose and replace.
  41139. */
  41140. private _imageProcessingObserver;
  41141. /**
  41142. * Attaches a new image processing configuration to the PBR Material.
  41143. * @param configuration
  41144. */
  41145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41146. /**
  41147. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41148. */
  41149. /**
  41150. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41151. */
  41152. colorCurves: Nullable<ColorCurves>;
  41153. /**
  41154. * Gets wether the color curves effect is enabled.
  41155. */
  41156. /**
  41157. * Sets wether the color curves effect is enabled.
  41158. */
  41159. colorCurvesEnabled: boolean;
  41160. /**
  41161. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41162. */
  41163. /**
  41164. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41165. */
  41166. colorGradingTexture: Nullable<BaseTexture>;
  41167. /**
  41168. * Gets wether the color grading effect is enabled.
  41169. */
  41170. /**
  41171. * Gets wether the color grading effect is enabled.
  41172. */
  41173. colorGradingEnabled: boolean;
  41174. /**
  41175. * Gets exposure used in the effect.
  41176. */
  41177. /**
  41178. * Sets exposure used in the effect.
  41179. */
  41180. exposure: number;
  41181. /**
  41182. * Gets wether tonemapping is enabled or not.
  41183. */
  41184. /**
  41185. * Sets wether tonemapping is enabled or not
  41186. */
  41187. toneMappingEnabled: boolean;
  41188. /**
  41189. * Gets the type of tone mapping effect.
  41190. */
  41191. /**
  41192. * Sets the type of tone mapping effect.
  41193. */
  41194. toneMappingType: number;
  41195. /**
  41196. * Gets contrast used in the effect.
  41197. */
  41198. /**
  41199. * Sets contrast used in the effect.
  41200. */
  41201. contrast: number;
  41202. /**
  41203. * Gets Vignette stretch size.
  41204. */
  41205. /**
  41206. * Sets Vignette stretch size.
  41207. */
  41208. vignetteStretch: number;
  41209. /**
  41210. * Gets Vignette centre X Offset.
  41211. */
  41212. /**
  41213. * Sets Vignette centre X Offset.
  41214. */
  41215. vignetteCentreX: number;
  41216. /**
  41217. * Gets Vignette centre Y Offset.
  41218. */
  41219. /**
  41220. * Sets Vignette centre Y Offset.
  41221. */
  41222. vignetteCentreY: number;
  41223. /**
  41224. * Gets Vignette weight or intensity of the vignette effect.
  41225. */
  41226. /**
  41227. * Sets Vignette weight or intensity of the vignette effect.
  41228. */
  41229. vignetteWeight: number;
  41230. /**
  41231. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41232. * if vignetteEnabled is set to true.
  41233. */
  41234. /**
  41235. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41236. * if vignetteEnabled is set to true.
  41237. */
  41238. vignetteColor: Color4;
  41239. /**
  41240. * Gets Camera field of view used by the Vignette effect.
  41241. */
  41242. /**
  41243. * Sets Camera field of view used by the Vignette effect.
  41244. */
  41245. vignetteCameraFov: number;
  41246. /**
  41247. * Gets the vignette blend mode allowing different kind of effect.
  41248. */
  41249. /**
  41250. * Sets the vignette blend mode allowing different kind of effect.
  41251. */
  41252. vignetteBlendMode: number;
  41253. /**
  41254. * Gets wether the vignette effect is enabled.
  41255. */
  41256. /**
  41257. * Sets wether the vignette effect is enabled.
  41258. */
  41259. vignetteEnabled: boolean;
  41260. private _fromLinearSpace;
  41261. /**
  41262. * Gets wether the input of the processing is in Gamma or Linear Space.
  41263. */
  41264. /**
  41265. * Sets wether the input of the processing is in Gamma or Linear Space.
  41266. */
  41267. fromLinearSpace: boolean;
  41268. /**
  41269. * Defines cache preventing GC.
  41270. */
  41271. private _defines;
  41272. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41273. /**
  41274. * "ImageProcessingPostProcess"
  41275. * @returns "ImageProcessingPostProcess"
  41276. */
  41277. getClassName(): string;
  41278. protected _updateParameters(): void;
  41279. dispose(camera?: Camera): void;
  41280. }
  41281. }
  41282. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41283. import { Scene } from "babylonjs/scene";
  41284. import { Color3 } from "babylonjs/Maths/math";
  41285. import { Mesh } from "babylonjs/Meshes/mesh";
  41286. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41287. import { Nullable } from "babylonjs/types";
  41288. /**
  41289. * Class containing static functions to help procedurally build meshes
  41290. */
  41291. export class GroundBuilder {
  41292. /**
  41293. * Creates a ground mesh
  41294. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41295. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41297. * @param name defines the name of the mesh
  41298. * @param options defines the options used to create the mesh
  41299. * @param scene defines the hosting scene
  41300. * @returns the ground mesh
  41301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41302. */
  41303. static CreateGround(name: string, options: {
  41304. width?: number;
  41305. height?: number;
  41306. subdivisions?: number;
  41307. subdivisionsX?: number;
  41308. subdivisionsY?: number;
  41309. updatable?: boolean;
  41310. }, scene: any): Mesh;
  41311. /**
  41312. * Creates a tiled ground mesh
  41313. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41314. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41315. * * 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
  41316. * * 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
  41317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41318. * @param name defines the name of the mesh
  41319. * @param options defines the options used to create the mesh
  41320. * @param scene defines the hosting scene
  41321. * @returns the tiled ground mesh
  41322. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41323. */
  41324. static CreateTiledGround(name: string, options: {
  41325. xmin: number;
  41326. zmin: number;
  41327. xmax: number;
  41328. zmax: number;
  41329. subdivisions?: {
  41330. w: number;
  41331. h: number;
  41332. };
  41333. precision?: {
  41334. w: number;
  41335. h: number;
  41336. };
  41337. updatable?: boolean;
  41338. }, scene?: Nullable<Scene>): Mesh;
  41339. /**
  41340. * Creates a ground mesh from a height map
  41341. * * The parameter `url` sets the URL of the height map image resource.
  41342. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41343. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41344. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41345. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41346. * * 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.
  41347. * * 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).
  41348. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41350. * @param name defines the name of the mesh
  41351. * @param url defines the url to the height map
  41352. * @param options defines the options used to create the mesh
  41353. * @param scene defines the hosting scene
  41354. * @returns the ground mesh
  41355. * @see https://doc.babylonjs.com/babylon101/height_map
  41356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41357. */
  41358. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41359. width?: number;
  41360. height?: number;
  41361. subdivisions?: number;
  41362. minHeight?: number;
  41363. maxHeight?: number;
  41364. colorFilter?: Color3;
  41365. alphaFilter?: number;
  41366. updatable?: boolean;
  41367. onReady?: (mesh: GroundMesh) => void;
  41368. }, scene?: Nullable<Scene>): GroundMesh;
  41369. }
  41370. }
  41371. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41372. import { Vector4 } from "babylonjs/Maths/math";
  41373. import { Mesh } from "babylonjs/Meshes/mesh";
  41374. /**
  41375. * Class containing static functions to help procedurally build meshes
  41376. */
  41377. export class TorusBuilder {
  41378. /**
  41379. * Creates a torus mesh
  41380. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41381. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41382. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41386. * @param name defines the name of the mesh
  41387. * @param options defines the options used to create the mesh
  41388. * @param scene defines the hosting scene
  41389. * @returns the torus mesh
  41390. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41391. */
  41392. static CreateTorus(name: string, options: {
  41393. diameter?: number;
  41394. thickness?: number;
  41395. tessellation?: number;
  41396. updatable?: boolean;
  41397. sideOrientation?: number;
  41398. frontUVs?: Vector4;
  41399. backUVs?: Vector4;
  41400. }, scene: any): Mesh;
  41401. }
  41402. }
  41403. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41404. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41405. import { Mesh } from "babylonjs/Meshes/mesh";
  41406. /**
  41407. * Class containing static functions to help procedurally build meshes
  41408. */
  41409. export class CylinderBuilder {
  41410. /**
  41411. * Creates a cylinder or a cone mesh
  41412. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41413. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41414. * * 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.
  41415. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41416. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41417. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41418. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41419. * * 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).
  41420. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41421. * * 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).
  41422. * * 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
  41423. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41424. * * 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
  41425. * * 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.
  41426. * * If `enclose` is false, a ring surface is one element.
  41427. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41428. * * 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
  41429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41432. * @param name defines the name of the mesh
  41433. * @param options defines the options used to create the mesh
  41434. * @param scene defines the hosting scene
  41435. * @returns the cylinder mesh
  41436. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41437. */
  41438. static CreateCylinder(name: string, options: {
  41439. height?: number;
  41440. diameterTop?: number;
  41441. diameterBottom?: number;
  41442. diameter?: number;
  41443. tessellation?: number;
  41444. subdivisions?: number;
  41445. arc?: number;
  41446. faceColors?: Color4[];
  41447. faceUV?: Vector4[];
  41448. updatable?: boolean;
  41449. hasRings?: boolean;
  41450. enclose?: boolean;
  41451. cap?: number;
  41452. sideOrientation?: number;
  41453. frontUVs?: Vector4;
  41454. backUVs?: Vector4;
  41455. }, scene: any): Mesh;
  41456. }
  41457. }
  41458. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41459. import { Observable } from "babylonjs/Misc/observable";
  41460. import { Nullable } from "babylonjs/types";
  41461. import { Camera } from "babylonjs/Cameras/camera";
  41462. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41463. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41464. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41465. import { Scene } from "babylonjs/scene";
  41466. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41467. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41469. import { Mesh } from "babylonjs/Meshes/mesh";
  41470. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41471. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41472. import "babylonjs/Meshes/Builders/groundBuilder";
  41473. import "babylonjs/Meshes/Builders/torusBuilder";
  41474. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41475. import "babylonjs/Gamepads/gamepadSceneComponent";
  41476. import "babylonjs/Animations/animatable";
  41477. /**
  41478. * Options to modify the vr teleportation behavior.
  41479. */
  41480. export interface VRTeleportationOptions {
  41481. /**
  41482. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41483. */
  41484. floorMeshName?: string;
  41485. /**
  41486. * A list of meshes to be used as the teleportation floor. (default: empty)
  41487. */
  41488. floorMeshes?: Mesh[];
  41489. }
  41490. /**
  41491. * Options to modify the vr experience helper's behavior.
  41492. */
  41493. export interface VRExperienceHelperOptions extends WebVROptions {
  41494. /**
  41495. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41496. */
  41497. createDeviceOrientationCamera?: boolean;
  41498. /**
  41499. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41500. */
  41501. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41502. /**
  41503. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41504. */
  41505. laserToggle?: boolean;
  41506. /**
  41507. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41508. */
  41509. floorMeshes?: Mesh[];
  41510. /**
  41511. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41512. */
  41513. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41514. }
  41515. /**
  41516. * Event containing information after VR has been entered
  41517. */
  41518. export class OnAfterEnteringVRObservableEvent {
  41519. /**
  41520. * If entering vr was successful
  41521. */
  41522. success: boolean;
  41523. }
  41524. /**
  41525. * Helps to quickly add VR support to an existing scene.
  41526. * See http://doc.babylonjs.com/how_to/webvr_helper
  41527. */
  41528. export class VRExperienceHelper {
  41529. /** Options to modify the vr experience helper's behavior. */
  41530. webVROptions: VRExperienceHelperOptions;
  41531. private _scene;
  41532. private _position;
  41533. private _btnVR;
  41534. private _btnVRDisplayed;
  41535. private _webVRsupported;
  41536. private _webVRready;
  41537. private _webVRrequesting;
  41538. private _webVRpresenting;
  41539. private _hasEnteredVR;
  41540. private _fullscreenVRpresenting;
  41541. private _canvas;
  41542. private _webVRCamera;
  41543. private _vrDeviceOrientationCamera;
  41544. private _deviceOrientationCamera;
  41545. private _existingCamera;
  41546. private _onKeyDown;
  41547. private _onVrDisplayPresentChange;
  41548. private _onVRDisplayChanged;
  41549. private _onVRRequestPresentStart;
  41550. private _onVRRequestPresentComplete;
  41551. /**
  41552. * Observable raised right before entering VR.
  41553. */
  41554. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41555. /**
  41556. * Observable raised when entering VR has completed.
  41557. */
  41558. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41559. /**
  41560. * Observable raised when exiting VR.
  41561. */
  41562. onExitingVRObservable: Observable<VRExperienceHelper>;
  41563. /**
  41564. * Observable raised when controller mesh is loaded.
  41565. */
  41566. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41567. /** Return this.onEnteringVRObservable
  41568. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41569. */
  41570. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41571. /** Return this.onExitingVRObservable
  41572. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41573. */
  41574. readonly onExitingVR: Observable<VRExperienceHelper>;
  41575. /** Return this.onControllerMeshLoadedObservable
  41576. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41577. */
  41578. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41579. private _rayLength;
  41580. private _useCustomVRButton;
  41581. private _teleportationRequested;
  41582. private _teleportActive;
  41583. private _floorMeshName;
  41584. private _floorMeshesCollection;
  41585. private _rotationAllowed;
  41586. private _teleportBackwardsVector;
  41587. private _teleportationTarget;
  41588. private _isDefaultTeleportationTarget;
  41589. private _postProcessMove;
  41590. private _teleportationFillColor;
  41591. private _teleportationBorderColor;
  41592. private _rotationAngle;
  41593. private _haloCenter;
  41594. private _cameraGazer;
  41595. private _padSensibilityUp;
  41596. private _padSensibilityDown;
  41597. private _leftController;
  41598. private _rightController;
  41599. /**
  41600. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41601. */
  41602. onNewMeshSelected: Observable<AbstractMesh>;
  41603. /**
  41604. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41605. */
  41606. onNewMeshPicked: Observable<PickingInfo>;
  41607. private _circleEase;
  41608. /**
  41609. * Observable raised before camera teleportation
  41610. */
  41611. onBeforeCameraTeleport: Observable<Vector3>;
  41612. /**
  41613. * Observable raised after camera teleportation
  41614. */
  41615. onAfterCameraTeleport: Observable<Vector3>;
  41616. /**
  41617. * Observable raised when current selected mesh gets unselected
  41618. */
  41619. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41620. private _raySelectionPredicate;
  41621. /**
  41622. * To be optionaly changed by user to define custom ray selection
  41623. */
  41624. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41625. /**
  41626. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41627. */
  41628. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41629. /**
  41630. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41631. */
  41632. teleportationEnabled: boolean;
  41633. private _defaultHeight;
  41634. private _teleportationInitialized;
  41635. private _interactionsEnabled;
  41636. private _interactionsRequested;
  41637. private _displayGaze;
  41638. private _displayLaserPointer;
  41639. /**
  41640. * The mesh used to display where the user is going to teleport.
  41641. */
  41642. /**
  41643. * Sets the mesh to be used to display where the user is going to teleport.
  41644. */
  41645. teleportationTarget: Mesh;
  41646. /**
  41647. * 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
  41648. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41649. * See http://doc.babylonjs.com/resources/baking_transformations
  41650. */
  41651. gazeTrackerMesh: Mesh;
  41652. /**
  41653. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41654. */
  41655. updateGazeTrackerScale: boolean;
  41656. /**
  41657. * If the gaze trackers color should be updated when selecting meshes
  41658. */
  41659. updateGazeTrackerColor: boolean;
  41660. /**
  41661. * The gaze tracking mesh corresponding to the left controller
  41662. */
  41663. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41664. /**
  41665. * The gaze tracking mesh corresponding to the right controller
  41666. */
  41667. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41668. /**
  41669. * If the ray of the gaze should be displayed.
  41670. */
  41671. /**
  41672. * Sets if the ray of the gaze should be displayed.
  41673. */
  41674. displayGaze: boolean;
  41675. /**
  41676. * If the ray of the LaserPointer should be displayed.
  41677. */
  41678. /**
  41679. * Sets if the ray of the LaserPointer should be displayed.
  41680. */
  41681. displayLaserPointer: boolean;
  41682. /**
  41683. * The deviceOrientationCamera used as the camera when not in VR.
  41684. */
  41685. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41686. /**
  41687. * Based on the current WebVR support, returns the current VR camera used.
  41688. */
  41689. readonly currentVRCamera: Nullable<Camera>;
  41690. /**
  41691. * The webVRCamera which is used when in VR.
  41692. */
  41693. readonly webVRCamera: WebVRFreeCamera;
  41694. /**
  41695. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41696. */
  41697. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41698. private readonly _teleportationRequestInitiated;
  41699. /**
  41700. * Defines wether or not Pointer lock should be requested when switching to
  41701. * full screen.
  41702. */
  41703. requestPointerLockOnFullScreen: boolean;
  41704. /**
  41705. * Instantiates a VRExperienceHelper.
  41706. * Helps to quickly add VR support to an existing scene.
  41707. * @param scene The scene the VRExperienceHelper belongs to.
  41708. * @param webVROptions Options to modify the vr experience helper's behavior.
  41709. */
  41710. constructor(scene: Scene,
  41711. /** Options to modify the vr experience helper's behavior. */
  41712. webVROptions?: VRExperienceHelperOptions);
  41713. private _onDefaultMeshLoaded;
  41714. private _onResize;
  41715. private _onFullscreenChange;
  41716. /**
  41717. * Gets a value indicating if we are currently in VR mode.
  41718. */
  41719. readonly isInVRMode: boolean;
  41720. private onVrDisplayPresentChange;
  41721. private onVRDisplayChanged;
  41722. private moveButtonToBottomRight;
  41723. private displayVRButton;
  41724. private updateButtonVisibility;
  41725. private _cachedAngularSensibility;
  41726. /**
  41727. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41728. * Otherwise, will use the fullscreen API.
  41729. */
  41730. enterVR(): void;
  41731. /**
  41732. * Attempt to exit VR, or fullscreen.
  41733. */
  41734. exitVR(): void;
  41735. /**
  41736. * The position of the vr experience helper.
  41737. */
  41738. /**
  41739. * Sets the position of the vr experience helper.
  41740. */
  41741. position: Vector3;
  41742. /**
  41743. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41744. */
  41745. enableInteractions(): void;
  41746. private readonly _noControllerIsActive;
  41747. private beforeRender;
  41748. private _isTeleportationFloor;
  41749. /**
  41750. * Adds a floor mesh to be used for teleportation.
  41751. * @param floorMesh the mesh to be used for teleportation.
  41752. */
  41753. addFloorMesh(floorMesh: Mesh): void;
  41754. /**
  41755. * Removes a floor mesh from being used for teleportation.
  41756. * @param floorMesh the mesh to be removed.
  41757. */
  41758. removeFloorMesh(floorMesh: Mesh): void;
  41759. /**
  41760. * Enables interactions and teleportation using the VR controllers and gaze.
  41761. * @param vrTeleportationOptions options to modify teleportation behavior.
  41762. */
  41763. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41764. private _onNewGamepadConnected;
  41765. private _tryEnableInteractionOnController;
  41766. private _onNewGamepadDisconnected;
  41767. private _enableInteractionOnController;
  41768. private _checkTeleportWithRay;
  41769. private _checkRotate;
  41770. private _checkTeleportBackwards;
  41771. private _enableTeleportationOnController;
  41772. private _createTeleportationCircles;
  41773. private _displayTeleportationTarget;
  41774. private _hideTeleportationTarget;
  41775. private _rotateCamera;
  41776. private _moveTeleportationSelectorTo;
  41777. private _workingVector;
  41778. private _workingQuaternion;
  41779. private _workingMatrix;
  41780. /**
  41781. * Teleports the users feet to the desired location
  41782. * @param location The location where the user's feet should be placed
  41783. */
  41784. teleportCamera(location: Vector3): void;
  41785. private _convertNormalToDirectionOfRay;
  41786. private _castRayAndSelectObject;
  41787. private _notifySelectedMeshUnselected;
  41788. /**
  41789. * Sets the color of the laser ray from the vr controllers.
  41790. * @param color new color for the ray.
  41791. */
  41792. changeLaserColor(color: Color3): void;
  41793. /**
  41794. * Sets the color of the ray from the vr headsets gaze.
  41795. * @param color new color for the ray.
  41796. */
  41797. changeGazeColor(color: Color3): void;
  41798. /**
  41799. * Exits VR and disposes of the vr experience helper
  41800. */
  41801. dispose(): void;
  41802. /**
  41803. * Gets the name of the VRExperienceHelper class
  41804. * @returns "VRExperienceHelper"
  41805. */
  41806. getClassName(): string;
  41807. }
  41808. }
  41809. declare module "babylonjs/Cameras/VR/index" {
  41810. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41811. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41812. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41813. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41814. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41815. export * from "babylonjs/Cameras/VR/webVRCamera";
  41816. }
  41817. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41818. import { Observable } from "babylonjs/Misc/observable";
  41819. import { Nullable } from "babylonjs/types";
  41820. import { IDisposable, Scene } from "babylonjs/scene";
  41821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41822. /**
  41823. * Manages an XRSession to work with Babylon's engine
  41824. * @see https://doc.babylonjs.com/how_to/webxr
  41825. */
  41826. export class WebXRSessionManager implements IDisposable {
  41827. private scene;
  41828. /**
  41829. * Fires every time a new xrFrame arrives which can be used to update the camera
  41830. */
  41831. onXRFrameObservable: Observable<any>;
  41832. /**
  41833. * Fires when the xr session is ended either by the device or manually done
  41834. */
  41835. onXRSessionEnded: Observable<any>;
  41836. /**
  41837. * Underlying xr session
  41838. */
  41839. session: XRSession;
  41840. /**
  41841. * Type of reference space used when creating the session
  41842. */
  41843. referenceSpace: XRReferenceSpace;
  41844. /** @hidden */
  41845. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41846. /**
  41847. * Current XR frame
  41848. */
  41849. currentFrame: Nullable<XRFrame>;
  41850. private _xrNavigator;
  41851. private baseLayer;
  41852. /**
  41853. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41854. * @param scene The scene which the session should be created for
  41855. */
  41856. constructor(scene: Scene);
  41857. /**
  41858. * Initializes the manager
  41859. * After initialization enterXR can be called to start an XR session
  41860. * @returns Promise which resolves after it is initialized
  41861. */
  41862. initializeAsync(): Promise<void>;
  41863. /**
  41864. * Initializes an xr session
  41865. * @param xrSessionMode mode to initialize
  41866. * @returns a promise which will resolve once the session has been initialized
  41867. */
  41868. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41869. /**
  41870. * Sets the reference space on the xr session
  41871. * @param referenceSpace space to set
  41872. * @returns a promise that will resolve once the reference space has been set
  41873. */
  41874. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41875. /**
  41876. * Updates the render state of the session
  41877. * @param state state to set
  41878. * @returns a promise that resolves once the render state has been updated
  41879. */
  41880. updateRenderStateAsync(state: any): Promise<void>;
  41881. /**
  41882. * Starts rendering to the xr layer
  41883. * @returns a promise that will resolve once rendering has started
  41884. */
  41885. startRenderingToXRAsync(): Promise<void>;
  41886. /**
  41887. * Stops the xrSession and restores the renderloop
  41888. * @returns Promise which resolves after it exits XR
  41889. */
  41890. exitXRAsync(): Promise<void>;
  41891. /**
  41892. * Checks if a session would be supported for the creation options specified
  41893. * @param sessionMode session mode to check if supported eg. immersive-vr
  41894. * @returns true if supported
  41895. */
  41896. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41897. /**
  41898. * @hidden
  41899. * Converts the render layer of xrSession to a render target
  41900. * @param session session to create render target for
  41901. * @param scene scene the new render target should be created for
  41902. */
  41903. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41904. /**
  41905. * Disposes of the session manager
  41906. */
  41907. dispose(): void;
  41908. }
  41909. }
  41910. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41911. import { Scene } from "babylonjs/scene";
  41912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41913. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41914. /**
  41915. * WebXR Camera which holds the views for the xrSession
  41916. * @see https://doc.babylonjs.com/how_to/webxr
  41917. */
  41918. export class WebXRCamera extends FreeCamera {
  41919. private static _TmpMatrix;
  41920. /**
  41921. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41922. * @param name the name of the camera
  41923. * @param scene the scene to add the camera to
  41924. */
  41925. constructor(name: string, scene: Scene);
  41926. private _updateNumberOfRigCameras;
  41927. /** @hidden */
  41928. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41929. /**
  41930. * Updates the cameras position from the current pose information of the XR session
  41931. * @param xrSessionManager the session containing pose information
  41932. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41933. */
  41934. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41935. }
  41936. }
  41937. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41938. import { Nullable } from "babylonjs/types";
  41939. import { IDisposable } from "babylonjs/scene";
  41940. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41941. /**
  41942. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41943. */
  41944. export class WebXRManagedOutputCanvas implements IDisposable {
  41945. private helper;
  41946. private _canvas;
  41947. /**
  41948. * xrpresent context of the canvas which can be used to display/mirror xr content
  41949. */
  41950. canvasContext: WebGLRenderingContext;
  41951. /**
  41952. * xr layer for the canvas
  41953. */
  41954. xrLayer: Nullable<XRWebGLLayer>;
  41955. /**
  41956. * Initializes the xr layer for the session
  41957. * @param xrSession xr session
  41958. * @returns a promise that will resolve once the XR Layer has been created
  41959. */
  41960. initializeXRLayerAsync(xrSession: any): any;
  41961. /**
  41962. * Initializes the canvas to be added/removed upon entering/exiting xr
  41963. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41964. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41965. */
  41966. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41967. /**
  41968. * Disposes of the object
  41969. */
  41970. dispose(): void;
  41971. private _setManagedOutputCanvas;
  41972. private _addCanvas;
  41973. private _removeCanvas;
  41974. }
  41975. }
  41976. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41977. import { Observable } from "babylonjs/Misc/observable";
  41978. import { IDisposable, Scene } from "babylonjs/scene";
  41979. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41981. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41982. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41983. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41984. /**
  41985. * States of the webXR experience
  41986. */
  41987. export enum WebXRState {
  41988. /**
  41989. * Transitioning to being in XR mode
  41990. */
  41991. ENTERING_XR = 0,
  41992. /**
  41993. * Transitioning to non XR mode
  41994. */
  41995. EXITING_XR = 1,
  41996. /**
  41997. * In XR mode and presenting
  41998. */
  41999. IN_XR = 2,
  42000. /**
  42001. * Not entered XR mode
  42002. */
  42003. NOT_IN_XR = 3
  42004. }
  42005. /**
  42006. * Helper class used to enable XR
  42007. * @see https://doc.babylonjs.com/how_to/webxr
  42008. */
  42009. export class WebXRExperienceHelper implements IDisposable {
  42010. private scene;
  42011. /**
  42012. * 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
  42013. */
  42014. container: AbstractMesh;
  42015. /**
  42016. * Camera used to render xr content
  42017. */
  42018. camera: WebXRCamera;
  42019. /**
  42020. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42021. */
  42022. state: WebXRState;
  42023. private _setState;
  42024. private static _TmpVector;
  42025. /**
  42026. * Fires when the state of the experience helper has changed
  42027. */
  42028. onStateChangedObservable: Observable<WebXRState>;
  42029. /** Session manager used to keep track of xr session */
  42030. sessionManager: WebXRSessionManager;
  42031. private _nonVRCamera;
  42032. private _originalSceneAutoClear;
  42033. private _supported;
  42034. /**
  42035. * Creates the experience helper
  42036. * @param scene the scene to attach the experience helper to
  42037. * @returns a promise for the experience helper
  42038. */
  42039. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42040. /**
  42041. * Creates a WebXRExperienceHelper
  42042. * @param scene The scene the helper should be created in
  42043. */
  42044. private constructor();
  42045. /**
  42046. * Exits XR mode and returns the scene to its original state
  42047. * @returns promise that resolves after xr mode has exited
  42048. */
  42049. exitXRAsync(): Promise<void>;
  42050. /**
  42051. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42052. * @param sessionCreationOptions options for the XR session
  42053. * @param referenceSpaceType frame of reference of the XR session
  42054. * @param outputCanvas the output canvas that will be used to enter XR mode
  42055. * @returns promise that resolves after xr mode has entered
  42056. */
  42057. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42058. /**
  42059. * Updates the global position of the camera by moving the camera's container
  42060. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42061. * @param position The desired global position of the camera
  42062. */
  42063. setPositionOfCameraUsingContainer(position: Vector3): void;
  42064. /**
  42065. * Rotates the xr camera by rotating the camera's container around the camera's position
  42066. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42067. * @param rotation the desired quaternion rotation to apply to the camera
  42068. */
  42069. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42070. /**
  42071. * Disposes of the experience helper
  42072. */
  42073. dispose(): void;
  42074. }
  42075. }
  42076. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42077. import { Nullable } from "babylonjs/types";
  42078. import { Observable } from "babylonjs/Misc/observable";
  42079. import { IDisposable, Scene } from "babylonjs/scene";
  42080. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42081. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42082. /**
  42083. * Button which can be used to enter a different mode of XR
  42084. */
  42085. export class WebXREnterExitUIButton {
  42086. /** button element */
  42087. element: HTMLElement;
  42088. /** XR initialization options for the button */
  42089. sessionMode: XRSessionMode;
  42090. /** Reference space type */
  42091. referenceSpaceType: XRReferenceSpaceType;
  42092. /**
  42093. * Creates a WebXREnterExitUIButton
  42094. * @param element button element
  42095. * @param sessionMode XR initialization session mode
  42096. * @param referenceSpaceType the type of reference space to be used
  42097. */
  42098. constructor(
  42099. /** button element */
  42100. element: HTMLElement,
  42101. /** XR initialization options for the button */
  42102. sessionMode: XRSessionMode,
  42103. /** Reference space type */
  42104. referenceSpaceType: XRReferenceSpaceType);
  42105. /**
  42106. * Overwritable function which can be used to update the button's visuals when the state changes
  42107. * @param activeButton the current active button in the UI
  42108. */
  42109. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42110. }
  42111. /**
  42112. * Options to create the webXR UI
  42113. */
  42114. export class WebXREnterExitUIOptions {
  42115. /**
  42116. * Context to enter xr with
  42117. */
  42118. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42119. /**
  42120. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42121. */
  42122. customButtons?: Array<WebXREnterExitUIButton>;
  42123. }
  42124. /**
  42125. * UI to allow the user to enter/exit XR mode
  42126. */
  42127. export class WebXREnterExitUI implements IDisposable {
  42128. private scene;
  42129. private _overlay;
  42130. private _buttons;
  42131. private _activeButton;
  42132. /**
  42133. * Fired every time the active button is changed.
  42134. *
  42135. * When xr is entered via a button that launches xr that button will be the callback parameter
  42136. *
  42137. * When exiting xr the callback parameter will be null)
  42138. */
  42139. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42140. /**
  42141. * Creates UI to allow the user to enter/exit XR mode
  42142. * @param scene the scene to add the ui to
  42143. * @param helper the xr experience helper to enter/exit xr with
  42144. * @param options options to configure the UI
  42145. * @returns the created ui
  42146. */
  42147. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42148. private constructor();
  42149. private _updateButtons;
  42150. /**
  42151. * Disposes of the object
  42152. */
  42153. dispose(): void;
  42154. }
  42155. }
  42156. declare module "babylonjs/Cameras/XR/webXRInput" {
  42157. import { Nullable } from "babylonjs/types";
  42158. import { Observable } from "babylonjs/Misc/observable";
  42159. import { IDisposable, Scene } from "babylonjs/scene";
  42160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42161. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42162. /**
  42163. * Represents an XR input
  42164. */
  42165. export class WebXRController {
  42166. private scene;
  42167. /** The underlying input source for the controller */
  42168. inputSource: XRInputSource;
  42169. private parentContainer;
  42170. /**
  42171. * 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
  42172. */
  42173. grip?: AbstractMesh;
  42174. /**
  42175. * Pointer which can be used to select objects or attach a visible laser to
  42176. */
  42177. pointer: AbstractMesh;
  42178. private _tmpMatrix;
  42179. /**
  42180. * Creates the controller
  42181. * @see https://doc.babylonjs.com/how_to/webxr
  42182. * @param scene the scene which the controller should be associated to
  42183. * @param inputSource the underlying input source for the controller
  42184. * @param parentContainer parent that the controller meshes should be children of
  42185. */
  42186. constructor(scene: Scene,
  42187. /** The underlying input source for the controller */
  42188. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42189. /**
  42190. * Updates the controller pose based on the given XRFrame
  42191. * @param xrFrame xr frame to update the pose with
  42192. * @param referenceSpace reference space to use
  42193. */
  42194. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42195. /**
  42196. * Disposes of the object
  42197. */
  42198. dispose(): void;
  42199. }
  42200. /**
  42201. * XR input used to track XR inputs such as controllers/rays
  42202. */
  42203. export class WebXRInput implements IDisposable {
  42204. private helper;
  42205. /**
  42206. * XR controllers being tracked
  42207. */
  42208. controllers: Array<WebXRController>;
  42209. private _frameObserver;
  42210. /**
  42211. * Event when a controller has been connected/added
  42212. */
  42213. onControllerAddedObservable: Observable<WebXRController>;
  42214. /**
  42215. * Event when a controller has been removed/disconnected
  42216. */
  42217. onControllerRemovedObservable: Observable<WebXRController>;
  42218. /**
  42219. * Initializes the WebXRInput
  42220. * @param helper experience helper which the input should be created for
  42221. */
  42222. constructor(helper: WebXRExperienceHelper);
  42223. private _onInputSourcesChange;
  42224. private _addAndRemoveControllers;
  42225. /**
  42226. * Disposes of the object
  42227. */
  42228. dispose(): void;
  42229. }
  42230. }
  42231. declare module "babylonjs/Cameras/XR/index" {
  42232. export * from "babylonjs/Cameras/XR/webXRCamera";
  42233. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42234. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42235. export * from "babylonjs/Cameras/XR/webXRInput";
  42236. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42237. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42238. }
  42239. declare module "babylonjs/Cameras/RigModes/index" {
  42240. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42241. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42242. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42243. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42244. }
  42245. declare module "babylonjs/Cameras/index" {
  42246. export * from "babylonjs/Cameras/Inputs/index";
  42247. export * from "babylonjs/Cameras/cameraInputsManager";
  42248. export * from "babylonjs/Cameras/camera";
  42249. export * from "babylonjs/Cameras/targetCamera";
  42250. export * from "babylonjs/Cameras/freeCamera";
  42251. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42252. export * from "babylonjs/Cameras/touchCamera";
  42253. export * from "babylonjs/Cameras/arcRotateCamera";
  42254. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42255. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42256. export * from "babylonjs/Cameras/flyCamera";
  42257. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42258. export * from "babylonjs/Cameras/followCamera";
  42259. export * from "babylonjs/Cameras/gamepadCamera";
  42260. export * from "babylonjs/Cameras/Stereoscopic/index";
  42261. export * from "babylonjs/Cameras/universalCamera";
  42262. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42263. export * from "babylonjs/Cameras/VR/index";
  42264. export * from "babylonjs/Cameras/XR/index";
  42265. export * from "babylonjs/Cameras/RigModes/index";
  42266. }
  42267. declare module "babylonjs/Collisions/index" {
  42268. export * from "babylonjs/Collisions/collider";
  42269. export * from "babylonjs/Collisions/collisionCoordinator";
  42270. export * from "babylonjs/Collisions/pickingInfo";
  42271. export * from "babylonjs/Collisions/intersectionInfo";
  42272. export * from "babylonjs/Collisions/meshCollisionData";
  42273. }
  42274. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42275. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42276. import { Vector3, Plane } from "babylonjs/Maths/math";
  42277. import { Ray } from "babylonjs/Culling/ray";
  42278. /**
  42279. * Contains an array of blocks representing the octree
  42280. */
  42281. export interface IOctreeContainer<T> {
  42282. /**
  42283. * Blocks within the octree
  42284. */
  42285. blocks: Array<OctreeBlock<T>>;
  42286. }
  42287. /**
  42288. * Class used to store a cell in an octree
  42289. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42290. */
  42291. export class OctreeBlock<T> {
  42292. /**
  42293. * Gets the content of the current block
  42294. */
  42295. entries: T[];
  42296. /**
  42297. * Gets the list of block children
  42298. */
  42299. blocks: Array<OctreeBlock<T>>;
  42300. private _depth;
  42301. private _maxDepth;
  42302. private _capacity;
  42303. private _minPoint;
  42304. private _maxPoint;
  42305. private _boundingVectors;
  42306. private _creationFunc;
  42307. /**
  42308. * Creates a new block
  42309. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42310. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42311. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42312. * @param depth defines the current depth of this block in the octree
  42313. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42314. * @param creationFunc defines a callback to call when an element is added to the block
  42315. */
  42316. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42317. /**
  42318. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42319. */
  42320. readonly capacity: number;
  42321. /**
  42322. * Gets the minimum vector (in world space) of the block's bounding box
  42323. */
  42324. readonly minPoint: Vector3;
  42325. /**
  42326. * Gets the maximum vector (in world space) of the block's bounding box
  42327. */
  42328. readonly maxPoint: Vector3;
  42329. /**
  42330. * Add a new element to this block
  42331. * @param entry defines the element to add
  42332. */
  42333. addEntry(entry: T): void;
  42334. /**
  42335. * Remove an element from this block
  42336. * @param entry defines the element to remove
  42337. */
  42338. removeEntry(entry: T): void;
  42339. /**
  42340. * Add an array of elements to this block
  42341. * @param entries defines the array of elements to add
  42342. */
  42343. addEntries(entries: T[]): void;
  42344. /**
  42345. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42346. * @param frustumPlanes defines the frustum planes to test
  42347. * @param selection defines the array to store current content if selection is positive
  42348. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42349. */
  42350. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42351. /**
  42352. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42353. * @param sphereCenter defines the bounding sphere center
  42354. * @param sphereRadius defines the bounding sphere radius
  42355. * @param selection defines the array to store current content if selection is positive
  42356. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42357. */
  42358. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42359. /**
  42360. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42361. * @param ray defines the ray to test with
  42362. * @param selection defines the array to store current content if selection is positive
  42363. */
  42364. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42365. /**
  42366. * Subdivide the content into child blocks (this block will then be empty)
  42367. */
  42368. createInnerBlocks(): void;
  42369. /**
  42370. * @hidden
  42371. */
  42372. 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;
  42373. }
  42374. }
  42375. declare module "babylonjs/Culling/Octrees/octree" {
  42376. import { SmartArray } from "babylonjs/Misc/smartArray";
  42377. import { Vector3, Plane } from "babylonjs/Maths/math";
  42378. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42380. import { Ray } from "babylonjs/Culling/ray";
  42381. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42382. /**
  42383. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42384. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42385. */
  42386. export class Octree<T> {
  42387. /** 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.) */
  42388. maxDepth: number;
  42389. /**
  42390. * Blocks within the octree containing objects
  42391. */
  42392. blocks: Array<OctreeBlock<T>>;
  42393. /**
  42394. * Content stored in the octree
  42395. */
  42396. dynamicContent: T[];
  42397. private _maxBlockCapacity;
  42398. private _selectionContent;
  42399. private _creationFunc;
  42400. /**
  42401. * Creates a octree
  42402. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42403. * @param creationFunc function to be used to instatiate the octree
  42404. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42405. * @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.)
  42406. */
  42407. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42408. /** 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.) */
  42409. maxDepth?: number);
  42410. /**
  42411. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42412. * @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);
  42413. * @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);
  42414. * @param entries meshes to be added to the octree blocks
  42415. */
  42416. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42417. /**
  42418. * Adds a mesh to the octree
  42419. * @param entry Mesh to add to the octree
  42420. */
  42421. addMesh(entry: T): void;
  42422. /**
  42423. * Remove an element from the octree
  42424. * @param entry defines the element to remove
  42425. */
  42426. removeMesh(entry: T): void;
  42427. /**
  42428. * Selects an array of meshes within the frustum
  42429. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42430. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42431. * @returns array of meshes within the frustum
  42432. */
  42433. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42434. /**
  42435. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42436. * @param sphereCenter defines the bounding sphere center
  42437. * @param sphereRadius defines the bounding sphere radius
  42438. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42439. * @returns an array of objects that intersect the sphere
  42440. */
  42441. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42442. /**
  42443. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42444. * @param ray defines the ray to test with
  42445. * @returns array of intersected objects
  42446. */
  42447. intersectsRay(ray: Ray): SmartArray<T>;
  42448. /**
  42449. * Adds a mesh into the octree block if it intersects the block
  42450. */
  42451. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42452. /**
  42453. * Adds a submesh into the octree block if it intersects the block
  42454. */
  42455. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42456. }
  42457. }
  42458. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42459. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42460. import { Scene } from "babylonjs/scene";
  42461. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42463. import { Ray } from "babylonjs/Culling/ray";
  42464. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42465. import { Collider } from "babylonjs/Collisions/collider";
  42466. module "babylonjs/scene" {
  42467. interface Scene {
  42468. /**
  42469. * @hidden
  42470. * Backing Filed
  42471. */
  42472. _selectionOctree: Octree<AbstractMesh>;
  42473. /**
  42474. * Gets the octree used to boost mesh selection (picking)
  42475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42476. */
  42477. selectionOctree: Octree<AbstractMesh>;
  42478. /**
  42479. * Creates or updates the octree used to boost selection (picking)
  42480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42481. * @param maxCapacity defines the maximum capacity per leaf
  42482. * @param maxDepth defines the maximum depth of the octree
  42483. * @returns an octree of AbstractMesh
  42484. */
  42485. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42486. }
  42487. }
  42488. module "babylonjs/Meshes/abstractMesh" {
  42489. interface AbstractMesh {
  42490. /**
  42491. * @hidden
  42492. * Backing Field
  42493. */
  42494. _submeshesOctree: Octree<SubMesh>;
  42495. /**
  42496. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42497. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42498. * @param maxCapacity defines the maximum size of each block (64 by default)
  42499. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42500. * @returns the new octree
  42501. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42503. */
  42504. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42505. }
  42506. }
  42507. /**
  42508. * Defines the octree scene component responsible to manage any octrees
  42509. * in a given scene.
  42510. */
  42511. export class OctreeSceneComponent {
  42512. /**
  42513. * The component name help to identify the component in the list of scene components.
  42514. */
  42515. readonly name: string;
  42516. /**
  42517. * The scene the component belongs to.
  42518. */
  42519. scene: Scene;
  42520. /**
  42521. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42522. */
  42523. readonly checksIsEnabled: boolean;
  42524. /**
  42525. * Creates a new instance of the component for the given scene
  42526. * @param scene Defines the scene to register the component in
  42527. */
  42528. constructor(scene: Scene);
  42529. /**
  42530. * Registers the component in a given scene
  42531. */
  42532. register(): void;
  42533. /**
  42534. * Return the list of active meshes
  42535. * @returns the list of active meshes
  42536. */
  42537. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42538. /**
  42539. * Return the list of active sub meshes
  42540. * @param mesh The mesh to get the candidates sub meshes from
  42541. * @returns the list of active sub meshes
  42542. */
  42543. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42544. private _tempRay;
  42545. /**
  42546. * Return the list of sub meshes intersecting with a given local ray
  42547. * @param mesh defines the mesh to find the submesh for
  42548. * @param localRay defines the ray in local space
  42549. * @returns the list of intersecting sub meshes
  42550. */
  42551. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42552. /**
  42553. * Return the list of sub meshes colliding with a collider
  42554. * @param mesh defines the mesh to find the submesh for
  42555. * @param collider defines the collider to evaluate the collision against
  42556. * @returns the list of colliding sub meshes
  42557. */
  42558. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42559. /**
  42560. * Rebuilds the elements related to this component in case of
  42561. * context lost for instance.
  42562. */
  42563. rebuild(): void;
  42564. /**
  42565. * Disposes the component and the associated ressources.
  42566. */
  42567. dispose(): void;
  42568. }
  42569. }
  42570. declare module "babylonjs/Culling/Octrees/index" {
  42571. export * from "babylonjs/Culling/Octrees/octree";
  42572. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42573. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42574. }
  42575. declare module "babylonjs/Culling/index" {
  42576. export * from "babylonjs/Culling/boundingBox";
  42577. export * from "babylonjs/Culling/boundingInfo";
  42578. export * from "babylonjs/Culling/boundingSphere";
  42579. export * from "babylonjs/Culling/Octrees/index";
  42580. export * from "babylonjs/Culling/ray";
  42581. }
  42582. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42583. import { IDisposable, Scene } from "babylonjs/scene";
  42584. import { Nullable } from "babylonjs/types";
  42585. import { Observable } from "babylonjs/Misc/observable";
  42586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42587. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42588. import { Camera } from "babylonjs/Cameras/camera";
  42589. /**
  42590. * Renders a layer on top of an existing scene
  42591. */
  42592. export class UtilityLayerRenderer implements IDisposable {
  42593. /** the original scene that will be rendered on top of */
  42594. originalScene: Scene;
  42595. private _pointerCaptures;
  42596. private _lastPointerEvents;
  42597. private static _DefaultUtilityLayer;
  42598. private static _DefaultKeepDepthUtilityLayer;
  42599. private _sharedGizmoLight;
  42600. private _renderCamera;
  42601. /**
  42602. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42603. * @returns the camera that is used when rendering the utility layer
  42604. */
  42605. getRenderCamera(): Nullable<Camera>;
  42606. /**
  42607. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42608. * @param cam the camera that should be used when rendering the utility layer
  42609. */
  42610. setRenderCamera(cam: Nullable<Camera>): void;
  42611. /**
  42612. * @hidden
  42613. * Light which used by gizmos to get light shading
  42614. */
  42615. _getSharedGizmoLight(): HemisphericLight;
  42616. /**
  42617. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42618. */
  42619. pickUtilitySceneFirst: boolean;
  42620. /**
  42621. * 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)
  42622. */
  42623. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42624. /**
  42625. * 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)
  42626. */
  42627. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42628. /**
  42629. * The scene that is rendered on top of the original scene
  42630. */
  42631. utilityLayerScene: Scene;
  42632. /**
  42633. * If the utility layer should automatically be rendered on top of existing scene
  42634. */
  42635. shouldRender: boolean;
  42636. /**
  42637. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42638. */
  42639. onlyCheckPointerDownEvents: boolean;
  42640. /**
  42641. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42642. */
  42643. processAllEvents: boolean;
  42644. /**
  42645. * Observable raised when the pointer move from the utility layer scene to the main scene
  42646. */
  42647. onPointerOutObservable: Observable<number>;
  42648. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42649. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42650. private _afterRenderObserver;
  42651. private _sceneDisposeObserver;
  42652. private _originalPointerObserver;
  42653. /**
  42654. * Instantiates a UtilityLayerRenderer
  42655. * @param originalScene the original scene that will be rendered on top of
  42656. * @param handleEvents boolean indicating if the utility layer should handle events
  42657. */
  42658. constructor(
  42659. /** the original scene that will be rendered on top of */
  42660. originalScene: Scene, handleEvents?: boolean);
  42661. private _notifyObservers;
  42662. /**
  42663. * Renders the utility layers scene on top of the original scene
  42664. */
  42665. render(): void;
  42666. /**
  42667. * Disposes of the renderer
  42668. */
  42669. dispose(): void;
  42670. private _updateCamera;
  42671. }
  42672. }
  42673. declare module "babylonjs/Gizmos/gizmo" {
  42674. import { Nullable } from "babylonjs/types";
  42675. import { IDisposable } from "babylonjs/scene";
  42676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42677. import { Mesh } from "babylonjs/Meshes/mesh";
  42678. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42679. /**
  42680. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42681. */
  42682. export class Gizmo implements IDisposable {
  42683. /** The utility layer the gizmo will be added to */
  42684. gizmoLayer: UtilityLayerRenderer;
  42685. /**
  42686. * The root mesh of the gizmo
  42687. */
  42688. _rootMesh: Mesh;
  42689. private _attachedMesh;
  42690. /**
  42691. * Ratio for the scale of the gizmo (Default: 1)
  42692. */
  42693. scaleRatio: number;
  42694. /**
  42695. * If a custom mesh has been set (Default: false)
  42696. */
  42697. protected _customMeshSet: boolean;
  42698. /**
  42699. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42700. * * When set, interactions will be enabled
  42701. */
  42702. attachedMesh: Nullable<AbstractMesh>;
  42703. /**
  42704. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42705. * @param mesh The mesh to replace the default mesh of the gizmo
  42706. */
  42707. setCustomMesh(mesh: Mesh): void;
  42708. /**
  42709. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42710. */
  42711. updateGizmoRotationToMatchAttachedMesh: boolean;
  42712. /**
  42713. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42714. */
  42715. updateGizmoPositionToMatchAttachedMesh: boolean;
  42716. /**
  42717. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42718. */
  42719. protected _updateScale: boolean;
  42720. protected _interactionsEnabled: boolean;
  42721. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42722. private _beforeRenderObserver;
  42723. private _tempVector;
  42724. /**
  42725. * Creates a gizmo
  42726. * @param gizmoLayer The utility layer the gizmo will be added to
  42727. */
  42728. constructor(
  42729. /** The utility layer the gizmo will be added to */
  42730. gizmoLayer?: UtilityLayerRenderer);
  42731. /**
  42732. * Updates the gizmo to match the attached mesh's position/rotation
  42733. */
  42734. protected _update(): void;
  42735. /**
  42736. * Disposes of the gizmo
  42737. */
  42738. dispose(): void;
  42739. }
  42740. }
  42741. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42742. import { Observable } from "babylonjs/Misc/observable";
  42743. import { Nullable } from "babylonjs/types";
  42744. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42745. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42747. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42748. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42750. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42751. import { Scene } from "babylonjs/scene";
  42752. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42753. /**
  42754. * Single plane drag gizmo
  42755. */
  42756. export class PlaneDragGizmo extends Gizmo {
  42757. /**
  42758. * Drag behavior responsible for the gizmos dragging interactions
  42759. */
  42760. dragBehavior: PointerDragBehavior;
  42761. private _pointerObserver;
  42762. /**
  42763. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42764. */
  42765. snapDistance: number;
  42766. /**
  42767. * Event that fires each time the gizmo snaps to a new location.
  42768. * * snapDistance is the the change in distance
  42769. */
  42770. onSnapObservable: Observable<{
  42771. snapDistance: number;
  42772. }>;
  42773. private _plane;
  42774. private _coloredMaterial;
  42775. private _hoverMaterial;
  42776. private _isEnabled;
  42777. private _parent;
  42778. /** @hidden */
  42779. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42780. /** @hidden */
  42781. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42782. /**
  42783. * Creates a PlaneDragGizmo
  42784. * @param gizmoLayer The utility layer the gizmo will be added to
  42785. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42786. * @param color The color of the gizmo
  42787. */
  42788. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42789. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42790. /**
  42791. * If the gizmo is enabled
  42792. */
  42793. isEnabled: boolean;
  42794. /**
  42795. * Disposes of the gizmo
  42796. */
  42797. dispose(): void;
  42798. }
  42799. }
  42800. declare module "babylonjs/Gizmos/positionGizmo" {
  42801. import { Observable } from "babylonjs/Misc/observable";
  42802. import { Nullable } from "babylonjs/types";
  42803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42804. import { Mesh } from "babylonjs/Meshes/mesh";
  42805. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42806. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42807. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42808. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42809. /**
  42810. * Gizmo that enables dragging a mesh along 3 axis
  42811. */
  42812. export class PositionGizmo extends Gizmo {
  42813. /**
  42814. * Internal gizmo used for interactions on the x axis
  42815. */
  42816. xGizmo: AxisDragGizmo;
  42817. /**
  42818. * Internal gizmo used for interactions on the y axis
  42819. */
  42820. yGizmo: AxisDragGizmo;
  42821. /**
  42822. * Internal gizmo used for interactions on the z axis
  42823. */
  42824. zGizmo: AxisDragGizmo;
  42825. /**
  42826. * Internal gizmo used for interactions on the yz plane
  42827. */
  42828. xPlaneGizmo: PlaneDragGizmo;
  42829. /**
  42830. * Internal gizmo used for interactions on the xz plane
  42831. */
  42832. yPlaneGizmo: PlaneDragGizmo;
  42833. /**
  42834. * Internal gizmo used for interactions on the xy plane
  42835. */
  42836. zPlaneGizmo: PlaneDragGizmo;
  42837. /**
  42838. * private variables
  42839. */
  42840. private _meshAttached;
  42841. private _updateGizmoRotationToMatchAttachedMesh;
  42842. private _snapDistance;
  42843. private _scaleRatio;
  42844. /** Fires an event when any of it's sub gizmos are dragged */
  42845. onDragStartObservable: Observable<unknown>;
  42846. /** Fires an event when any of it's sub gizmos are released from dragging */
  42847. onDragEndObservable: Observable<unknown>;
  42848. /**
  42849. * If set to true, planar drag is enabled
  42850. */
  42851. private _planarGizmoEnabled;
  42852. attachedMesh: Nullable<AbstractMesh>;
  42853. /**
  42854. * Creates a PositionGizmo
  42855. * @param gizmoLayer The utility layer the gizmo will be added to
  42856. */
  42857. constructor(gizmoLayer?: UtilityLayerRenderer);
  42858. /**
  42859. * If the planar drag gizmo is enabled
  42860. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42861. */
  42862. planarGizmoEnabled: boolean;
  42863. updateGizmoRotationToMatchAttachedMesh: boolean;
  42864. /**
  42865. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42866. */
  42867. snapDistance: number;
  42868. /**
  42869. * Ratio for the scale of the gizmo (Default: 1)
  42870. */
  42871. scaleRatio: number;
  42872. /**
  42873. * Disposes of the gizmo
  42874. */
  42875. dispose(): void;
  42876. /**
  42877. * CustomMeshes are not supported by this gizmo
  42878. * @param mesh The mesh to replace the default mesh of the gizmo
  42879. */
  42880. setCustomMesh(mesh: Mesh): void;
  42881. }
  42882. }
  42883. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42884. import { Observable } from "babylonjs/Misc/observable";
  42885. import { Nullable } from "babylonjs/types";
  42886. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42889. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42890. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42891. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42892. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42893. import { Scene } from "babylonjs/scene";
  42894. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42895. /**
  42896. * Single axis drag gizmo
  42897. */
  42898. export class AxisDragGizmo extends Gizmo {
  42899. /**
  42900. * Drag behavior responsible for the gizmos dragging interactions
  42901. */
  42902. dragBehavior: PointerDragBehavior;
  42903. private _pointerObserver;
  42904. /**
  42905. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42906. */
  42907. snapDistance: number;
  42908. /**
  42909. * Event that fires each time the gizmo snaps to a new location.
  42910. * * snapDistance is the the change in distance
  42911. */
  42912. onSnapObservable: Observable<{
  42913. snapDistance: number;
  42914. }>;
  42915. private _isEnabled;
  42916. private _parent;
  42917. private _arrow;
  42918. private _coloredMaterial;
  42919. private _hoverMaterial;
  42920. /** @hidden */
  42921. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42922. /** @hidden */
  42923. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42924. /**
  42925. * Creates an AxisDragGizmo
  42926. * @param gizmoLayer The utility layer the gizmo will be added to
  42927. * @param dragAxis The axis which the gizmo will be able to drag on
  42928. * @param color The color of the gizmo
  42929. */
  42930. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42932. /**
  42933. * If the gizmo is enabled
  42934. */
  42935. isEnabled: boolean;
  42936. /**
  42937. * Disposes of the gizmo
  42938. */
  42939. dispose(): void;
  42940. }
  42941. }
  42942. declare module "babylonjs/Debug/axesViewer" {
  42943. import { Vector3 } from "babylonjs/Maths/math";
  42944. import { Nullable } from "babylonjs/types";
  42945. import { Scene } from "babylonjs/scene";
  42946. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42947. /**
  42948. * The Axes viewer will show 3 axes in a specific point in space
  42949. */
  42950. export class AxesViewer {
  42951. private _xAxis;
  42952. private _yAxis;
  42953. private _zAxis;
  42954. private _scaleLinesFactor;
  42955. private _instanced;
  42956. /**
  42957. * Gets the hosting scene
  42958. */
  42959. scene: Scene;
  42960. /**
  42961. * Gets or sets a number used to scale line length
  42962. */
  42963. scaleLines: number;
  42964. /** Gets the node hierarchy used to render x-axis */
  42965. readonly xAxis: TransformNode;
  42966. /** Gets the node hierarchy used to render y-axis */
  42967. readonly yAxis: TransformNode;
  42968. /** Gets the node hierarchy used to render z-axis */
  42969. readonly zAxis: TransformNode;
  42970. /**
  42971. * Creates a new AxesViewer
  42972. * @param scene defines the hosting scene
  42973. * @param scaleLines defines a number used to scale line length (1 by default)
  42974. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42975. * @param xAxis defines the node hierarchy used to render the x-axis
  42976. * @param yAxis defines the node hierarchy used to render the y-axis
  42977. * @param zAxis defines the node hierarchy used to render the z-axis
  42978. */
  42979. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42980. /**
  42981. * Force the viewer to update
  42982. * @param position defines the position of the viewer
  42983. * @param xaxis defines the x axis of the viewer
  42984. * @param yaxis defines the y axis of the viewer
  42985. * @param zaxis defines the z axis of the viewer
  42986. */
  42987. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42988. /**
  42989. * Creates an instance of this axes viewer.
  42990. * @returns a new axes viewer with instanced meshes
  42991. */
  42992. createInstance(): AxesViewer;
  42993. /** Releases resources */
  42994. dispose(): void;
  42995. private static _SetRenderingGroupId;
  42996. }
  42997. }
  42998. declare module "babylonjs/Debug/boneAxesViewer" {
  42999. import { Nullable } from "babylonjs/types";
  43000. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  43001. import { Vector3 } from "babylonjs/Maths/math";
  43002. import { Mesh } from "babylonjs/Meshes/mesh";
  43003. import { Bone } from "babylonjs/Bones/bone";
  43004. import { Scene } from "babylonjs/scene";
  43005. /**
  43006. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43007. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43008. */
  43009. export class BoneAxesViewer extends AxesViewer {
  43010. /**
  43011. * Gets or sets the target mesh where to display the axes viewer
  43012. */
  43013. mesh: Nullable<Mesh>;
  43014. /**
  43015. * Gets or sets the target bone where to display the axes viewer
  43016. */
  43017. bone: Nullable<Bone>;
  43018. /** Gets current position */
  43019. pos: Vector3;
  43020. /** Gets direction of X axis */
  43021. xaxis: Vector3;
  43022. /** Gets direction of Y axis */
  43023. yaxis: Vector3;
  43024. /** Gets direction of Z axis */
  43025. zaxis: Vector3;
  43026. /**
  43027. * Creates a new BoneAxesViewer
  43028. * @param scene defines the hosting scene
  43029. * @param bone defines the target bone
  43030. * @param mesh defines the target mesh
  43031. * @param scaleLines defines a scaling factor for line length (1 by default)
  43032. */
  43033. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43034. /**
  43035. * Force the viewer to update
  43036. */
  43037. update(): void;
  43038. /** Releases resources */
  43039. dispose(): void;
  43040. }
  43041. }
  43042. declare module "babylonjs/Debug/debugLayer" {
  43043. import { Scene } from "babylonjs/scene";
  43044. /**
  43045. * Interface used to define scene explorer extensibility option
  43046. */
  43047. export interface IExplorerExtensibilityOption {
  43048. /**
  43049. * Define the option label
  43050. */
  43051. label: string;
  43052. /**
  43053. * Defines the action to execute on click
  43054. */
  43055. action: (entity: any) => void;
  43056. }
  43057. /**
  43058. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43059. */
  43060. export interface IExplorerExtensibilityGroup {
  43061. /**
  43062. * Defines a predicate to test if a given type mut be extended
  43063. */
  43064. predicate: (entity: any) => boolean;
  43065. /**
  43066. * Gets the list of options added to a type
  43067. */
  43068. entries: IExplorerExtensibilityOption[];
  43069. }
  43070. /**
  43071. * Interface used to define the options to use to create the Inspector
  43072. */
  43073. export interface IInspectorOptions {
  43074. /**
  43075. * Display in overlay mode (default: false)
  43076. */
  43077. overlay?: boolean;
  43078. /**
  43079. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43080. */
  43081. globalRoot?: HTMLElement;
  43082. /**
  43083. * Display the Scene explorer
  43084. */
  43085. showExplorer?: boolean;
  43086. /**
  43087. * Display the property inspector
  43088. */
  43089. showInspector?: boolean;
  43090. /**
  43091. * Display in embed mode (both panes on the right)
  43092. */
  43093. embedMode?: boolean;
  43094. /**
  43095. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43096. */
  43097. handleResize?: boolean;
  43098. /**
  43099. * Allow the panes to popup (default: true)
  43100. */
  43101. enablePopup?: boolean;
  43102. /**
  43103. * Allow the panes to be closed by users (default: true)
  43104. */
  43105. enableClose?: boolean;
  43106. /**
  43107. * Optional list of extensibility entries
  43108. */
  43109. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43110. /**
  43111. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43112. */
  43113. inspectorURL?: string;
  43114. }
  43115. module "babylonjs/scene" {
  43116. interface Scene {
  43117. /**
  43118. * @hidden
  43119. * Backing field
  43120. */
  43121. _debugLayer: DebugLayer;
  43122. /**
  43123. * Gets the debug layer (aka Inspector) associated with the scene
  43124. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43125. */
  43126. debugLayer: DebugLayer;
  43127. }
  43128. }
  43129. /**
  43130. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43131. * what is happening in your scene
  43132. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43133. */
  43134. export class DebugLayer {
  43135. /**
  43136. * Define the url to get the inspector script from.
  43137. * By default it uses the babylonjs CDN.
  43138. * @ignoreNaming
  43139. */
  43140. static InspectorURL: string;
  43141. private _scene;
  43142. private BJSINSPECTOR;
  43143. private _onPropertyChangedObservable?;
  43144. /**
  43145. * Observable triggered when a property is changed through the inspector.
  43146. */
  43147. readonly onPropertyChangedObservable: any;
  43148. /**
  43149. * Instantiates a new debug layer.
  43150. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43151. * what is happening in your scene
  43152. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43153. * @param scene Defines the scene to inspect
  43154. */
  43155. constructor(scene: Scene);
  43156. /** Creates the inspector window. */
  43157. private _createInspector;
  43158. /**
  43159. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43160. * @param entity defines the entity to select
  43161. * @param lineContainerTitle defines the specific block to highlight
  43162. */
  43163. select(entity: any, lineContainerTitle?: string): void;
  43164. /** Get the inspector from bundle or global */
  43165. private _getGlobalInspector;
  43166. /**
  43167. * Get if the inspector is visible or not.
  43168. * @returns true if visible otherwise, false
  43169. */
  43170. isVisible(): boolean;
  43171. /**
  43172. * Hide the inspector and close its window.
  43173. */
  43174. hide(): void;
  43175. /**
  43176. * Launch the debugLayer.
  43177. * @param config Define the configuration of the inspector
  43178. * @return a promise fulfilled when the debug layer is visible
  43179. */
  43180. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43181. }
  43182. }
  43183. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43184. import { Nullable } from "babylonjs/types";
  43185. import { Scene } from "babylonjs/scene";
  43186. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43187. import { Mesh } from "babylonjs/Meshes/mesh";
  43188. /**
  43189. * Class containing static functions to help procedurally build meshes
  43190. */
  43191. export class BoxBuilder {
  43192. /**
  43193. * Creates a box mesh
  43194. * * The parameter `size` sets the size (float) of each box side (default 1)
  43195. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43196. * * 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)
  43197. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43201. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43202. * @param name defines the name of the mesh
  43203. * @param options defines the options used to create the mesh
  43204. * @param scene defines the hosting scene
  43205. * @returns the box mesh
  43206. */
  43207. static CreateBox(name: string, options: {
  43208. size?: number;
  43209. width?: number;
  43210. height?: number;
  43211. depth?: number;
  43212. faceUV?: Vector4[];
  43213. faceColors?: Color4[];
  43214. sideOrientation?: number;
  43215. frontUVs?: Vector4;
  43216. backUVs?: Vector4;
  43217. wrap?: boolean;
  43218. topBaseAt?: number;
  43219. bottomBaseAt?: number;
  43220. updatable?: boolean;
  43221. }, scene?: Nullable<Scene>): Mesh;
  43222. }
  43223. }
  43224. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43225. import { Vector4 } from "babylonjs/Maths/math";
  43226. import { Mesh } from "babylonjs/Meshes/mesh";
  43227. /**
  43228. * Class containing static functions to help procedurally build meshes
  43229. */
  43230. export class SphereBuilder {
  43231. /**
  43232. * Creates a sphere mesh
  43233. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43234. * * 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`)
  43235. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43236. * * 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
  43237. * * 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)
  43238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43241. * @param name defines the name of the mesh
  43242. * @param options defines the options used to create the mesh
  43243. * @param scene defines the hosting scene
  43244. * @returns the sphere mesh
  43245. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43246. */
  43247. static CreateSphere(name: string, options: {
  43248. segments?: number;
  43249. diameter?: number;
  43250. diameterX?: number;
  43251. diameterY?: number;
  43252. diameterZ?: number;
  43253. arc?: number;
  43254. slice?: number;
  43255. sideOrientation?: number;
  43256. frontUVs?: Vector4;
  43257. backUVs?: Vector4;
  43258. updatable?: boolean;
  43259. }, scene: any): Mesh;
  43260. }
  43261. }
  43262. declare module "babylonjs/Debug/physicsViewer" {
  43263. import { Nullable } from "babylonjs/types";
  43264. import { Scene } from "babylonjs/scene";
  43265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43266. import { Mesh } from "babylonjs/Meshes/mesh";
  43267. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43268. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43269. /**
  43270. * Used to show the physics impostor around the specific mesh
  43271. */
  43272. export class PhysicsViewer {
  43273. /** @hidden */
  43274. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43275. /** @hidden */
  43276. protected _meshes: Array<Nullable<AbstractMesh>>;
  43277. /** @hidden */
  43278. protected _scene: Nullable<Scene>;
  43279. /** @hidden */
  43280. protected _numMeshes: number;
  43281. /** @hidden */
  43282. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43283. private _renderFunction;
  43284. private _utilityLayer;
  43285. private _debugBoxMesh;
  43286. private _debugSphereMesh;
  43287. private _debugCylinderMesh;
  43288. private _debugMaterial;
  43289. private _debugMeshMeshes;
  43290. /**
  43291. * Creates a new PhysicsViewer
  43292. * @param scene defines the hosting scene
  43293. */
  43294. constructor(scene: Scene);
  43295. /** @hidden */
  43296. protected _updateDebugMeshes(): void;
  43297. /**
  43298. * Renders a specified physic impostor
  43299. * @param impostor defines the impostor to render
  43300. * @param targetMesh defines the mesh represented by the impostor
  43301. * @returns the new debug mesh used to render the impostor
  43302. */
  43303. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43304. /**
  43305. * Hides a specified physic impostor
  43306. * @param impostor defines the impostor to hide
  43307. */
  43308. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43309. private _getDebugMaterial;
  43310. private _getDebugBoxMesh;
  43311. private _getDebugSphereMesh;
  43312. private _getDebugCylinderMesh;
  43313. private _getDebugMeshMesh;
  43314. private _getDebugMesh;
  43315. /** Releases all resources */
  43316. dispose(): void;
  43317. }
  43318. }
  43319. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43320. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43321. import { Nullable } from "babylonjs/types";
  43322. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43323. import { Scene } from "babylonjs/scene";
  43324. /**
  43325. * Class containing static functions to help procedurally build meshes
  43326. */
  43327. export class LinesBuilder {
  43328. /**
  43329. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43330. * * 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
  43331. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43332. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43333. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43334. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43335. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43336. * * 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
  43337. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43340. * @param name defines the name of the new line system
  43341. * @param options defines the options used to create the line system
  43342. * @param scene defines the hosting scene
  43343. * @returns a new line system mesh
  43344. */
  43345. static CreateLineSystem(name: string, options: {
  43346. lines: Vector3[][];
  43347. updatable?: boolean;
  43348. instance?: Nullable<LinesMesh>;
  43349. colors?: Nullable<Color4[][]>;
  43350. useVertexAlpha?: boolean;
  43351. }, scene: Nullable<Scene>): LinesMesh;
  43352. /**
  43353. * Creates a line mesh
  43354. * 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
  43355. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43356. * * The parameter `points` is an array successive Vector3
  43357. * * 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
  43358. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43359. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43360. * * When updating an instance, remember that only point positions can change, not the number of points
  43361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43363. * @param name defines the name of the new line system
  43364. * @param options defines the options used to create the line system
  43365. * @param scene defines the hosting scene
  43366. * @returns a new line mesh
  43367. */
  43368. static CreateLines(name: string, options: {
  43369. points: Vector3[];
  43370. updatable?: boolean;
  43371. instance?: Nullable<LinesMesh>;
  43372. colors?: Color4[];
  43373. useVertexAlpha?: boolean;
  43374. }, scene?: Nullable<Scene>): LinesMesh;
  43375. /**
  43376. * Creates a dashed line mesh
  43377. * * 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
  43378. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43379. * * The parameter `points` is an array successive Vector3
  43380. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43381. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43382. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43383. * * 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
  43384. * * When updating an instance, remember that only point positions can change, not the number of points
  43385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43386. * @param name defines the name of the mesh
  43387. * @param options defines the options used to create the mesh
  43388. * @param scene defines the hosting scene
  43389. * @returns the dashed line mesh
  43390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43391. */
  43392. static CreateDashedLines(name: string, options: {
  43393. points: Vector3[];
  43394. dashSize?: number;
  43395. gapSize?: number;
  43396. dashNb?: number;
  43397. updatable?: boolean;
  43398. instance?: LinesMesh;
  43399. }, scene?: Nullable<Scene>): LinesMesh;
  43400. }
  43401. }
  43402. declare module "babylonjs/Debug/rayHelper" {
  43403. import { Nullable } from "babylonjs/types";
  43404. import { Ray } from "babylonjs/Culling/ray";
  43405. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43406. import { Scene } from "babylonjs/scene";
  43407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43408. import "babylonjs/Meshes/Builders/linesBuilder";
  43409. /**
  43410. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43411. * in order to better appreciate the issue one might have.
  43412. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43413. */
  43414. export class RayHelper {
  43415. /**
  43416. * Defines the ray we are currently tryin to visualize.
  43417. */
  43418. ray: Nullable<Ray>;
  43419. private _renderPoints;
  43420. private _renderLine;
  43421. private _renderFunction;
  43422. private _scene;
  43423. private _updateToMeshFunction;
  43424. private _attachedToMesh;
  43425. private _meshSpaceDirection;
  43426. private _meshSpaceOrigin;
  43427. /**
  43428. * Helper function to create a colored helper in a scene in one line.
  43429. * @param ray Defines the ray we are currently tryin to visualize
  43430. * @param scene Defines the scene the ray is used in
  43431. * @param color Defines the color we want to see the ray in
  43432. * @returns The newly created ray helper.
  43433. */
  43434. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43435. /**
  43436. * Instantiate a new ray helper.
  43437. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43438. * in order to better appreciate the issue one might have.
  43439. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43440. * @param ray Defines the ray we are currently tryin to visualize
  43441. */
  43442. constructor(ray: Ray);
  43443. /**
  43444. * Shows the ray we are willing to debug.
  43445. * @param scene Defines the scene the ray needs to be rendered in
  43446. * @param color Defines the color the ray needs to be rendered in
  43447. */
  43448. show(scene: Scene, color?: Color3): void;
  43449. /**
  43450. * Hides the ray we are debugging.
  43451. */
  43452. hide(): void;
  43453. private _render;
  43454. /**
  43455. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43456. * @param mesh Defines the mesh we want the helper attached to
  43457. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43458. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43459. * @param length Defines the length of the ray
  43460. */
  43461. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43462. /**
  43463. * Detach the ray helper from the mesh it has previously been attached to.
  43464. */
  43465. detachFromMesh(): void;
  43466. private _updateToMesh;
  43467. /**
  43468. * Dispose the helper and release its associated resources.
  43469. */
  43470. dispose(): void;
  43471. }
  43472. }
  43473. declare module "babylonjs/Debug/skeletonViewer" {
  43474. import { Color3 } from "babylonjs/Maths/math";
  43475. import { Scene } from "babylonjs/scene";
  43476. import { Nullable } from "babylonjs/types";
  43477. import { Skeleton } from "babylonjs/Bones/skeleton";
  43478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43479. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43480. /**
  43481. * Class used to render a debug view of a given skeleton
  43482. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43483. */
  43484. export class SkeletonViewer {
  43485. /** defines the skeleton to render */
  43486. skeleton: Skeleton;
  43487. /** defines the mesh attached to the skeleton */
  43488. mesh: AbstractMesh;
  43489. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43490. autoUpdateBonesMatrices: boolean;
  43491. /** defines the rendering group id to use with the viewer */
  43492. renderingGroupId: number;
  43493. /** Gets or sets the color used to render the skeleton */
  43494. color: Color3;
  43495. private _scene;
  43496. private _debugLines;
  43497. private _debugMesh;
  43498. private _isEnabled;
  43499. private _renderFunction;
  43500. private _utilityLayer;
  43501. /**
  43502. * Returns the mesh used to render the bones
  43503. */
  43504. readonly debugMesh: Nullable<LinesMesh>;
  43505. /**
  43506. * Creates a new SkeletonViewer
  43507. * @param skeleton defines the skeleton to render
  43508. * @param mesh defines the mesh attached to the skeleton
  43509. * @param scene defines the hosting scene
  43510. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43511. * @param renderingGroupId defines the rendering group id to use with the viewer
  43512. */
  43513. constructor(
  43514. /** defines the skeleton to render */
  43515. skeleton: Skeleton,
  43516. /** defines the mesh attached to the skeleton */
  43517. mesh: AbstractMesh, scene: Scene,
  43518. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43519. autoUpdateBonesMatrices?: boolean,
  43520. /** defines the rendering group id to use with the viewer */
  43521. renderingGroupId?: number);
  43522. /** Gets or sets a boolean indicating if the viewer is enabled */
  43523. isEnabled: boolean;
  43524. private _getBonePosition;
  43525. private _getLinesForBonesWithLength;
  43526. private _getLinesForBonesNoLength;
  43527. /** Update the viewer to sync with current skeleton state */
  43528. update(): void;
  43529. /** Release associated resources */
  43530. dispose(): void;
  43531. }
  43532. }
  43533. declare module "babylonjs/Debug/index" {
  43534. export * from "babylonjs/Debug/axesViewer";
  43535. export * from "babylonjs/Debug/boneAxesViewer";
  43536. export * from "babylonjs/Debug/debugLayer";
  43537. export * from "babylonjs/Debug/physicsViewer";
  43538. export * from "babylonjs/Debug/rayHelper";
  43539. export * from "babylonjs/Debug/skeletonViewer";
  43540. }
  43541. declare module "babylonjs/Engines/nullEngine" {
  43542. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43543. import { Scene } from "babylonjs/scene";
  43544. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43545. import { Engine } from "babylonjs/Engines/engine";
  43546. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43547. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43549. import { Effect } from "babylonjs/Materials/effect";
  43550. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43551. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43552. /**
  43553. * Options to create the null engine
  43554. */
  43555. export class NullEngineOptions {
  43556. /**
  43557. * Render width (Default: 512)
  43558. */
  43559. renderWidth: number;
  43560. /**
  43561. * Render height (Default: 256)
  43562. */
  43563. renderHeight: number;
  43564. /**
  43565. * Texture size (Default: 512)
  43566. */
  43567. textureSize: number;
  43568. /**
  43569. * If delta time between frames should be constant
  43570. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43571. */
  43572. deterministicLockstep: boolean;
  43573. /**
  43574. * Maximum about of steps between frames (Default: 4)
  43575. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43576. */
  43577. lockstepMaxSteps: number;
  43578. }
  43579. /**
  43580. * The null engine class provides support for headless version of babylon.js.
  43581. * This can be used in server side scenario or for testing purposes
  43582. */
  43583. export class NullEngine extends Engine {
  43584. private _options;
  43585. /**
  43586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43587. */
  43588. isDeterministicLockStep(): boolean;
  43589. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43590. getLockstepMaxSteps(): number;
  43591. /**
  43592. * Sets hardware scaling, used to save performance if needed
  43593. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43594. */
  43595. getHardwareScalingLevel(): number;
  43596. constructor(options?: NullEngineOptions);
  43597. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43598. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43599. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43600. getRenderWidth(useScreen?: boolean): number;
  43601. getRenderHeight(useScreen?: boolean): number;
  43602. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43603. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43604. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43605. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43606. bindSamplers(effect: Effect): void;
  43607. enableEffect(effect: Effect): void;
  43608. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43609. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43610. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43611. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43612. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43613. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43614. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43615. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43616. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43617. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43618. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43619. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43620. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43621. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43622. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43623. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43624. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43625. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43626. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43627. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43628. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43629. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43630. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43631. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43632. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43633. bindBuffers(vertexBuffers: {
  43634. [key: string]: VertexBuffer;
  43635. }, indexBuffer: DataBuffer, effect: Effect): void;
  43636. wipeCaches(bruteForce?: boolean): void;
  43637. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43638. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43639. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43640. /** @hidden */
  43641. _createTexture(): WebGLTexture;
  43642. /** @hidden */
  43643. _releaseTexture(texture: InternalTexture): void;
  43644. 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;
  43645. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43646. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43647. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43648. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43649. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43651. areAllEffectsReady(): boolean;
  43652. /**
  43653. * @hidden
  43654. * Get the current error code of the webGL context
  43655. * @returns the error code
  43656. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43657. */
  43658. getError(): number;
  43659. /** @hidden */
  43660. _getUnpackAlignement(): number;
  43661. /** @hidden */
  43662. _unpackFlipY(value: boolean): void;
  43663. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43664. /**
  43665. * Updates a dynamic vertex buffer.
  43666. * @param vertexBuffer the vertex buffer to update
  43667. * @param data the data used to update the vertex buffer
  43668. * @param byteOffset the byte offset of the data (optional)
  43669. * @param byteLength the byte length of the data (optional)
  43670. */
  43671. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43672. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43673. /** @hidden */
  43674. _bindTexture(channel: number, texture: InternalTexture): void;
  43675. /** @hidden */
  43676. _releaseBuffer(buffer: DataBuffer): boolean;
  43677. releaseEffects(): void;
  43678. displayLoadingUI(): void;
  43679. hideLoadingUI(): void;
  43680. /** @hidden */
  43681. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43682. /** @hidden */
  43683. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43684. /** @hidden */
  43685. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43686. /** @hidden */
  43687. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43688. }
  43689. }
  43690. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43691. import { Nullable, int } from "babylonjs/types";
  43692. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43693. /** @hidden */
  43694. export class _OcclusionDataStorage {
  43695. /** @hidden */
  43696. occlusionInternalRetryCounter: number;
  43697. /** @hidden */
  43698. isOcclusionQueryInProgress: boolean;
  43699. /** @hidden */
  43700. isOccluded: boolean;
  43701. /** @hidden */
  43702. occlusionRetryCount: number;
  43703. /** @hidden */
  43704. occlusionType: number;
  43705. /** @hidden */
  43706. occlusionQueryAlgorithmType: number;
  43707. }
  43708. module "babylonjs/Engines/engine" {
  43709. interface Engine {
  43710. /**
  43711. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43712. * @return the new query
  43713. */
  43714. createQuery(): WebGLQuery;
  43715. /**
  43716. * Delete and release a webGL query
  43717. * @param query defines the query to delete
  43718. * @return the current engine
  43719. */
  43720. deleteQuery(query: WebGLQuery): Engine;
  43721. /**
  43722. * Check if a given query has resolved and got its value
  43723. * @param query defines the query to check
  43724. * @returns true if the query got its value
  43725. */
  43726. isQueryResultAvailable(query: WebGLQuery): boolean;
  43727. /**
  43728. * Gets the value of a given query
  43729. * @param query defines the query to check
  43730. * @returns the value of the query
  43731. */
  43732. getQueryResult(query: WebGLQuery): number;
  43733. /**
  43734. * Initiates an occlusion query
  43735. * @param algorithmType defines the algorithm to use
  43736. * @param query defines the query to use
  43737. * @returns the current engine
  43738. * @see http://doc.babylonjs.com/features/occlusionquery
  43739. */
  43740. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43741. /**
  43742. * Ends an occlusion query
  43743. * @see http://doc.babylonjs.com/features/occlusionquery
  43744. * @param algorithmType defines the algorithm to use
  43745. * @returns the current engine
  43746. */
  43747. endOcclusionQuery(algorithmType: number): Engine;
  43748. /**
  43749. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43750. * Please note that only one query can be issued at a time
  43751. * @returns a time token used to track the time span
  43752. */
  43753. startTimeQuery(): Nullable<_TimeToken>;
  43754. /**
  43755. * Ends a time query
  43756. * @param token defines the token used to measure the time span
  43757. * @returns the time spent (in ns)
  43758. */
  43759. endTimeQuery(token: _TimeToken): int;
  43760. /** @hidden */
  43761. _currentNonTimestampToken: Nullable<_TimeToken>;
  43762. /** @hidden */
  43763. _createTimeQuery(): WebGLQuery;
  43764. /** @hidden */
  43765. _deleteTimeQuery(query: WebGLQuery): void;
  43766. /** @hidden */
  43767. _getGlAlgorithmType(algorithmType: number): number;
  43768. /** @hidden */
  43769. _getTimeQueryResult(query: WebGLQuery): any;
  43770. /** @hidden */
  43771. _getTimeQueryAvailability(query: WebGLQuery): any;
  43772. }
  43773. }
  43774. module "babylonjs/Meshes/abstractMesh" {
  43775. interface AbstractMesh {
  43776. /**
  43777. * Backing filed
  43778. * @hidden
  43779. */
  43780. __occlusionDataStorage: _OcclusionDataStorage;
  43781. /**
  43782. * Access property
  43783. * @hidden
  43784. */
  43785. _occlusionDataStorage: _OcclusionDataStorage;
  43786. /**
  43787. * 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.
  43788. * The default value is -1 which means don't break the query and wait till the result
  43789. * @see http://doc.babylonjs.com/features/occlusionquery
  43790. */
  43791. occlusionRetryCount: number;
  43792. /**
  43793. * 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:
  43794. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43795. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43796. * * 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.
  43797. * @see http://doc.babylonjs.com/features/occlusionquery
  43798. */
  43799. occlusionType: number;
  43800. /**
  43801. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43802. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43803. * * 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.
  43804. * @see http://doc.babylonjs.com/features/occlusionquery
  43805. */
  43806. occlusionQueryAlgorithmType: number;
  43807. /**
  43808. * 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
  43809. * @see http://doc.babylonjs.com/features/occlusionquery
  43810. */
  43811. isOccluded: boolean;
  43812. /**
  43813. * Flag to check the progress status of the query
  43814. * @see http://doc.babylonjs.com/features/occlusionquery
  43815. */
  43816. isOcclusionQueryInProgress: boolean;
  43817. }
  43818. }
  43819. }
  43820. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43821. import { Nullable } from "babylonjs/types";
  43822. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43823. /** @hidden */
  43824. export var _forceTransformFeedbackToBundle: boolean;
  43825. module "babylonjs/Engines/engine" {
  43826. interface Engine {
  43827. /**
  43828. * Creates a webGL transform feedback object
  43829. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43830. * @returns the webGL transform feedback object
  43831. */
  43832. createTransformFeedback(): WebGLTransformFeedback;
  43833. /**
  43834. * Delete a webGL transform feedback object
  43835. * @param value defines the webGL transform feedback object to delete
  43836. */
  43837. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43838. /**
  43839. * Bind a webGL transform feedback object to the webgl context
  43840. * @param value defines the webGL transform feedback object to bind
  43841. */
  43842. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43843. /**
  43844. * Begins a transform feedback operation
  43845. * @param usePoints defines if points or triangles must be used
  43846. */
  43847. beginTransformFeedback(usePoints: boolean): void;
  43848. /**
  43849. * Ends a transform feedback operation
  43850. */
  43851. endTransformFeedback(): void;
  43852. /**
  43853. * Specify the varyings to use with transform feedback
  43854. * @param program defines the associated webGL program
  43855. * @param value defines the list of strings representing the varying names
  43856. */
  43857. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43858. /**
  43859. * Bind a webGL buffer for a transform feedback operation
  43860. * @param value defines the webGL buffer to bind
  43861. */
  43862. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43863. }
  43864. }
  43865. }
  43866. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43867. import { Scene } from "babylonjs/scene";
  43868. import { Engine } from "babylonjs/Engines/engine";
  43869. import { Texture } from "babylonjs/Materials/Textures/texture";
  43870. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43871. import "babylonjs/Engines/Extensions/engine.multiRender";
  43872. /**
  43873. * Creation options of the multi render target texture.
  43874. */
  43875. export interface IMultiRenderTargetOptions {
  43876. /**
  43877. * Define if the texture needs to create mip maps after render.
  43878. */
  43879. generateMipMaps?: boolean;
  43880. /**
  43881. * Define the types of all the draw buffers we want to create
  43882. */
  43883. types?: number[];
  43884. /**
  43885. * Define the sampling modes of all the draw buffers we want to create
  43886. */
  43887. samplingModes?: number[];
  43888. /**
  43889. * Define if a depth buffer is required
  43890. */
  43891. generateDepthBuffer?: boolean;
  43892. /**
  43893. * Define if a stencil buffer is required
  43894. */
  43895. generateStencilBuffer?: boolean;
  43896. /**
  43897. * Define if a depth texture is required instead of a depth buffer
  43898. */
  43899. generateDepthTexture?: boolean;
  43900. /**
  43901. * Define the number of desired draw buffers
  43902. */
  43903. textureCount?: number;
  43904. /**
  43905. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43906. */
  43907. doNotChangeAspectRatio?: boolean;
  43908. /**
  43909. * Define the default type of the buffers we are creating
  43910. */
  43911. defaultType?: number;
  43912. }
  43913. /**
  43914. * A multi render target, like a render target provides the ability to render to a texture.
  43915. * Unlike the render target, it can render to several draw buffers in one draw.
  43916. * This is specially interesting in deferred rendering or for any effects requiring more than
  43917. * just one color from a single pass.
  43918. */
  43919. export class MultiRenderTarget extends RenderTargetTexture {
  43920. private _internalTextures;
  43921. private _textures;
  43922. private _multiRenderTargetOptions;
  43923. /**
  43924. * Get if draw buffers are currently supported by the used hardware and browser.
  43925. */
  43926. readonly isSupported: boolean;
  43927. /**
  43928. * Get the list of textures generated by the multi render target.
  43929. */
  43930. readonly textures: Texture[];
  43931. /**
  43932. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43933. */
  43934. readonly depthTexture: Texture;
  43935. /**
  43936. * Set the wrapping mode on U of all the textures we are rendering to.
  43937. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43938. */
  43939. wrapU: number;
  43940. /**
  43941. * Set the wrapping mode on V of all the textures we are rendering to.
  43942. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43943. */
  43944. wrapV: number;
  43945. /**
  43946. * Instantiate a new multi render target texture.
  43947. * A multi render target, like a render target provides the ability to render to a texture.
  43948. * Unlike the render target, it can render to several draw buffers in one draw.
  43949. * This is specially interesting in deferred rendering or for any effects requiring more than
  43950. * just one color from a single pass.
  43951. * @param name Define the name of the texture
  43952. * @param size Define the size of the buffers to render to
  43953. * @param count Define the number of target we are rendering into
  43954. * @param scene Define the scene the texture belongs to
  43955. * @param options Define the options used to create the multi render target
  43956. */
  43957. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43958. /** @hidden */
  43959. _rebuild(): void;
  43960. private _createInternalTextures;
  43961. private _createTextures;
  43962. /**
  43963. * Define the number of samples used if MSAA is enabled.
  43964. */
  43965. samples: number;
  43966. /**
  43967. * Resize all the textures in the multi render target.
  43968. * Be carrefull as it will recreate all the data in the new texture.
  43969. * @param size Define the new size
  43970. */
  43971. resize(size: any): void;
  43972. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43973. /**
  43974. * Dispose the render targets and their associated resources
  43975. */
  43976. dispose(): void;
  43977. /**
  43978. * Release all the underlying texture used as draw buffers.
  43979. */
  43980. releaseInternalTextures(): void;
  43981. }
  43982. }
  43983. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43984. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43985. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43986. import { Nullable } from "babylonjs/types";
  43987. module "babylonjs/Engines/engine" {
  43988. interface Engine {
  43989. /**
  43990. * Unbind a list of render target textures from the webGL context
  43991. * This is used only when drawBuffer extension or webGL2 are active
  43992. * @param textures defines the render target textures to unbind
  43993. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43994. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43995. */
  43996. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43997. /**
  43998. * Create a multi render target texture
  43999. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44000. * @param size defines the size of the texture
  44001. * @param options defines the creation options
  44002. * @returns the cube texture as an InternalTexture
  44003. */
  44004. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44005. /**
  44006. * Update the sample count for a given multiple render target texture
  44007. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44008. * @param textures defines the textures to update
  44009. * @param samples defines the sample count to set
  44010. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44011. */
  44012. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44013. }
  44014. }
  44015. }
  44016. declare module "babylonjs/Engines/Extensions/index" {
  44017. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  44018. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  44019. export * from "babylonjs/Engines/Extensions/engine.multiview";
  44020. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  44021. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  44022. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  44023. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  44024. export * from "babylonjs/Engines/Extensions/engine.webVR";
  44025. }
  44026. declare module "babylonjs/Engines/index" {
  44027. export * from "babylonjs/Engines/constants";
  44028. export * from "babylonjs/Engines/engine";
  44029. export * from "babylonjs/Engines/engineStore";
  44030. export * from "babylonjs/Engines/nullEngine";
  44031. export * from "babylonjs/Engines/Extensions/index";
  44032. export * from "babylonjs/Engines/IPipelineContext";
  44033. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  44034. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  44035. }
  44036. declare module "babylonjs/Events/clipboardEvents" {
  44037. /**
  44038. * Gather the list of clipboard event types as constants.
  44039. */
  44040. export class ClipboardEventTypes {
  44041. /**
  44042. * The clipboard event is fired when a copy command is active (pressed).
  44043. */
  44044. static readonly COPY: number;
  44045. /**
  44046. * The clipboard event is fired when a cut command is active (pressed).
  44047. */
  44048. static readonly CUT: number;
  44049. /**
  44050. * The clipboard event is fired when a paste command is active (pressed).
  44051. */
  44052. static readonly PASTE: number;
  44053. }
  44054. /**
  44055. * This class is used to store clipboard related info for the onClipboardObservable event.
  44056. */
  44057. export class ClipboardInfo {
  44058. /**
  44059. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44060. */
  44061. type: number;
  44062. /**
  44063. * Defines the related dom event
  44064. */
  44065. event: ClipboardEvent;
  44066. /**
  44067. *Creates an instance of ClipboardInfo.
  44068. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44069. * @param event Defines the related dom event
  44070. */
  44071. constructor(
  44072. /**
  44073. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44074. */
  44075. type: number,
  44076. /**
  44077. * Defines the related dom event
  44078. */
  44079. event: ClipboardEvent);
  44080. /**
  44081. * Get the clipboard event's type from the keycode.
  44082. * @param keyCode Defines the keyCode for the current keyboard event.
  44083. * @return {number}
  44084. */
  44085. static GetTypeFromCharacter(keyCode: number): number;
  44086. }
  44087. }
  44088. declare module "babylonjs/Events/index" {
  44089. export * from "babylonjs/Events/keyboardEvents";
  44090. export * from "babylonjs/Events/pointerEvents";
  44091. export * from "babylonjs/Events/clipboardEvents";
  44092. }
  44093. declare module "babylonjs/Loading/sceneLoader" {
  44094. import { Observable } from "babylonjs/Misc/observable";
  44095. import { Nullable } from "babylonjs/types";
  44096. import { Scene } from "babylonjs/scene";
  44097. import { Engine } from "babylonjs/Engines/engine";
  44098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44099. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44100. import { AssetContainer } from "babylonjs/assetContainer";
  44101. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44102. import { Skeleton } from "babylonjs/Bones/skeleton";
  44103. /**
  44104. * Class used to represent data loading progression
  44105. */
  44106. export class SceneLoaderProgressEvent {
  44107. /** defines if data length to load can be evaluated */
  44108. readonly lengthComputable: boolean;
  44109. /** defines the loaded data length */
  44110. readonly loaded: number;
  44111. /** defines the data length to load */
  44112. readonly total: number;
  44113. /**
  44114. * Create a new progress event
  44115. * @param lengthComputable defines if data length to load can be evaluated
  44116. * @param loaded defines the loaded data length
  44117. * @param total defines the data length to load
  44118. */
  44119. constructor(
  44120. /** defines if data length to load can be evaluated */
  44121. lengthComputable: boolean,
  44122. /** defines the loaded data length */
  44123. loaded: number,
  44124. /** defines the data length to load */
  44125. total: number);
  44126. /**
  44127. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44128. * @param event defines the source event
  44129. * @returns a new SceneLoaderProgressEvent
  44130. */
  44131. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44132. }
  44133. /**
  44134. * Interface used by SceneLoader plugins to define supported file extensions
  44135. */
  44136. export interface ISceneLoaderPluginExtensions {
  44137. /**
  44138. * Defines the list of supported extensions
  44139. */
  44140. [extension: string]: {
  44141. isBinary: boolean;
  44142. };
  44143. }
  44144. /**
  44145. * Interface used by SceneLoader plugin factory
  44146. */
  44147. export interface ISceneLoaderPluginFactory {
  44148. /**
  44149. * Defines the name of the factory
  44150. */
  44151. name: string;
  44152. /**
  44153. * Function called to create a new plugin
  44154. * @return the new plugin
  44155. */
  44156. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44157. /**
  44158. * Boolean indicating if the plugin can direct load specific data
  44159. */
  44160. canDirectLoad?: (data: string) => boolean;
  44161. }
  44162. /**
  44163. * Interface used to define a SceneLoader plugin
  44164. */
  44165. export interface ISceneLoaderPlugin {
  44166. /**
  44167. * The friendly name of this plugin.
  44168. */
  44169. name: string;
  44170. /**
  44171. * The file extensions supported by this plugin.
  44172. */
  44173. extensions: string | ISceneLoaderPluginExtensions;
  44174. /**
  44175. * Import meshes into a scene.
  44176. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44177. * @param scene The scene to import into
  44178. * @param data The data to import
  44179. * @param rootUrl The root url for scene and resources
  44180. * @param meshes The meshes array to import into
  44181. * @param particleSystems The particle systems array to import into
  44182. * @param skeletons The skeletons array to import into
  44183. * @param onError The callback when import fails
  44184. * @returns True if successful or false otherwise
  44185. */
  44186. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44187. /**
  44188. * Load into a scene.
  44189. * @param scene The scene to load into
  44190. * @param data The data to import
  44191. * @param rootUrl The root url for scene and resources
  44192. * @param onError The callback when import fails
  44193. * @returns true if successful or false otherwise
  44194. */
  44195. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44196. /**
  44197. * The callback that returns true if the data can be directly loaded.
  44198. */
  44199. canDirectLoad?: (data: string) => boolean;
  44200. /**
  44201. * The callback that allows custom handling of the root url based on the response url.
  44202. */
  44203. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44204. /**
  44205. * Load into an asset container.
  44206. * @param scene The scene to load into
  44207. * @param data The data to import
  44208. * @param rootUrl The root url for scene and resources
  44209. * @param onError The callback when import fails
  44210. * @returns The loaded asset container
  44211. */
  44212. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44213. }
  44214. /**
  44215. * Interface used to define an async SceneLoader plugin
  44216. */
  44217. export interface ISceneLoaderPluginAsync {
  44218. /**
  44219. * The friendly name of this plugin.
  44220. */
  44221. name: string;
  44222. /**
  44223. * The file extensions supported by this plugin.
  44224. */
  44225. extensions: string | ISceneLoaderPluginExtensions;
  44226. /**
  44227. * Import meshes into a scene.
  44228. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44229. * @param scene The scene to import into
  44230. * @param data The data to import
  44231. * @param rootUrl The root url for scene and resources
  44232. * @param onProgress The callback when the load progresses
  44233. * @param fileName Defines the name of the file to load
  44234. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44235. */
  44236. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44237. meshes: AbstractMesh[];
  44238. particleSystems: IParticleSystem[];
  44239. skeletons: Skeleton[];
  44240. animationGroups: AnimationGroup[];
  44241. }>;
  44242. /**
  44243. * Load into a scene.
  44244. * @param scene The scene to load into
  44245. * @param data The data to import
  44246. * @param rootUrl The root url for scene and resources
  44247. * @param onProgress The callback when the load progresses
  44248. * @param fileName Defines the name of the file to load
  44249. * @returns Nothing
  44250. */
  44251. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44252. /**
  44253. * The callback that returns true if the data can be directly loaded.
  44254. */
  44255. canDirectLoad?: (data: string) => boolean;
  44256. /**
  44257. * The callback that allows custom handling of the root url based on the response url.
  44258. */
  44259. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44260. /**
  44261. * Load into an asset container.
  44262. * @param scene The scene to load into
  44263. * @param data The data to import
  44264. * @param rootUrl The root url for scene and resources
  44265. * @param onProgress The callback when the load progresses
  44266. * @param fileName Defines the name of the file to load
  44267. * @returns The loaded asset container
  44268. */
  44269. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44270. }
  44271. /**
  44272. * Class used to load scene from various file formats using registered plugins
  44273. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44274. */
  44275. export class SceneLoader {
  44276. /**
  44277. * No logging while loading
  44278. */
  44279. static readonly NO_LOGGING: number;
  44280. /**
  44281. * Minimal logging while loading
  44282. */
  44283. static readonly MINIMAL_LOGGING: number;
  44284. /**
  44285. * Summary logging while loading
  44286. */
  44287. static readonly SUMMARY_LOGGING: number;
  44288. /**
  44289. * Detailled logging while loading
  44290. */
  44291. static readonly DETAILED_LOGGING: number;
  44292. /**
  44293. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44294. */
  44295. static ForceFullSceneLoadingForIncremental: boolean;
  44296. /**
  44297. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44298. */
  44299. static ShowLoadingScreen: boolean;
  44300. /**
  44301. * Defines the current logging level (while loading the scene)
  44302. * @ignorenaming
  44303. */
  44304. static loggingLevel: number;
  44305. /**
  44306. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44307. */
  44308. static CleanBoneMatrixWeights: boolean;
  44309. /**
  44310. * Event raised when a plugin is used to load a scene
  44311. */
  44312. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44313. private static _registeredPlugins;
  44314. private static _getDefaultPlugin;
  44315. private static _getPluginForExtension;
  44316. private static _getPluginForDirectLoad;
  44317. private static _getPluginForFilename;
  44318. private static _getDirectLoad;
  44319. private static _loadData;
  44320. private static _getFileInfo;
  44321. /**
  44322. * Gets a plugin that can load the given extension
  44323. * @param extension defines the extension to load
  44324. * @returns a plugin or null if none works
  44325. */
  44326. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44327. /**
  44328. * Gets a boolean indicating that the given extension can be loaded
  44329. * @param extension defines the extension to load
  44330. * @returns true if the extension is supported
  44331. */
  44332. static IsPluginForExtensionAvailable(extension: string): boolean;
  44333. /**
  44334. * Adds a new plugin to the list of registered plugins
  44335. * @param plugin defines the plugin to add
  44336. */
  44337. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44338. /**
  44339. * Import meshes into a scene
  44340. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44341. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44342. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44343. * @param scene the instance of BABYLON.Scene to append to
  44344. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44345. * @param onProgress a callback with a progress event for each file being loaded
  44346. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44347. * @param pluginExtension the extension used to determine the plugin
  44348. * @returns The loaded plugin
  44349. */
  44350. static 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>;
  44351. /**
  44352. * Import meshes into a scene
  44353. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44354. * @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)
  44355. * @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)
  44356. * @param scene the instance of BABYLON.Scene to append to
  44357. * @param onProgress a callback with a progress event for each file being loaded
  44358. * @param pluginExtension the extension used to determine the plugin
  44359. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44360. */
  44361. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44362. meshes: AbstractMesh[];
  44363. particleSystems: IParticleSystem[];
  44364. skeletons: Skeleton[];
  44365. animationGroups: AnimationGroup[];
  44366. }>;
  44367. /**
  44368. * Load a scene
  44369. * @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)
  44370. * @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)
  44371. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44372. * @param onSuccess a callback with the scene when import succeeds
  44373. * @param onProgress a callback with a progress event for each file being loaded
  44374. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44375. * @param pluginExtension the extension used to determine the plugin
  44376. * @returns The loaded plugin
  44377. */
  44378. 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>;
  44379. /**
  44380. * Load a scene
  44381. * @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)
  44382. * @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)
  44383. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44384. * @param onProgress a callback with a progress event for each file being loaded
  44385. * @param pluginExtension the extension used to determine the plugin
  44386. * @returns The loaded scene
  44387. */
  44388. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44389. /**
  44390. * Append a scene
  44391. * @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)
  44392. * @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)
  44393. * @param scene is the instance of BABYLON.Scene to append to
  44394. * @param onSuccess a callback with the scene when import succeeds
  44395. * @param onProgress a callback with a progress event for each file being loaded
  44396. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44397. * @param pluginExtension the extension used to determine the plugin
  44398. * @returns The loaded plugin
  44399. */
  44400. 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>;
  44401. /**
  44402. * Append a scene
  44403. * @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)
  44404. * @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)
  44405. * @param scene is the instance of BABYLON.Scene to append to
  44406. * @param onProgress a callback with a progress event for each file being loaded
  44407. * @param pluginExtension the extension used to determine the plugin
  44408. * @returns The given scene
  44409. */
  44410. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44411. /**
  44412. * Load a scene into an asset container
  44413. * @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)
  44414. * @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)
  44415. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44416. * @param onSuccess a callback with the scene when import succeeds
  44417. * @param onProgress a callback with a progress event for each file being loaded
  44418. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44419. * @param pluginExtension the extension used to determine the plugin
  44420. * @returns The loaded plugin
  44421. */
  44422. 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>;
  44423. /**
  44424. * Load a scene into an asset container
  44425. * @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)
  44426. * @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)
  44427. * @param scene is the instance of Scene to append to
  44428. * @param onProgress a callback with a progress event for each file being loaded
  44429. * @param pluginExtension the extension used to determine the plugin
  44430. * @returns The loaded asset container
  44431. */
  44432. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44433. }
  44434. }
  44435. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44436. import { Scene } from "babylonjs/scene";
  44437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44438. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44439. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44440. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44441. /**
  44442. * Google Daydream controller
  44443. */
  44444. export class DaydreamController extends WebVRController {
  44445. /**
  44446. * Base Url for the controller model.
  44447. */
  44448. static MODEL_BASE_URL: string;
  44449. /**
  44450. * File name for the controller model.
  44451. */
  44452. static MODEL_FILENAME: string;
  44453. /**
  44454. * Gamepad Id prefix used to identify Daydream Controller.
  44455. */
  44456. static readonly GAMEPAD_ID_PREFIX: string;
  44457. /**
  44458. * Creates a new DaydreamController from a gamepad
  44459. * @param vrGamepad the gamepad that the controller should be created from
  44460. */
  44461. constructor(vrGamepad: any);
  44462. /**
  44463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44464. * @param scene scene in which to add meshes
  44465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44466. */
  44467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44468. /**
  44469. * Called once for each button that changed state since the last frame
  44470. * @param buttonIdx Which button index changed
  44471. * @param state New state of the button
  44472. * @param changes Which properties on the state changed since last frame
  44473. */
  44474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44475. }
  44476. }
  44477. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44478. import { Scene } from "babylonjs/scene";
  44479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44480. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44481. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44482. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44483. /**
  44484. * Gear VR Controller
  44485. */
  44486. export class GearVRController extends WebVRController {
  44487. /**
  44488. * Base Url for the controller model.
  44489. */
  44490. static MODEL_BASE_URL: string;
  44491. /**
  44492. * File name for the controller model.
  44493. */
  44494. static MODEL_FILENAME: string;
  44495. /**
  44496. * Gamepad Id prefix used to identify this controller.
  44497. */
  44498. static readonly GAMEPAD_ID_PREFIX: string;
  44499. private readonly _buttonIndexToObservableNameMap;
  44500. /**
  44501. * Creates a new GearVRController from a gamepad
  44502. * @param vrGamepad the gamepad that the controller should be created from
  44503. */
  44504. constructor(vrGamepad: any);
  44505. /**
  44506. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44507. * @param scene scene in which to add meshes
  44508. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44509. */
  44510. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44511. /**
  44512. * Called once for each button that changed state since the last frame
  44513. * @param buttonIdx Which button index changed
  44514. * @param state New state of the button
  44515. * @param changes Which properties on the state changed since last frame
  44516. */
  44517. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44518. }
  44519. }
  44520. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44521. import { Scene } from "babylonjs/scene";
  44522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44523. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44524. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44525. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44526. /**
  44527. * Generic Controller
  44528. */
  44529. export class GenericController extends WebVRController {
  44530. /**
  44531. * Base Url for the controller model.
  44532. */
  44533. static readonly MODEL_BASE_URL: string;
  44534. /**
  44535. * File name for the controller model.
  44536. */
  44537. static readonly MODEL_FILENAME: string;
  44538. /**
  44539. * Creates a new GenericController from a gamepad
  44540. * @param vrGamepad the gamepad that the controller should be created from
  44541. */
  44542. constructor(vrGamepad: any);
  44543. /**
  44544. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44545. * @param scene scene in which to add meshes
  44546. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44547. */
  44548. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44549. /**
  44550. * Called once for each button that changed state since the last frame
  44551. * @param buttonIdx Which button index changed
  44552. * @param state New state of the button
  44553. * @param changes Which properties on the state changed since last frame
  44554. */
  44555. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44556. }
  44557. }
  44558. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44559. import { Observable } from "babylonjs/Misc/observable";
  44560. import { Scene } from "babylonjs/scene";
  44561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44562. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44563. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44564. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44565. /**
  44566. * Oculus Touch Controller
  44567. */
  44568. export class OculusTouchController extends WebVRController {
  44569. /**
  44570. * Base Url for the controller model.
  44571. */
  44572. static MODEL_BASE_URL: string;
  44573. /**
  44574. * File name for the left controller model.
  44575. */
  44576. static MODEL_LEFT_FILENAME: string;
  44577. /**
  44578. * File name for the right controller model.
  44579. */
  44580. static MODEL_RIGHT_FILENAME: string;
  44581. /**
  44582. * Base Url for the Quest controller model.
  44583. */
  44584. static QUEST_MODEL_BASE_URL: string;
  44585. /**
  44586. * @hidden
  44587. * If the controllers are running on a device that needs the updated Quest controller models
  44588. */
  44589. static _IsQuest: boolean;
  44590. /**
  44591. * Fired when the secondary trigger on this controller is modified
  44592. */
  44593. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44594. /**
  44595. * Fired when the thumb rest on this controller is modified
  44596. */
  44597. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44598. /**
  44599. * Creates a new OculusTouchController from a gamepad
  44600. * @param vrGamepad the gamepad that the controller should be created from
  44601. */
  44602. constructor(vrGamepad: any);
  44603. /**
  44604. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44605. * @param scene scene in which to add meshes
  44606. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44607. */
  44608. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44609. /**
  44610. * Fired when the A button on this controller is modified
  44611. */
  44612. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44613. /**
  44614. * Fired when the B button on this controller is modified
  44615. */
  44616. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44617. /**
  44618. * Fired when the X button on this controller is modified
  44619. */
  44620. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44621. /**
  44622. * Fired when the Y button on this controller is modified
  44623. */
  44624. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44625. /**
  44626. * Called once for each button that changed state since the last frame
  44627. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44628. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44629. * 2) secondary trigger (same)
  44630. * 3) A (right) X (left), touch, pressed = value
  44631. * 4) B / Y
  44632. * 5) thumb rest
  44633. * @param buttonIdx Which button index changed
  44634. * @param state New state of the button
  44635. * @param changes Which properties on the state changed since last frame
  44636. */
  44637. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44638. }
  44639. }
  44640. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44641. import { Scene } from "babylonjs/scene";
  44642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44643. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44644. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44645. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44646. import { Observable } from "babylonjs/Misc/observable";
  44647. /**
  44648. * Vive Controller
  44649. */
  44650. export class ViveController extends WebVRController {
  44651. /**
  44652. * Base Url for the controller model.
  44653. */
  44654. static MODEL_BASE_URL: string;
  44655. /**
  44656. * File name for the controller model.
  44657. */
  44658. static MODEL_FILENAME: string;
  44659. /**
  44660. * Creates a new ViveController from a gamepad
  44661. * @param vrGamepad the gamepad that the controller should be created from
  44662. */
  44663. constructor(vrGamepad: any);
  44664. /**
  44665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44666. * @param scene scene in which to add meshes
  44667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44668. */
  44669. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44670. /**
  44671. * Fired when the left button on this controller is modified
  44672. */
  44673. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44674. /**
  44675. * Fired when the right button on this controller is modified
  44676. */
  44677. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44678. /**
  44679. * Fired when the menu button on this controller is modified
  44680. */
  44681. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44682. /**
  44683. * Called once for each button that changed state since the last frame
  44684. * Vive mapping:
  44685. * 0: touchpad
  44686. * 1: trigger
  44687. * 2: left AND right buttons
  44688. * 3: menu button
  44689. * @param buttonIdx Which button index changed
  44690. * @param state New state of the button
  44691. * @param changes Which properties on the state changed since last frame
  44692. */
  44693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44694. }
  44695. }
  44696. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44697. import { Observable } from "babylonjs/Misc/observable";
  44698. import { Scene } from "babylonjs/scene";
  44699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44700. import { Ray } from "babylonjs/Culling/ray";
  44701. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44702. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44703. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44704. /**
  44705. * Defines the WindowsMotionController object that the state of the windows motion controller
  44706. */
  44707. export class WindowsMotionController extends WebVRController {
  44708. /**
  44709. * The base url used to load the left and right controller models
  44710. */
  44711. static MODEL_BASE_URL: string;
  44712. /**
  44713. * The name of the left controller model file
  44714. */
  44715. static MODEL_LEFT_FILENAME: string;
  44716. /**
  44717. * The name of the right controller model file
  44718. */
  44719. static MODEL_RIGHT_FILENAME: string;
  44720. /**
  44721. * The controller name prefix for this controller type
  44722. */
  44723. static readonly GAMEPAD_ID_PREFIX: string;
  44724. /**
  44725. * The controller id pattern for this controller type
  44726. */
  44727. private static readonly GAMEPAD_ID_PATTERN;
  44728. private _loadedMeshInfo;
  44729. private readonly _mapping;
  44730. /**
  44731. * Fired when the trackpad on this controller is clicked
  44732. */
  44733. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44734. /**
  44735. * Fired when the trackpad on this controller is modified
  44736. */
  44737. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44738. /**
  44739. * The current x and y values of this controller's trackpad
  44740. */
  44741. trackpad: StickValues;
  44742. /**
  44743. * Creates a new WindowsMotionController from a gamepad
  44744. * @param vrGamepad the gamepad that the controller should be created from
  44745. */
  44746. constructor(vrGamepad: any);
  44747. /**
  44748. * Fired when the trigger on this controller is modified
  44749. */
  44750. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44751. /**
  44752. * Fired when the menu button on this controller is modified
  44753. */
  44754. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44755. /**
  44756. * Fired when the grip button on this controller is modified
  44757. */
  44758. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44759. /**
  44760. * Fired when the thumbstick button on this controller is modified
  44761. */
  44762. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44763. /**
  44764. * Fired when the touchpad button on this controller is modified
  44765. */
  44766. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44767. /**
  44768. * Fired when the touchpad values on this controller are modified
  44769. */
  44770. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44771. private _updateTrackpad;
  44772. /**
  44773. * Called once per frame by the engine.
  44774. */
  44775. update(): void;
  44776. /**
  44777. * Called once for each button that changed state since the last frame
  44778. * @param buttonIdx Which button index changed
  44779. * @param state New state of the button
  44780. * @param changes Which properties on the state changed since last frame
  44781. */
  44782. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44783. /**
  44784. * Moves the buttons on the controller mesh based on their current state
  44785. * @param buttonName the name of the button to move
  44786. * @param buttonValue the value of the button which determines the buttons new position
  44787. */
  44788. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44789. /**
  44790. * Moves the axis on the controller mesh based on its current state
  44791. * @param axis the index of the axis
  44792. * @param axisValue the value of the axis which determines the meshes new position
  44793. * @hidden
  44794. */
  44795. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44796. /**
  44797. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44798. * @param scene scene in which to add meshes
  44799. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44800. */
  44801. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44802. /**
  44803. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44804. * can be transformed by button presses and axes values, based on this._mapping.
  44805. *
  44806. * @param scene scene in which the meshes exist
  44807. * @param meshes list of meshes that make up the controller model to process
  44808. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44809. */
  44810. private processModel;
  44811. private createMeshInfo;
  44812. /**
  44813. * Gets the ray of the controller in the direction the controller is pointing
  44814. * @param length the length the resulting ray should be
  44815. * @returns a ray in the direction the controller is pointing
  44816. */
  44817. getForwardRay(length?: number): Ray;
  44818. /**
  44819. * Disposes of the controller
  44820. */
  44821. dispose(): void;
  44822. }
  44823. }
  44824. declare module "babylonjs/Gamepads/Controllers/index" {
  44825. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44826. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44827. export * from "babylonjs/Gamepads/Controllers/genericController";
  44828. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44829. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44830. export * from "babylonjs/Gamepads/Controllers/viveController";
  44831. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44832. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44833. }
  44834. declare module "babylonjs/Gamepads/index" {
  44835. export * from "babylonjs/Gamepads/Controllers/index";
  44836. export * from "babylonjs/Gamepads/gamepad";
  44837. export * from "babylonjs/Gamepads/gamepadManager";
  44838. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44839. export * from "babylonjs/Gamepads/xboxGamepad";
  44840. }
  44841. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44842. import { Scene } from "babylonjs/scene";
  44843. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44844. import { Mesh } from "babylonjs/Meshes/mesh";
  44845. import { Nullable } from "babylonjs/types";
  44846. /**
  44847. * Class containing static functions to help procedurally build meshes
  44848. */
  44849. export class PolyhedronBuilder {
  44850. /**
  44851. * Creates a polyhedron mesh
  44852. * * 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
  44853. * * The parameter `size` (positive float, default 1) sets the polygon size
  44854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44855. * * 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`
  44856. * * 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
  44857. * * 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)`)
  44858. * * 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
  44859. * * 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
  44860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44863. * @param name defines the name of the mesh
  44864. * @param options defines the options used to create the mesh
  44865. * @param scene defines the hosting scene
  44866. * @returns the polyhedron mesh
  44867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44868. */
  44869. static CreatePolyhedron(name: string, options: {
  44870. type?: number;
  44871. size?: number;
  44872. sizeX?: number;
  44873. sizeY?: number;
  44874. sizeZ?: number;
  44875. custom?: any;
  44876. faceUV?: Vector4[];
  44877. faceColors?: Color4[];
  44878. flat?: boolean;
  44879. updatable?: boolean;
  44880. sideOrientation?: number;
  44881. frontUVs?: Vector4;
  44882. backUVs?: Vector4;
  44883. }, scene?: Nullable<Scene>): Mesh;
  44884. }
  44885. }
  44886. declare module "babylonjs/Gizmos/scaleGizmo" {
  44887. import { Observable } from "babylonjs/Misc/observable";
  44888. import { Nullable } from "babylonjs/types";
  44889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44890. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44891. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44892. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44893. /**
  44894. * Gizmo that enables scaling a mesh along 3 axis
  44895. */
  44896. export class ScaleGizmo extends Gizmo {
  44897. /**
  44898. * Internal gizmo used for interactions on the x axis
  44899. */
  44900. xGizmo: AxisScaleGizmo;
  44901. /**
  44902. * Internal gizmo used for interactions on the y axis
  44903. */
  44904. yGizmo: AxisScaleGizmo;
  44905. /**
  44906. * Internal gizmo used for interactions on the z axis
  44907. */
  44908. zGizmo: AxisScaleGizmo;
  44909. /**
  44910. * Internal gizmo used to scale all axis equally
  44911. */
  44912. uniformScaleGizmo: AxisScaleGizmo;
  44913. private _meshAttached;
  44914. private _updateGizmoRotationToMatchAttachedMesh;
  44915. private _snapDistance;
  44916. private _scaleRatio;
  44917. private _uniformScalingMesh;
  44918. private _octahedron;
  44919. /** Fires an event when any of it's sub gizmos are dragged */
  44920. onDragStartObservable: Observable<unknown>;
  44921. /** Fires an event when any of it's sub gizmos are released from dragging */
  44922. onDragEndObservable: Observable<unknown>;
  44923. attachedMesh: Nullable<AbstractMesh>;
  44924. /**
  44925. * Creates a ScaleGizmo
  44926. * @param gizmoLayer The utility layer the gizmo will be added to
  44927. */
  44928. constructor(gizmoLayer?: UtilityLayerRenderer);
  44929. updateGizmoRotationToMatchAttachedMesh: boolean;
  44930. /**
  44931. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44932. */
  44933. snapDistance: number;
  44934. /**
  44935. * Ratio for the scale of the gizmo (Default: 1)
  44936. */
  44937. scaleRatio: number;
  44938. /**
  44939. * Disposes of the gizmo
  44940. */
  44941. dispose(): void;
  44942. }
  44943. }
  44944. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44945. import { Observable } from "babylonjs/Misc/observable";
  44946. import { Nullable } from "babylonjs/types";
  44947. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44949. import { Mesh } from "babylonjs/Meshes/mesh";
  44950. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44951. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44952. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44953. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44954. /**
  44955. * Single axis scale gizmo
  44956. */
  44957. export class AxisScaleGizmo extends Gizmo {
  44958. /**
  44959. * Drag behavior responsible for the gizmos dragging interactions
  44960. */
  44961. dragBehavior: PointerDragBehavior;
  44962. private _pointerObserver;
  44963. /**
  44964. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44965. */
  44966. snapDistance: number;
  44967. /**
  44968. * Event that fires each time the gizmo snaps to a new location.
  44969. * * snapDistance is the the change in distance
  44970. */
  44971. onSnapObservable: Observable<{
  44972. snapDistance: number;
  44973. }>;
  44974. /**
  44975. * If the scaling operation should be done on all axis (default: false)
  44976. */
  44977. uniformScaling: boolean;
  44978. private _isEnabled;
  44979. private _parent;
  44980. private _arrow;
  44981. private _coloredMaterial;
  44982. private _hoverMaterial;
  44983. /**
  44984. * Creates an AxisScaleGizmo
  44985. * @param gizmoLayer The utility layer the gizmo will be added to
  44986. * @param dragAxis The axis which the gizmo will be able to scale on
  44987. * @param color The color of the gizmo
  44988. */
  44989. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44990. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44991. /**
  44992. * If the gizmo is enabled
  44993. */
  44994. isEnabled: boolean;
  44995. /**
  44996. * Disposes of the gizmo
  44997. */
  44998. dispose(): void;
  44999. /**
  45000. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45001. * @param mesh The mesh to replace the default mesh of the gizmo
  45002. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45003. */
  45004. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45005. }
  45006. }
  45007. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45008. import { Observable } from "babylonjs/Misc/observable";
  45009. import { Nullable } from "babylonjs/types";
  45010. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45012. import { Mesh } from "babylonjs/Meshes/mesh";
  45013. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45014. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45015. import "babylonjs/Meshes/Builders/boxBuilder";
  45016. /**
  45017. * Bounding box gizmo
  45018. */
  45019. export class BoundingBoxGizmo extends Gizmo {
  45020. private _lineBoundingBox;
  45021. private _rotateSpheresParent;
  45022. private _scaleBoxesParent;
  45023. private _boundingDimensions;
  45024. private _renderObserver;
  45025. private _pointerObserver;
  45026. private _scaleDragSpeed;
  45027. private _tmpQuaternion;
  45028. private _tmpVector;
  45029. private _tmpRotationMatrix;
  45030. /**
  45031. * 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)
  45032. */
  45033. ignoreChildren: boolean;
  45034. /**
  45035. * 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)
  45036. */
  45037. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45038. /**
  45039. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45040. */
  45041. rotationSphereSize: number;
  45042. /**
  45043. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45044. */
  45045. scaleBoxSize: number;
  45046. /**
  45047. * 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)
  45048. */
  45049. fixedDragMeshScreenSize: boolean;
  45050. /**
  45051. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45052. */
  45053. fixedDragMeshScreenSizeDistanceFactor: number;
  45054. /**
  45055. * Fired when a rotation sphere or scale box is dragged
  45056. */
  45057. onDragStartObservable: Observable<{}>;
  45058. /**
  45059. * Fired when a scale box is dragged
  45060. */
  45061. onScaleBoxDragObservable: Observable<{}>;
  45062. /**
  45063. * Fired when a scale box drag is ended
  45064. */
  45065. onScaleBoxDragEndObservable: Observable<{}>;
  45066. /**
  45067. * Fired when a rotation sphere is dragged
  45068. */
  45069. onRotationSphereDragObservable: Observable<{}>;
  45070. /**
  45071. * Fired when a rotation sphere drag is ended
  45072. */
  45073. onRotationSphereDragEndObservable: Observable<{}>;
  45074. /**
  45075. * 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)
  45076. */
  45077. scalePivot: Nullable<Vector3>;
  45078. /**
  45079. * Mesh used as a pivot to rotate the attached mesh
  45080. */
  45081. private _anchorMesh;
  45082. private _existingMeshScale;
  45083. private _dragMesh;
  45084. private pointerDragBehavior;
  45085. private coloredMaterial;
  45086. private hoverColoredMaterial;
  45087. /**
  45088. * Sets the color of the bounding box gizmo
  45089. * @param color the color to set
  45090. */
  45091. setColor(color: Color3): void;
  45092. /**
  45093. * Creates an BoundingBoxGizmo
  45094. * @param gizmoLayer The utility layer the gizmo will be added to
  45095. * @param color The color of the gizmo
  45096. */
  45097. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45098. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45099. private _selectNode;
  45100. /**
  45101. * Updates the bounding box information for the Gizmo
  45102. */
  45103. updateBoundingBox(): void;
  45104. private _updateRotationSpheres;
  45105. private _updateScaleBoxes;
  45106. /**
  45107. * Enables rotation on the specified axis and disables rotation on the others
  45108. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45109. */
  45110. setEnabledRotationAxis(axis: string): void;
  45111. /**
  45112. * Enables/disables scaling
  45113. * @param enable if scaling should be enabled
  45114. */
  45115. setEnabledScaling(enable: boolean): void;
  45116. private _updateDummy;
  45117. /**
  45118. * Enables a pointer drag behavior on the bounding box of the gizmo
  45119. */
  45120. enableDragBehavior(): void;
  45121. /**
  45122. * Disposes of the gizmo
  45123. */
  45124. dispose(): void;
  45125. /**
  45126. * 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)
  45127. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45128. * @returns the bounding box mesh with the passed in mesh as a child
  45129. */
  45130. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45131. /**
  45132. * CustomMeshes are not supported by this gizmo
  45133. * @param mesh The mesh to replace the default mesh of the gizmo
  45134. */
  45135. setCustomMesh(mesh: Mesh): void;
  45136. }
  45137. }
  45138. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45139. import { Observable } from "babylonjs/Misc/observable";
  45140. import { Nullable } from "babylonjs/types";
  45141. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45143. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45144. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45145. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45146. import "babylonjs/Meshes/Builders/linesBuilder";
  45147. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45148. /**
  45149. * Single plane rotation gizmo
  45150. */
  45151. export class PlaneRotationGizmo extends Gizmo {
  45152. /**
  45153. * Drag behavior responsible for the gizmos dragging interactions
  45154. */
  45155. dragBehavior: PointerDragBehavior;
  45156. private _pointerObserver;
  45157. /**
  45158. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45159. */
  45160. snapDistance: number;
  45161. /**
  45162. * Event that fires each time the gizmo snaps to a new location.
  45163. * * snapDistance is the the change in distance
  45164. */
  45165. onSnapObservable: Observable<{
  45166. snapDistance: number;
  45167. }>;
  45168. private _isEnabled;
  45169. private _parent;
  45170. /**
  45171. * Creates a PlaneRotationGizmo
  45172. * @param gizmoLayer The utility layer the gizmo will be added to
  45173. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45174. * @param color The color of the gizmo
  45175. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45176. */
  45177. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45178. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45179. /**
  45180. * If the gizmo is enabled
  45181. */
  45182. isEnabled: boolean;
  45183. /**
  45184. * Disposes of the gizmo
  45185. */
  45186. dispose(): void;
  45187. }
  45188. }
  45189. declare module "babylonjs/Gizmos/rotationGizmo" {
  45190. import { Observable } from "babylonjs/Misc/observable";
  45191. import { Nullable } from "babylonjs/types";
  45192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45193. import { Mesh } from "babylonjs/Meshes/mesh";
  45194. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45195. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45196. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45197. /**
  45198. * Gizmo that enables rotating a mesh along 3 axis
  45199. */
  45200. export class RotationGizmo extends Gizmo {
  45201. /**
  45202. * Internal gizmo used for interactions on the x axis
  45203. */
  45204. xGizmo: PlaneRotationGizmo;
  45205. /**
  45206. * Internal gizmo used for interactions on the y axis
  45207. */
  45208. yGizmo: PlaneRotationGizmo;
  45209. /**
  45210. * Internal gizmo used for interactions on the z axis
  45211. */
  45212. zGizmo: PlaneRotationGizmo;
  45213. /** Fires an event when any of it's sub gizmos are dragged */
  45214. onDragStartObservable: Observable<unknown>;
  45215. /** Fires an event when any of it's sub gizmos are released from dragging */
  45216. onDragEndObservable: Observable<unknown>;
  45217. private _meshAttached;
  45218. attachedMesh: Nullable<AbstractMesh>;
  45219. /**
  45220. * Creates a RotationGizmo
  45221. * @param gizmoLayer The utility layer the gizmo will be added to
  45222. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45223. */
  45224. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45225. updateGizmoRotationToMatchAttachedMesh: boolean;
  45226. /**
  45227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45228. */
  45229. snapDistance: number;
  45230. /**
  45231. * Ratio for the scale of the gizmo (Default: 1)
  45232. */
  45233. scaleRatio: number;
  45234. /**
  45235. * Disposes of the gizmo
  45236. */
  45237. dispose(): void;
  45238. /**
  45239. * CustomMeshes are not supported by this gizmo
  45240. * @param mesh The mesh to replace the default mesh of the gizmo
  45241. */
  45242. setCustomMesh(mesh: Mesh): void;
  45243. }
  45244. }
  45245. declare module "babylonjs/Gizmos/gizmoManager" {
  45246. import { Observable } from "babylonjs/Misc/observable";
  45247. import { Nullable } from "babylonjs/types";
  45248. import { Scene, IDisposable } from "babylonjs/scene";
  45249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45250. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45251. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45252. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45253. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45254. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45255. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45256. /**
  45257. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45258. */
  45259. export class GizmoManager implements IDisposable {
  45260. private scene;
  45261. /**
  45262. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45263. */
  45264. gizmos: {
  45265. positionGizmo: Nullable<PositionGizmo>;
  45266. rotationGizmo: Nullable<RotationGizmo>;
  45267. scaleGizmo: Nullable<ScaleGizmo>;
  45268. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45269. };
  45270. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45271. clearGizmoOnEmptyPointerEvent: boolean;
  45272. /** Fires an event when the manager is attached to a mesh */
  45273. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45274. private _gizmosEnabled;
  45275. private _pointerObserver;
  45276. private _attachedMesh;
  45277. private _boundingBoxColor;
  45278. private _defaultUtilityLayer;
  45279. private _defaultKeepDepthUtilityLayer;
  45280. /**
  45281. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45282. */
  45283. boundingBoxDragBehavior: SixDofDragBehavior;
  45284. /**
  45285. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45286. */
  45287. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45288. /**
  45289. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45290. */
  45291. usePointerToAttachGizmos: boolean;
  45292. /**
  45293. * Utility layer that the bounding box gizmo belongs to
  45294. */
  45295. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45296. /**
  45297. * Utility layer that all gizmos besides bounding box belong to
  45298. */
  45299. readonly utilityLayer: UtilityLayerRenderer;
  45300. /**
  45301. * Instatiates a gizmo manager
  45302. * @param scene the scene to overlay the gizmos on top of
  45303. */
  45304. constructor(scene: Scene);
  45305. /**
  45306. * Attaches a set of gizmos to the specified mesh
  45307. * @param mesh The mesh the gizmo's should be attached to
  45308. */
  45309. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45310. /**
  45311. * If the position gizmo is enabled
  45312. */
  45313. positionGizmoEnabled: boolean;
  45314. /**
  45315. * If the rotation gizmo is enabled
  45316. */
  45317. rotationGizmoEnabled: boolean;
  45318. /**
  45319. * If the scale gizmo is enabled
  45320. */
  45321. scaleGizmoEnabled: boolean;
  45322. /**
  45323. * If the boundingBox gizmo is enabled
  45324. */
  45325. boundingBoxGizmoEnabled: boolean;
  45326. /**
  45327. * Disposes of the gizmo manager
  45328. */
  45329. dispose(): void;
  45330. }
  45331. }
  45332. declare module "babylonjs/Lights/directionalLight" {
  45333. import { Camera } from "babylonjs/Cameras/camera";
  45334. import { Scene } from "babylonjs/scene";
  45335. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45337. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45338. import { Effect } from "babylonjs/Materials/effect";
  45339. /**
  45340. * A directional light is defined by a direction (what a surprise!).
  45341. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45342. * 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.
  45343. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45344. */
  45345. export class DirectionalLight extends ShadowLight {
  45346. private _shadowFrustumSize;
  45347. /**
  45348. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45349. */
  45350. /**
  45351. * Specifies a fix frustum size for the shadow generation.
  45352. */
  45353. shadowFrustumSize: number;
  45354. private _shadowOrthoScale;
  45355. /**
  45356. * Gets the shadow projection scale against the optimal computed one.
  45357. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45358. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45359. */
  45360. /**
  45361. * Sets the shadow projection scale against the optimal computed one.
  45362. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45363. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45364. */
  45365. shadowOrthoScale: number;
  45366. /**
  45367. * Automatically compute the projection matrix to best fit (including all the casters)
  45368. * on each frame.
  45369. */
  45370. autoUpdateExtends: boolean;
  45371. private _orthoLeft;
  45372. private _orthoRight;
  45373. private _orthoTop;
  45374. private _orthoBottom;
  45375. /**
  45376. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45377. * The directional light is emitted from everywhere in the given direction.
  45378. * It can cast shadows.
  45379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45380. * @param name The friendly name of the light
  45381. * @param direction The direction of the light
  45382. * @param scene The scene the light belongs to
  45383. */
  45384. constructor(name: string, direction: Vector3, scene: Scene);
  45385. /**
  45386. * Returns the string "DirectionalLight".
  45387. * @return The class name
  45388. */
  45389. getClassName(): string;
  45390. /**
  45391. * Returns the integer 1.
  45392. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45393. */
  45394. getTypeID(): number;
  45395. /**
  45396. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45397. * Returns the DirectionalLight Shadow projection matrix.
  45398. */
  45399. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45400. /**
  45401. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45402. * Returns the DirectionalLight Shadow projection matrix.
  45403. */
  45404. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45405. /**
  45406. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45407. * Returns the DirectionalLight Shadow projection matrix.
  45408. */
  45409. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45410. protected _buildUniformLayout(): void;
  45411. /**
  45412. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45413. * @param effect The effect to update
  45414. * @param lightIndex The index of the light in the effect to update
  45415. * @returns The directional light
  45416. */
  45417. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45418. /**
  45419. * Gets the minZ used for shadow according to both the scene and the light.
  45420. *
  45421. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45422. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45423. * @param activeCamera The camera we are returning the min for
  45424. * @returns the depth min z
  45425. */
  45426. getDepthMinZ(activeCamera: Camera): number;
  45427. /**
  45428. * Gets the maxZ used for shadow according to both the scene and the light.
  45429. *
  45430. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45431. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45432. * @param activeCamera The camera we are returning the max for
  45433. * @returns the depth max z
  45434. */
  45435. getDepthMaxZ(activeCamera: Camera): number;
  45436. /**
  45437. * Prepares the list of defines specific to the light type.
  45438. * @param defines the list of defines
  45439. * @param lightIndex defines the index of the light for the effect
  45440. */
  45441. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45442. }
  45443. }
  45444. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45445. import { Mesh } from "babylonjs/Meshes/mesh";
  45446. /**
  45447. * Class containing static functions to help procedurally build meshes
  45448. */
  45449. export class HemisphereBuilder {
  45450. /**
  45451. * Creates a hemisphere mesh
  45452. * @param name defines the name of the mesh
  45453. * @param options defines the options used to create the mesh
  45454. * @param scene defines the hosting scene
  45455. * @returns the hemisphere mesh
  45456. */
  45457. static CreateHemisphere(name: string, options: {
  45458. segments?: number;
  45459. diameter?: number;
  45460. sideOrientation?: number;
  45461. }, scene: any): Mesh;
  45462. }
  45463. }
  45464. declare module "babylonjs/Lights/spotLight" {
  45465. import { Nullable } from "babylonjs/types";
  45466. import { Scene } from "babylonjs/scene";
  45467. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45469. import { Effect } from "babylonjs/Materials/effect";
  45470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45471. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45472. /**
  45473. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45474. * These values define a cone of light starting from the position, emitting toward the direction.
  45475. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45476. * and the exponent defines the speed of the decay of the light with distance (reach).
  45477. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45478. */
  45479. export class SpotLight extends ShadowLight {
  45480. private _angle;
  45481. private _innerAngle;
  45482. private _cosHalfAngle;
  45483. private _lightAngleScale;
  45484. private _lightAngleOffset;
  45485. /**
  45486. * Gets the cone angle of the spot light in Radians.
  45487. */
  45488. /**
  45489. * Sets the cone angle of the spot light in Radians.
  45490. */
  45491. angle: number;
  45492. /**
  45493. * Only used in gltf falloff mode, this defines the angle where
  45494. * the directional falloff will start before cutting at angle which could be seen
  45495. * as outer angle.
  45496. */
  45497. /**
  45498. * Only used in gltf falloff mode, this defines the angle where
  45499. * the directional falloff will start before cutting at angle which could be seen
  45500. * as outer angle.
  45501. */
  45502. innerAngle: number;
  45503. private _shadowAngleScale;
  45504. /**
  45505. * Allows scaling the angle of the light for shadow generation only.
  45506. */
  45507. /**
  45508. * Allows scaling the angle of the light for shadow generation only.
  45509. */
  45510. shadowAngleScale: number;
  45511. /**
  45512. * The light decay speed with the distance from the emission spot.
  45513. */
  45514. exponent: number;
  45515. private _projectionTextureMatrix;
  45516. /**
  45517. * Allows reading the projecton texture
  45518. */
  45519. readonly projectionTextureMatrix: Matrix;
  45520. protected _projectionTextureLightNear: number;
  45521. /**
  45522. * Gets the near clip of the Spotlight for texture projection.
  45523. */
  45524. /**
  45525. * Sets the near clip of the Spotlight for texture projection.
  45526. */
  45527. projectionTextureLightNear: number;
  45528. protected _projectionTextureLightFar: number;
  45529. /**
  45530. * Gets the far clip of the Spotlight for texture projection.
  45531. */
  45532. /**
  45533. * Sets the far clip of the Spotlight for texture projection.
  45534. */
  45535. projectionTextureLightFar: number;
  45536. protected _projectionTextureUpDirection: Vector3;
  45537. /**
  45538. * Gets the Up vector of the Spotlight for texture projection.
  45539. */
  45540. /**
  45541. * Sets the Up vector of the Spotlight for texture projection.
  45542. */
  45543. projectionTextureUpDirection: Vector3;
  45544. private _projectionTexture;
  45545. /**
  45546. * Gets the projection texture of the light.
  45547. */
  45548. /**
  45549. * Sets the projection texture of the light.
  45550. */
  45551. projectionTexture: Nullable<BaseTexture>;
  45552. private _projectionTextureViewLightDirty;
  45553. private _projectionTextureProjectionLightDirty;
  45554. private _projectionTextureDirty;
  45555. private _projectionTextureViewTargetVector;
  45556. private _projectionTextureViewLightMatrix;
  45557. private _projectionTextureProjectionLightMatrix;
  45558. private _projectionTextureScalingMatrix;
  45559. /**
  45560. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45561. * It can cast shadows.
  45562. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45563. * @param name The light friendly name
  45564. * @param position The position of the spot light in the scene
  45565. * @param direction The direction of the light in the scene
  45566. * @param angle The cone angle of the light in Radians
  45567. * @param exponent The light decay speed with the distance from the emission spot
  45568. * @param scene The scene the lights belongs to
  45569. */
  45570. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45571. /**
  45572. * Returns the string "SpotLight".
  45573. * @returns the class name
  45574. */
  45575. getClassName(): string;
  45576. /**
  45577. * Returns the integer 2.
  45578. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45579. */
  45580. getTypeID(): number;
  45581. /**
  45582. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45583. */
  45584. protected _setDirection(value: Vector3): void;
  45585. /**
  45586. * Overrides the position setter to recompute the projection texture view light Matrix.
  45587. */
  45588. protected _setPosition(value: Vector3): void;
  45589. /**
  45590. * 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.
  45591. * Returns the SpotLight.
  45592. */
  45593. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45594. protected _computeProjectionTextureViewLightMatrix(): void;
  45595. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45596. /**
  45597. * Main function for light texture projection matrix computing.
  45598. */
  45599. protected _computeProjectionTextureMatrix(): void;
  45600. protected _buildUniformLayout(): void;
  45601. private _computeAngleValues;
  45602. /**
  45603. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45604. * @param effect The effect to update
  45605. * @param lightIndex The index of the light in the effect to update
  45606. * @returns The spot light
  45607. */
  45608. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45609. /**
  45610. * Disposes the light and the associated resources.
  45611. */
  45612. dispose(): void;
  45613. /**
  45614. * Prepares the list of defines specific to the light type.
  45615. * @param defines the list of defines
  45616. * @param lightIndex defines the index of the light for the effect
  45617. */
  45618. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45619. }
  45620. }
  45621. declare module "babylonjs/Gizmos/lightGizmo" {
  45622. import { Nullable } from "babylonjs/types";
  45623. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45624. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45625. import { Light } from "babylonjs/Lights/light";
  45626. /**
  45627. * Gizmo that enables viewing a light
  45628. */
  45629. export class LightGizmo extends Gizmo {
  45630. private _lightMesh;
  45631. private _material;
  45632. private cachedPosition;
  45633. private cachedForward;
  45634. /**
  45635. * Creates a LightGizmo
  45636. * @param gizmoLayer The utility layer the gizmo will be added to
  45637. */
  45638. constructor(gizmoLayer?: UtilityLayerRenderer);
  45639. private _light;
  45640. /**
  45641. * The light that the gizmo is attached to
  45642. */
  45643. light: Nullable<Light>;
  45644. /**
  45645. * @hidden
  45646. * Updates the gizmo to match the attached mesh's position/rotation
  45647. */
  45648. protected _update(): void;
  45649. private static _Scale;
  45650. /**
  45651. * Creates the lines for a light mesh
  45652. */
  45653. private static _createLightLines;
  45654. /**
  45655. * Disposes of the light gizmo
  45656. */
  45657. dispose(): void;
  45658. private static _CreateHemisphericLightMesh;
  45659. private static _CreatePointLightMesh;
  45660. private static _CreateSpotLightMesh;
  45661. private static _CreateDirectionalLightMesh;
  45662. }
  45663. }
  45664. declare module "babylonjs/Gizmos/index" {
  45665. export * from "babylonjs/Gizmos/axisDragGizmo";
  45666. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45667. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45668. export * from "babylonjs/Gizmos/gizmo";
  45669. export * from "babylonjs/Gizmos/gizmoManager";
  45670. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45671. export * from "babylonjs/Gizmos/positionGizmo";
  45672. export * from "babylonjs/Gizmos/rotationGizmo";
  45673. export * from "babylonjs/Gizmos/scaleGizmo";
  45674. export * from "babylonjs/Gizmos/lightGizmo";
  45675. }
  45676. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45677. /** @hidden */
  45678. export var backgroundFragmentDeclaration: {
  45679. name: string;
  45680. shader: string;
  45681. };
  45682. }
  45683. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45684. /** @hidden */
  45685. export var backgroundUboDeclaration: {
  45686. name: string;
  45687. shader: string;
  45688. };
  45689. }
  45690. declare module "babylonjs/Shaders/background.fragment" {
  45691. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45692. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45693. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45694. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45695. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45696. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45697. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45698. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45699. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45700. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45701. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45702. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45704. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45705. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45706. /** @hidden */
  45707. export var backgroundPixelShader: {
  45708. name: string;
  45709. shader: string;
  45710. };
  45711. }
  45712. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45713. /** @hidden */
  45714. export var backgroundVertexDeclaration: {
  45715. name: string;
  45716. shader: string;
  45717. };
  45718. }
  45719. declare module "babylonjs/Shaders/background.vertex" {
  45720. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45721. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45723. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45724. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45725. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45726. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45727. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45728. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45729. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45730. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45731. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45732. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45733. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45734. /** @hidden */
  45735. export var backgroundVertexShader: {
  45736. name: string;
  45737. shader: string;
  45738. };
  45739. }
  45740. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45741. import { Nullable, int, float } from "babylonjs/types";
  45742. import { Scene } from "babylonjs/scene";
  45743. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45744. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45746. import { Mesh } from "babylonjs/Meshes/mesh";
  45747. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45748. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45749. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45751. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45752. import "babylonjs/Shaders/background.fragment";
  45753. import "babylonjs/Shaders/background.vertex";
  45754. /**
  45755. * Background material used to create an efficient environement around your scene.
  45756. */
  45757. export class BackgroundMaterial extends PushMaterial {
  45758. /**
  45759. * Standard reflectance value at parallel view angle.
  45760. */
  45761. static StandardReflectance0: number;
  45762. /**
  45763. * Standard reflectance value at grazing angle.
  45764. */
  45765. static StandardReflectance90: number;
  45766. protected _primaryColor: Color3;
  45767. /**
  45768. * Key light Color (multiply against the environement texture)
  45769. */
  45770. primaryColor: Color3;
  45771. protected __perceptualColor: Nullable<Color3>;
  45772. /**
  45773. * Experimental Internal Use Only.
  45774. *
  45775. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45776. * This acts as a helper to set the primary color to a more "human friendly" value.
  45777. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45778. * output color as close as possible from the chosen value.
  45779. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45780. * part of lighting setup.)
  45781. */
  45782. _perceptualColor: Nullable<Color3>;
  45783. protected _primaryColorShadowLevel: float;
  45784. /**
  45785. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45786. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45787. */
  45788. primaryColorShadowLevel: float;
  45789. protected _primaryColorHighlightLevel: float;
  45790. /**
  45791. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45792. * The primary color is used at the level chosen to define what the white area would look.
  45793. */
  45794. primaryColorHighlightLevel: float;
  45795. protected _reflectionTexture: Nullable<BaseTexture>;
  45796. /**
  45797. * Reflection Texture used in the material.
  45798. * Should be author in a specific way for the best result (refer to the documentation).
  45799. */
  45800. reflectionTexture: Nullable<BaseTexture>;
  45801. protected _reflectionBlur: float;
  45802. /**
  45803. * Reflection Texture level of blur.
  45804. *
  45805. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45806. * texture twice.
  45807. */
  45808. reflectionBlur: float;
  45809. protected _diffuseTexture: Nullable<BaseTexture>;
  45810. /**
  45811. * Diffuse Texture used in the material.
  45812. * Should be author in a specific way for the best result (refer to the documentation).
  45813. */
  45814. diffuseTexture: Nullable<BaseTexture>;
  45815. protected _shadowLights: Nullable<IShadowLight[]>;
  45816. /**
  45817. * Specify the list of lights casting shadow on the material.
  45818. * All scene shadow lights will be included if null.
  45819. */
  45820. shadowLights: Nullable<IShadowLight[]>;
  45821. protected _shadowLevel: float;
  45822. /**
  45823. * Helps adjusting the shadow to a softer level if required.
  45824. * 0 means black shadows and 1 means no shadows.
  45825. */
  45826. shadowLevel: float;
  45827. protected _sceneCenter: Vector3;
  45828. /**
  45829. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45830. * It is usually zero but might be interesting to modify according to your setup.
  45831. */
  45832. sceneCenter: Vector3;
  45833. protected _opacityFresnel: boolean;
  45834. /**
  45835. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45836. * This helps ensuring a nice transition when the camera goes under the ground.
  45837. */
  45838. opacityFresnel: boolean;
  45839. protected _reflectionFresnel: boolean;
  45840. /**
  45841. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45842. * This helps adding a mirror texture on the ground.
  45843. */
  45844. reflectionFresnel: boolean;
  45845. protected _reflectionFalloffDistance: number;
  45846. /**
  45847. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45848. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45849. */
  45850. reflectionFalloffDistance: number;
  45851. protected _reflectionAmount: number;
  45852. /**
  45853. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45854. */
  45855. reflectionAmount: number;
  45856. protected _reflectionReflectance0: number;
  45857. /**
  45858. * This specifies the weight of the reflection at grazing angle.
  45859. */
  45860. reflectionReflectance0: number;
  45861. protected _reflectionReflectance90: number;
  45862. /**
  45863. * This specifies the weight of the reflection at a perpendicular point of view.
  45864. */
  45865. reflectionReflectance90: number;
  45866. /**
  45867. * Sets the reflection reflectance fresnel values according to the default standard
  45868. * empirically know to work well :-)
  45869. */
  45870. reflectionStandardFresnelWeight: number;
  45871. protected _useRGBColor: boolean;
  45872. /**
  45873. * Helps to directly use the maps channels instead of their level.
  45874. */
  45875. useRGBColor: boolean;
  45876. protected _enableNoise: boolean;
  45877. /**
  45878. * This helps reducing the banding effect that could occur on the background.
  45879. */
  45880. enableNoise: boolean;
  45881. /**
  45882. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45883. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45884. * Recommended to be keep at 1.0 except for special cases.
  45885. */
  45886. fovMultiplier: number;
  45887. private _fovMultiplier;
  45888. /**
  45889. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45890. */
  45891. useEquirectangularFOV: boolean;
  45892. private _maxSimultaneousLights;
  45893. /**
  45894. * Number of Simultaneous lights allowed on the material.
  45895. */
  45896. maxSimultaneousLights: int;
  45897. /**
  45898. * Default configuration related to image processing available in the Background Material.
  45899. */
  45900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45901. /**
  45902. * Keep track of the image processing observer to allow dispose and replace.
  45903. */
  45904. private _imageProcessingObserver;
  45905. /**
  45906. * Attaches a new image processing configuration to the PBR Material.
  45907. * @param configuration (if null the scene configuration will be use)
  45908. */
  45909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45910. /**
  45911. * Gets the image processing configuration used either in this material.
  45912. */
  45913. /**
  45914. * Sets the Default image processing configuration used either in the this material.
  45915. *
  45916. * If sets to null, the scene one is in use.
  45917. */
  45918. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45919. /**
  45920. * Gets wether the color curves effect is enabled.
  45921. */
  45922. /**
  45923. * Sets wether the color curves effect is enabled.
  45924. */
  45925. cameraColorCurvesEnabled: boolean;
  45926. /**
  45927. * Gets wether the color grading effect is enabled.
  45928. */
  45929. /**
  45930. * Gets wether the color grading effect is enabled.
  45931. */
  45932. cameraColorGradingEnabled: boolean;
  45933. /**
  45934. * Gets wether tonemapping is enabled or not.
  45935. */
  45936. /**
  45937. * Sets wether tonemapping is enabled or not
  45938. */
  45939. cameraToneMappingEnabled: boolean;
  45940. /**
  45941. * The camera exposure used on this material.
  45942. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45943. * This corresponds to a photographic exposure.
  45944. */
  45945. /**
  45946. * The camera exposure used on this material.
  45947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45948. * This corresponds to a photographic exposure.
  45949. */
  45950. cameraExposure: float;
  45951. /**
  45952. * Gets The camera contrast used on this material.
  45953. */
  45954. /**
  45955. * Sets The camera contrast used on this material.
  45956. */
  45957. cameraContrast: float;
  45958. /**
  45959. * Gets the Color Grading 2D Lookup Texture.
  45960. */
  45961. /**
  45962. * Sets the Color Grading 2D Lookup Texture.
  45963. */
  45964. cameraColorGradingTexture: Nullable<BaseTexture>;
  45965. /**
  45966. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45967. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45968. * 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;
  45969. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45970. */
  45971. /**
  45972. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45973. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45974. * 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;
  45975. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45976. */
  45977. cameraColorCurves: Nullable<ColorCurves>;
  45978. /**
  45979. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45980. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45981. */
  45982. switchToBGR: boolean;
  45983. private _renderTargets;
  45984. private _reflectionControls;
  45985. private _white;
  45986. private _primaryShadowColor;
  45987. private _primaryHighlightColor;
  45988. /**
  45989. * Instantiates a Background Material in the given scene
  45990. * @param name The friendly name of the material
  45991. * @param scene The scene to add the material to
  45992. */
  45993. constructor(name: string, scene: Scene);
  45994. /**
  45995. * Gets a boolean indicating that current material needs to register RTT
  45996. */
  45997. readonly hasRenderTargetTextures: boolean;
  45998. /**
  45999. * The entire material has been created in order to prevent overdraw.
  46000. * @returns false
  46001. */
  46002. needAlphaTesting(): boolean;
  46003. /**
  46004. * The entire material has been created in order to prevent overdraw.
  46005. * @returns true if blending is enable
  46006. */
  46007. needAlphaBlending(): boolean;
  46008. /**
  46009. * Checks wether the material is ready to be rendered for a given mesh.
  46010. * @param mesh The mesh to render
  46011. * @param subMesh The submesh to check against
  46012. * @param useInstances Specify wether or not the material is used with instances
  46013. * @returns true if all the dependencies are ready (Textures, Effects...)
  46014. */
  46015. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46016. /**
  46017. * Compute the primary color according to the chosen perceptual color.
  46018. */
  46019. private _computePrimaryColorFromPerceptualColor;
  46020. /**
  46021. * Compute the highlights and shadow colors according to their chosen levels.
  46022. */
  46023. private _computePrimaryColors;
  46024. /**
  46025. * Build the uniform buffer used in the material.
  46026. */
  46027. buildUniformLayout(): void;
  46028. /**
  46029. * Unbind the material.
  46030. */
  46031. unbind(): void;
  46032. /**
  46033. * Bind only the world matrix to the material.
  46034. * @param world The world matrix to bind.
  46035. */
  46036. bindOnlyWorldMatrix(world: Matrix): void;
  46037. /**
  46038. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46039. * @param world The world matrix to bind.
  46040. * @param subMesh The submesh to bind for.
  46041. */
  46042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46043. /**
  46044. * Dispose the material.
  46045. * @param forceDisposeEffect Force disposal of the associated effect.
  46046. * @param forceDisposeTextures Force disposal of the associated textures.
  46047. */
  46048. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46049. /**
  46050. * Clones the material.
  46051. * @param name The cloned name.
  46052. * @returns The cloned material.
  46053. */
  46054. clone(name: string): BackgroundMaterial;
  46055. /**
  46056. * Serializes the current material to its JSON representation.
  46057. * @returns The JSON representation.
  46058. */
  46059. serialize(): any;
  46060. /**
  46061. * Gets the class name of the material
  46062. * @returns "BackgroundMaterial"
  46063. */
  46064. getClassName(): string;
  46065. /**
  46066. * Parse a JSON input to create back a background material.
  46067. * @param source The JSON data to parse
  46068. * @param scene The scene to create the parsed material in
  46069. * @param rootUrl The root url of the assets the material depends upon
  46070. * @returns the instantiated BackgroundMaterial.
  46071. */
  46072. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46073. }
  46074. }
  46075. declare module "babylonjs/Helpers/environmentHelper" {
  46076. import { Observable } from "babylonjs/Misc/observable";
  46077. import { Nullable } from "babylonjs/types";
  46078. import { Scene } from "babylonjs/scene";
  46079. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46081. import { Mesh } from "babylonjs/Meshes/mesh";
  46082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46083. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46084. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46085. import "babylonjs/Meshes/Builders/planeBuilder";
  46086. import "babylonjs/Meshes/Builders/boxBuilder";
  46087. /**
  46088. * Represents the different options available during the creation of
  46089. * a Environment helper.
  46090. *
  46091. * This can control the default ground, skybox and image processing setup of your scene.
  46092. */
  46093. export interface IEnvironmentHelperOptions {
  46094. /**
  46095. * Specifies wether or not to create a ground.
  46096. * True by default.
  46097. */
  46098. createGround: boolean;
  46099. /**
  46100. * Specifies the ground size.
  46101. * 15 by default.
  46102. */
  46103. groundSize: number;
  46104. /**
  46105. * The texture used on the ground for the main color.
  46106. * Comes from the BabylonJS CDN by default.
  46107. *
  46108. * Remarks: Can be either a texture or a url.
  46109. */
  46110. groundTexture: string | BaseTexture;
  46111. /**
  46112. * The color mixed in the ground texture by default.
  46113. * BabylonJS clearColor by default.
  46114. */
  46115. groundColor: Color3;
  46116. /**
  46117. * Specifies the ground opacity.
  46118. * 1 by default.
  46119. */
  46120. groundOpacity: number;
  46121. /**
  46122. * Enables the ground to receive shadows.
  46123. * True by default.
  46124. */
  46125. enableGroundShadow: boolean;
  46126. /**
  46127. * Helps preventing the shadow to be fully black on the ground.
  46128. * 0.5 by default.
  46129. */
  46130. groundShadowLevel: number;
  46131. /**
  46132. * Creates a mirror texture attach to the ground.
  46133. * false by default.
  46134. */
  46135. enableGroundMirror: boolean;
  46136. /**
  46137. * Specifies the ground mirror size ratio.
  46138. * 0.3 by default as the default kernel is 64.
  46139. */
  46140. groundMirrorSizeRatio: number;
  46141. /**
  46142. * Specifies the ground mirror blur kernel size.
  46143. * 64 by default.
  46144. */
  46145. groundMirrorBlurKernel: number;
  46146. /**
  46147. * Specifies the ground mirror visibility amount.
  46148. * 1 by default
  46149. */
  46150. groundMirrorAmount: number;
  46151. /**
  46152. * Specifies the ground mirror reflectance weight.
  46153. * This uses the standard weight of the background material to setup the fresnel effect
  46154. * of the mirror.
  46155. * 1 by default.
  46156. */
  46157. groundMirrorFresnelWeight: number;
  46158. /**
  46159. * Specifies the ground mirror Falloff distance.
  46160. * This can helps reducing the size of the reflection.
  46161. * 0 by Default.
  46162. */
  46163. groundMirrorFallOffDistance: number;
  46164. /**
  46165. * Specifies the ground mirror texture type.
  46166. * Unsigned Int by Default.
  46167. */
  46168. groundMirrorTextureType: number;
  46169. /**
  46170. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46171. * the shown objects.
  46172. */
  46173. groundYBias: number;
  46174. /**
  46175. * Specifies wether or not to create a skybox.
  46176. * True by default.
  46177. */
  46178. createSkybox: boolean;
  46179. /**
  46180. * Specifies the skybox size.
  46181. * 20 by default.
  46182. */
  46183. skyboxSize: number;
  46184. /**
  46185. * The texture used on the skybox for the main color.
  46186. * Comes from the BabylonJS CDN by default.
  46187. *
  46188. * Remarks: Can be either a texture or a url.
  46189. */
  46190. skyboxTexture: string | BaseTexture;
  46191. /**
  46192. * The color mixed in the skybox texture by default.
  46193. * BabylonJS clearColor by default.
  46194. */
  46195. skyboxColor: Color3;
  46196. /**
  46197. * The background rotation around the Y axis of the scene.
  46198. * This helps aligning the key lights of your scene with the background.
  46199. * 0 by default.
  46200. */
  46201. backgroundYRotation: number;
  46202. /**
  46203. * Compute automatically the size of the elements to best fit with the scene.
  46204. */
  46205. sizeAuto: boolean;
  46206. /**
  46207. * Default position of the rootMesh if autoSize is not true.
  46208. */
  46209. rootPosition: Vector3;
  46210. /**
  46211. * Sets up the image processing in the scene.
  46212. * true by default.
  46213. */
  46214. setupImageProcessing: boolean;
  46215. /**
  46216. * The texture used as your environment texture in the scene.
  46217. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46218. *
  46219. * Remarks: Can be either a texture or a url.
  46220. */
  46221. environmentTexture: string | BaseTexture;
  46222. /**
  46223. * The value of the exposure to apply to the scene.
  46224. * 0.6 by default if setupImageProcessing is true.
  46225. */
  46226. cameraExposure: number;
  46227. /**
  46228. * The value of the contrast to apply to the scene.
  46229. * 1.6 by default if setupImageProcessing is true.
  46230. */
  46231. cameraContrast: number;
  46232. /**
  46233. * Specifies wether or not tonemapping should be enabled in the scene.
  46234. * true by default if setupImageProcessing is true.
  46235. */
  46236. toneMappingEnabled: boolean;
  46237. }
  46238. /**
  46239. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46240. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46241. * It also helps with the default setup of your imageProcessing configuration.
  46242. */
  46243. export class EnvironmentHelper {
  46244. /**
  46245. * Default ground texture URL.
  46246. */
  46247. private static _groundTextureCDNUrl;
  46248. /**
  46249. * Default skybox texture URL.
  46250. */
  46251. private static _skyboxTextureCDNUrl;
  46252. /**
  46253. * Default environment texture URL.
  46254. */
  46255. private static _environmentTextureCDNUrl;
  46256. /**
  46257. * Creates the default options for the helper.
  46258. */
  46259. private static _getDefaultOptions;
  46260. private _rootMesh;
  46261. /**
  46262. * Gets the root mesh created by the helper.
  46263. */
  46264. readonly rootMesh: Mesh;
  46265. private _skybox;
  46266. /**
  46267. * Gets the skybox created by the helper.
  46268. */
  46269. readonly skybox: Nullable<Mesh>;
  46270. private _skyboxTexture;
  46271. /**
  46272. * Gets the skybox texture created by the helper.
  46273. */
  46274. readonly skyboxTexture: Nullable<BaseTexture>;
  46275. private _skyboxMaterial;
  46276. /**
  46277. * Gets the skybox material created by the helper.
  46278. */
  46279. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46280. private _ground;
  46281. /**
  46282. * Gets the ground mesh created by the helper.
  46283. */
  46284. readonly ground: Nullable<Mesh>;
  46285. private _groundTexture;
  46286. /**
  46287. * Gets the ground texture created by the helper.
  46288. */
  46289. readonly groundTexture: Nullable<BaseTexture>;
  46290. private _groundMirror;
  46291. /**
  46292. * Gets the ground mirror created by the helper.
  46293. */
  46294. readonly groundMirror: Nullable<MirrorTexture>;
  46295. /**
  46296. * Gets the ground mirror render list to helps pushing the meshes
  46297. * you wish in the ground reflection.
  46298. */
  46299. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46300. private _groundMaterial;
  46301. /**
  46302. * Gets the ground material created by the helper.
  46303. */
  46304. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46305. /**
  46306. * Stores the creation options.
  46307. */
  46308. private readonly _scene;
  46309. private _options;
  46310. /**
  46311. * This observable will be notified with any error during the creation of the environment,
  46312. * mainly texture creation errors.
  46313. */
  46314. onErrorObservable: Observable<{
  46315. message?: string;
  46316. exception?: any;
  46317. }>;
  46318. /**
  46319. * constructor
  46320. * @param options Defines the options we want to customize the helper
  46321. * @param scene The scene to add the material to
  46322. */
  46323. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46324. /**
  46325. * Updates the background according to the new options
  46326. * @param options
  46327. */
  46328. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46329. /**
  46330. * Sets the primary color of all the available elements.
  46331. * @param color the main color to affect to the ground and the background
  46332. */
  46333. setMainColor(color: Color3): void;
  46334. /**
  46335. * Setup the image processing according to the specified options.
  46336. */
  46337. private _setupImageProcessing;
  46338. /**
  46339. * Setup the environment texture according to the specified options.
  46340. */
  46341. private _setupEnvironmentTexture;
  46342. /**
  46343. * Setup the background according to the specified options.
  46344. */
  46345. private _setupBackground;
  46346. /**
  46347. * Get the scene sizes according to the setup.
  46348. */
  46349. private _getSceneSize;
  46350. /**
  46351. * Setup the ground according to the specified options.
  46352. */
  46353. private _setupGround;
  46354. /**
  46355. * Setup the ground material according to the specified options.
  46356. */
  46357. private _setupGroundMaterial;
  46358. /**
  46359. * Setup the ground diffuse texture according to the specified options.
  46360. */
  46361. private _setupGroundDiffuseTexture;
  46362. /**
  46363. * Setup the ground mirror texture according to the specified options.
  46364. */
  46365. private _setupGroundMirrorTexture;
  46366. /**
  46367. * Setup the ground to receive the mirror texture.
  46368. */
  46369. private _setupMirrorInGroundMaterial;
  46370. /**
  46371. * Setup the skybox according to the specified options.
  46372. */
  46373. private _setupSkybox;
  46374. /**
  46375. * Setup the skybox material according to the specified options.
  46376. */
  46377. private _setupSkyboxMaterial;
  46378. /**
  46379. * Setup the skybox reflection texture according to the specified options.
  46380. */
  46381. private _setupSkyboxReflectionTexture;
  46382. private _errorHandler;
  46383. /**
  46384. * Dispose all the elements created by the Helper.
  46385. */
  46386. dispose(): void;
  46387. }
  46388. }
  46389. declare module "babylonjs/Helpers/photoDome" {
  46390. import { Observable } from "babylonjs/Misc/observable";
  46391. import { Nullable } from "babylonjs/types";
  46392. import { Scene } from "babylonjs/scene";
  46393. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46394. import { Mesh } from "babylonjs/Meshes/mesh";
  46395. import { Texture } from "babylonjs/Materials/Textures/texture";
  46396. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46397. import "babylonjs/Meshes/Builders/sphereBuilder";
  46398. /**
  46399. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46400. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46401. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46402. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46403. */
  46404. export class PhotoDome extends TransformNode {
  46405. /**
  46406. * Define the image as a Monoscopic panoramic 360 image.
  46407. */
  46408. static readonly MODE_MONOSCOPIC: number;
  46409. /**
  46410. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46411. */
  46412. static readonly MODE_TOPBOTTOM: number;
  46413. /**
  46414. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46415. */
  46416. static readonly MODE_SIDEBYSIDE: number;
  46417. private _useDirectMapping;
  46418. /**
  46419. * The texture being displayed on the sphere
  46420. */
  46421. protected _photoTexture: Texture;
  46422. /**
  46423. * Gets or sets the texture being displayed on the sphere
  46424. */
  46425. photoTexture: Texture;
  46426. /**
  46427. * Observable raised when an error occured while loading the 360 image
  46428. */
  46429. onLoadErrorObservable: Observable<string>;
  46430. /**
  46431. * The skybox material
  46432. */
  46433. protected _material: BackgroundMaterial;
  46434. /**
  46435. * The surface used for the skybox
  46436. */
  46437. protected _mesh: Mesh;
  46438. /**
  46439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46440. * Also see the options.resolution property.
  46441. */
  46442. fovMultiplier: number;
  46443. private _imageMode;
  46444. /**
  46445. * Gets or set the current video mode for the video. It can be:
  46446. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46447. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46448. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46449. */
  46450. imageMode: number;
  46451. /**
  46452. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46453. * @param name Element's name, child elements will append suffixes for their own names.
  46454. * @param urlsOfPhoto defines the url of the photo to display
  46455. * @param options defines an object containing optional or exposed sub element properties
  46456. * @param onError defines a callback called when an error occured while loading the texture
  46457. */
  46458. constructor(name: string, urlOfPhoto: string, options: {
  46459. resolution?: number;
  46460. size?: number;
  46461. useDirectMapping?: boolean;
  46462. faceForward?: boolean;
  46463. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46464. private _onBeforeCameraRenderObserver;
  46465. private _changeImageMode;
  46466. /**
  46467. * Releases resources associated with this node.
  46468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46470. */
  46471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46472. }
  46473. }
  46474. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46476. /** @hidden */
  46477. export var rgbdDecodePixelShader: {
  46478. name: string;
  46479. shader: string;
  46480. };
  46481. }
  46482. declare module "babylonjs/Misc/brdfTextureTools" {
  46483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46484. import { Scene } from "babylonjs/scene";
  46485. import "babylonjs/Shaders/rgbdDecode.fragment";
  46486. /**
  46487. * Class used to host texture specific utilities
  46488. */
  46489. export class BRDFTextureTools {
  46490. /**
  46491. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46492. * @param texture the texture to expand.
  46493. */
  46494. private static _ExpandDefaultBRDFTexture;
  46495. /**
  46496. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46497. * @param scene defines the hosting scene
  46498. * @returns the environment BRDF texture
  46499. */
  46500. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46501. private static _environmentBRDFBase64Texture;
  46502. }
  46503. }
  46504. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46505. import { Nullable } from "babylonjs/types";
  46506. import { IAnimatable } from "babylonjs/Misc/tools";
  46507. import { Color3 } from "babylonjs/Maths/math";
  46508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46509. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46510. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46511. import { Engine } from "babylonjs/Engines/engine";
  46512. import { Scene } from "babylonjs/scene";
  46513. /**
  46514. * @hidden
  46515. */
  46516. export interface IMaterialClearCoatDefines {
  46517. CLEARCOAT: boolean;
  46518. CLEARCOAT_DEFAULTIOR: boolean;
  46519. CLEARCOAT_TEXTURE: boolean;
  46520. CLEARCOAT_TEXTUREDIRECTUV: number;
  46521. CLEARCOAT_BUMP: boolean;
  46522. CLEARCOAT_BUMPDIRECTUV: number;
  46523. CLEARCOAT_TINT: boolean;
  46524. CLEARCOAT_TINT_TEXTURE: boolean;
  46525. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46526. /** @hidden */
  46527. _areTexturesDirty: boolean;
  46528. }
  46529. /**
  46530. * Define the code related to the clear coat parameters of the pbr material.
  46531. */
  46532. export class PBRClearCoatConfiguration {
  46533. /**
  46534. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46535. * The default fits with a polyurethane material.
  46536. */
  46537. private static readonly _DefaultIndexOfRefraction;
  46538. private _isEnabled;
  46539. /**
  46540. * Defines if the clear coat is enabled in the material.
  46541. */
  46542. isEnabled: boolean;
  46543. /**
  46544. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46545. */
  46546. intensity: number;
  46547. /**
  46548. * Defines the clear coat layer roughness.
  46549. */
  46550. roughness: number;
  46551. private _indexOfRefraction;
  46552. /**
  46553. * Defines the index of refraction of the clear coat.
  46554. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46555. * The default fits with a polyurethane material.
  46556. * Changing the default value is more performance intensive.
  46557. */
  46558. indexOfRefraction: number;
  46559. private _texture;
  46560. /**
  46561. * Stores the clear coat values in a texture.
  46562. */
  46563. texture: Nullable<BaseTexture>;
  46564. private _bumpTexture;
  46565. /**
  46566. * Define the clear coat specific bump texture.
  46567. */
  46568. bumpTexture: Nullable<BaseTexture>;
  46569. private _isTintEnabled;
  46570. /**
  46571. * Defines if the clear coat tint is enabled in the material.
  46572. */
  46573. isTintEnabled: boolean;
  46574. /**
  46575. * Defines the clear coat tint of the material.
  46576. * This is only use if tint is enabled
  46577. */
  46578. tintColor: Color3;
  46579. /**
  46580. * Defines the distance at which the tint color should be found in the
  46581. * clear coat media.
  46582. * This is only use if tint is enabled
  46583. */
  46584. tintColorAtDistance: number;
  46585. /**
  46586. * Defines the clear coat layer thickness.
  46587. * This is only use if tint is enabled
  46588. */
  46589. tintThickness: number;
  46590. private _tintTexture;
  46591. /**
  46592. * Stores the clear tint values in a texture.
  46593. * rgb is tint
  46594. * a is a thickness factor
  46595. */
  46596. tintTexture: Nullable<BaseTexture>;
  46597. /** @hidden */
  46598. private _internalMarkAllSubMeshesAsTexturesDirty;
  46599. /** @hidden */
  46600. _markAllSubMeshesAsTexturesDirty(): void;
  46601. /**
  46602. * Instantiate a new istance of clear coat configuration.
  46603. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46604. */
  46605. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46606. /**
  46607. * Gets wehter the submesh is ready to be used or not.
  46608. * @param defines the list of "defines" to update.
  46609. * @param scene defines the scene the material belongs to.
  46610. * @param engine defines the engine the material belongs to.
  46611. * @param disableBumpMap defines wether the material disables bump or not.
  46612. * @returns - boolean indicating that the submesh is ready or not.
  46613. */
  46614. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46615. /**
  46616. * Checks to see if a texture is used in the material.
  46617. * @param defines the list of "defines" to update.
  46618. * @param scene defines the scene to the material belongs to.
  46619. */
  46620. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46621. /**
  46622. * Binds the material data.
  46623. * @param uniformBuffer defines the Uniform buffer to fill in.
  46624. * @param scene defines the scene the material belongs to.
  46625. * @param engine defines the engine the material belongs to.
  46626. * @param disableBumpMap defines wether the material disables bump or not.
  46627. * @param isFrozen defines wether the material is frozen or not.
  46628. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46629. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46630. */
  46631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46632. /**
  46633. * Checks to see if a texture is used in the material.
  46634. * @param texture - Base texture to use.
  46635. * @returns - Boolean specifying if a texture is used in the material.
  46636. */
  46637. hasTexture(texture: BaseTexture): boolean;
  46638. /**
  46639. * Returns an array of the actively used textures.
  46640. * @param activeTextures Array of BaseTextures
  46641. */
  46642. getActiveTextures(activeTextures: BaseTexture[]): void;
  46643. /**
  46644. * Returns the animatable textures.
  46645. * @param animatables Array of animatable textures.
  46646. */
  46647. getAnimatables(animatables: IAnimatable[]): void;
  46648. /**
  46649. * Disposes the resources of the material.
  46650. * @param forceDisposeTextures - Forces the disposal of all textures.
  46651. */
  46652. dispose(forceDisposeTextures?: boolean): void;
  46653. /**
  46654. * Get the current class name of the texture useful for serialization or dynamic coding.
  46655. * @returns "PBRClearCoatConfiguration"
  46656. */
  46657. getClassName(): string;
  46658. /**
  46659. * Add fallbacks to the effect fallbacks list.
  46660. * @param defines defines the Base texture to use.
  46661. * @param fallbacks defines the current fallback list.
  46662. * @param currentRank defines the current fallback rank.
  46663. * @returns the new fallback rank.
  46664. */
  46665. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46666. /**
  46667. * Add the required uniforms to the current list.
  46668. * @param uniforms defines the current uniform list.
  46669. */
  46670. static AddUniforms(uniforms: string[]): void;
  46671. /**
  46672. * Add the required samplers to the current list.
  46673. * @param samplers defines the current sampler list.
  46674. */
  46675. static AddSamplers(samplers: string[]): void;
  46676. /**
  46677. * Add the required uniforms to the current buffer.
  46678. * @param uniformBuffer defines the current uniform buffer.
  46679. */
  46680. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46681. /**
  46682. * Makes a duplicate of the current configuration into another one.
  46683. * @param clearCoatConfiguration define the config where to copy the info
  46684. */
  46685. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46686. /**
  46687. * Serializes this clear coat configuration.
  46688. * @returns - An object with the serialized config.
  46689. */
  46690. serialize(): any;
  46691. /**
  46692. * Parses a anisotropy Configuration from a serialized object.
  46693. * @param source - Serialized object.
  46694. * @param scene Defines the scene we are parsing for
  46695. * @param rootUrl Defines the rootUrl to load from
  46696. */
  46697. parse(source: any, scene: Scene, rootUrl: string): void;
  46698. }
  46699. }
  46700. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46701. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46702. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46704. import { Vector2 } from "babylonjs/Maths/math";
  46705. import { Scene } from "babylonjs/scene";
  46706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46707. import { IAnimatable } from "babylonjs/Misc/tools";
  46708. import { Nullable } from "babylonjs/types";
  46709. /**
  46710. * @hidden
  46711. */
  46712. export interface IMaterialAnisotropicDefines {
  46713. ANISOTROPIC: boolean;
  46714. ANISOTROPIC_TEXTURE: boolean;
  46715. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46716. MAINUV1: boolean;
  46717. _areTexturesDirty: boolean;
  46718. _needUVs: boolean;
  46719. }
  46720. /**
  46721. * Define the code related to the anisotropic parameters of the pbr material.
  46722. */
  46723. export class PBRAnisotropicConfiguration {
  46724. private _isEnabled;
  46725. /**
  46726. * Defines if the anisotropy is enabled in the material.
  46727. */
  46728. isEnabled: boolean;
  46729. /**
  46730. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46731. */
  46732. intensity: number;
  46733. /**
  46734. * Defines if the effect is along the tangents, bitangents or in between.
  46735. * By default, the effect is "strectching" the highlights along the tangents.
  46736. */
  46737. direction: Vector2;
  46738. private _texture;
  46739. /**
  46740. * Stores the anisotropy values in a texture.
  46741. * rg is direction (like normal from -1 to 1)
  46742. * b is a intensity
  46743. */
  46744. texture: Nullable<BaseTexture>;
  46745. /** @hidden */
  46746. private _internalMarkAllSubMeshesAsTexturesDirty;
  46747. /** @hidden */
  46748. _markAllSubMeshesAsTexturesDirty(): void;
  46749. /**
  46750. * Instantiate a new istance of anisotropy configuration.
  46751. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46752. */
  46753. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46754. /**
  46755. * Specifies that the submesh is ready to be used.
  46756. * @param defines the list of "defines" to update.
  46757. * @param scene defines the scene the material belongs to.
  46758. * @returns - boolean indicating that the submesh is ready or not.
  46759. */
  46760. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46761. /**
  46762. * Checks to see if a texture is used in the material.
  46763. * @param defines the list of "defines" to update.
  46764. * @param mesh the mesh we are preparing the defines for.
  46765. * @param scene defines the scene the material belongs to.
  46766. */
  46767. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46768. /**
  46769. * Binds the material data.
  46770. * @param uniformBuffer defines the Uniform buffer to fill in.
  46771. * @param scene defines the scene the material belongs to.
  46772. * @param isFrozen defines wether the material is frozen or not.
  46773. */
  46774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46775. /**
  46776. * Checks to see if a texture is used in the material.
  46777. * @param texture - Base texture to use.
  46778. * @returns - Boolean specifying if a texture is used in the material.
  46779. */
  46780. hasTexture(texture: BaseTexture): boolean;
  46781. /**
  46782. * Returns an array of the actively used textures.
  46783. * @param activeTextures Array of BaseTextures
  46784. */
  46785. getActiveTextures(activeTextures: BaseTexture[]): void;
  46786. /**
  46787. * Returns the animatable textures.
  46788. * @param animatables Array of animatable textures.
  46789. */
  46790. getAnimatables(animatables: IAnimatable[]): void;
  46791. /**
  46792. * Disposes the resources of the material.
  46793. * @param forceDisposeTextures - Forces the disposal of all textures.
  46794. */
  46795. dispose(forceDisposeTextures?: boolean): void;
  46796. /**
  46797. * Get the current class name of the texture useful for serialization or dynamic coding.
  46798. * @returns "PBRAnisotropicConfiguration"
  46799. */
  46800. getClassName(): string;
  46801. /**
  46802. * Add fallbacks to the effect fallbacks list.
  46803. * @param defines defines the Base texture to use.
  46804. * @param fallbacks defines the current fallback list.
  46805. * @param currentRank defines the current fallback rank.
  46806. * @returns the new fallback rank.
  46807. */
  46808. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46809. /**
  46810. * Add the required uniforms to the current list.
  46811. * @param uniforms defines the current uniform list.
  46812. */
  46813. static AddUniforms(uniforms: string[]): void;
  46814. /**
  46815. * Add the required uniforms to the current buffer.
  46816. * @param uniformBuffer defines the current uniform buffer.
  46817. */
  46818. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46819. /**
  46820. * Add the required samplers to the current list.
  46821. * @param samplers defines the current sampler list.
  46822. */
  46823. static AddSamplers(samplers: string[]): void;
  46824. /**
  46825. * Makes a duplicate of the current configuration into another one.
  46826. * @param anisotropicConfiguration define the config where to copy the info
  46827. */
  46828. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46829. /**
  46830. * Serializes this anisotropy configuration.
  46831. * @returns - An object with the serialized config.
  46832. */
  46833. serialize(): any;
  46834. /**
  46835. * Parses a anisotropy Configuration from a serialized object.
  46836. * @param source - Serialized object.
  46837. * @param scene Defines the scene we are parsing for
  46838. * @param rootUrl Defines the rootUrl to load from
  46839. */
  46840. parse(source: any, scene: Scene, rootUrl: string): void;
  46841. }
  46842. }
  46843. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46844. import { Scene } from "babylonjs/scene";
  46845. /**
  46846. * @hidden
  46847. */
  46848. export interface IMaterialBRDFDefines {
  46849. BRDF_V_HEIGHT_CORRELATED: boolean;
  46850. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46851. SPHERICAL_HARMONICS: boolean;
  46852. /** @hidden */
  46853. _areMiscDirty: boolean;
  46854. }
  46855. /**
  46856. * Define the code related to the BRDF parameters of the pbr material.
  46857. */
  46858. export class PBRBRDFConfiguration {
  46859. /**
  46860. * Default value used for the energy conservation.
  46861. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46862. */
  46863. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46864. /**
  46865. * Default value used for the Smith Visibility Height Correlated mode.
  46866. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46867. */
  46868. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46869. /**
  46870. * Default value used for the IBL diffuse part.
  46871. * This can help switching back to the polynomials mode globally which is a tiny bit
  46872. * less GPU intensive at the drawback of a lower quality.
  46873. */
  46874. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46875. private _useEnergyConservation;
  46876. /**
  46877. * Defines if the material uses energy conservation.
  46878. */
  46879. useEnergyConservation: boolean;
  46880. private _useSmithVisibilityHeightCorrelated;
  46881. /**
  46882. * LEGACY Mode set to false
  46883. * Defines if the material uses height smith correlated visibility term.
  46884. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46885. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46886. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46887. * Not relying on height correlated will also disable energy conservation.
  46888. */
  46889. useSmithVisibilityHeightCorrelated: boolean;
  46890. private _useSphericalHarmonics;
  46891. /**
  46892. * LEGACY Mode set to false
  46893. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46894. * diffuse part of the IBL.
  46895. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46896. * to the ground truth.
  46897. */
  46898. useSphericalHarmonics: boolean;
  46899. /** @hidden */
  46900. private _internalMarkAllSubMeshesAsMiscDirty;
  46901. /** @hidden */
  46902. _markAllSubMeshesAsMiscDirty(): void;
  46903. /**
  46904. * Instantiate a new istance of clear coat configuration.
  46905. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46906. */
  46907. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46908. /**
  46909. * Checks to see if a texture is used in the material.
  46910. * @param defines the list of "defines" to update.
  46911. */
  46912. prepareDefines(defines: IMaterialBRDFDefines): void;
  46913. /**
  46914. * Get the current class name of the texture useful for serialization or dynamic coding.
  46915. * @returns "PBRClearCoatConfiguration"
  46916. */
  46917. getClassName(): string;
  46918. /**
  46919. * Makes a duplicate of the current configuration into another one.
  46920. * @param brdfConfiguration define the config where to copy the info
  46921. */
  46922. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46923. /**
  46924. * Serializes this BRDF configuration.
  46925. * @returns - An object with the serialized config.
  46926. */
  46927. serialize(): any;
  46928. /**
  46929. * Parses a anisotropy Configuration from a serialized object.
  46930. * @param source - Serialized object.
  46931. * @param scene Defines the scene we are parsing for
  46932. * @param rootUrl Defines the rootUrl to load from
  46933. */
  46934. parse(source: any, scene: Scene, rootUrl: string): void;
  46935. }
  46936. }
  46937. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46938. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46939. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46940. import { Color3 } from "babylonjs/Maths/math";
  46941. import { Scene } from "babylonjs/scene";
  46942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46943. import { IAnimatable } from "babylonjs/Misc/tools";
  46944. import { Nullable } from "babylonjs/types";
  46945. /**
  46946. * @hidden
  46947. */
  46948. export interface IMaterialSheenDefines {
  46949. SHEEN: boolean;
  46950. SHEEN_TEXTURE: boolean;
  46951. SHEEN_TEXTUREDIRECTUV: number;
  46952. SHEEN_LINKWITHALBEDO: boolean;
  46953. /** @hidden */
  46954. _areTexturesDirty: boolean;
  46955. }
  46956. /**
  46957. * Define the code related to the Sheen parameters of the pbr material.
  46958. */
  46959. export class PBRSheenConfiguration {
  46960. private _isEnabled;
  46961. /**
  46962. * Defines if the material uses sheen.
  46963. */
  46964. isEnabled: boolean;
  46965. private _linkSheenWithAlbedo;
  46966. /**
  46967. * Defines if the sheen is linked to the sheen color.
  46968. */
  46969. linkSheenWithAlbedo: boolean;
  46970. /**
  46971. * Defines the sheen intensity.
  46972. */
  46973. intensity: number;
  46974. /**
  46975. * Defines the sheen color.
  46976. */
  46977. color: Color3;
  46978. private _texture;
  46979. /**
  46980. * Stores the sheen tint values in a texture.
  46981. * rgb is tint
  46982. * a is a intensity
  46983. */
  46984. texture: Nullable<BaseTexture>;
  46985. /** @hidden */
  46986. private _internalMarkAllSubMeshesAsTexturesDirty;
  46987. /** @hidden */
  46988. _markAllSubMeshesAsTexturesDirty(): void;
  46989. /**
  46990. * Instantiate a new istance of clear coat configuration.
  46991. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46992. */
  46993. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46994. /**
  46995. * Specifies that the submesh is ready to be used.
  46996. * @param defines the list of "defines" to update.
  46997. * @param scene defines the scene the material belongs to.
  46998. * @returns - boolean indicating that the submesh is ready or not.
  46999. */
  47000. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47001. /**
  47002. * Checks to see if a texture is used in the material.
  47003. * @param defines the list of "defines" to update.
  47004. * @param scene defines the scene the material belongs to.
  47005. */
  47006. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47007. /**
  47008. * Binds the material data.
  47009. * @param uniformBuffer defines the Uniform buffer to fill in.
  47010. * @param scene defines the scene the material belongs to.
  47011. * @param isFrozen defines wether the material is frozen or not.
  47012. */
  47013. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47014. /**
  47015. * Checks to see if a texture is used in the material.
  47016. * @param texture - Base texture to use.
  47017. * @returns - Boolean specifying if a texture is used in the material.
  47018. */
  47019. hasTexture(texture: BaseTexture): boolean;
  47020. /**
  47021. * Returns an array of the actively used textures.
  47022. * @param activeTextures Array of BaseTextures
  47023. */
  47024. getActiveTextures(activeTextures: BaseTexture[]): void;
  47025. /**
  47026. * Returns the animatable textures.
  47027. * @param animatables Array of animatable textures.
  47028. */
  47029. getAnimatables(animatables: IAnimatable[]): void;
  47030. /**
  47031. * Disposes the resources of the material.
  47032. * @param forceDisposeTextures - Forces the disposal of all textures.
  47033. */
  47034. dispose(forceDisposeTextures?: boolean): void;
  47035. /**
  47036. * Get the current class name of the texture useful for serialization or dynamic coding.
  47037. * @returns "PBRSheenConfiguration"
  47038. */
  47039. getClassName(): string;
  47040. /**
  47041. * Add fallbacks to the effect fallbacks list.
  47042. * @param defines defines the Base texture to use.
  47043. * @param fallbacks defines the current fallback list.
  47044. * @param currentRank defines the current fallback rank.
  47045. * @returns the new fallback rank.
  47046. */
  47047. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47048. /**
  47049. * Add the required uniforms to the current list.
  47050. * @param uniforms defines the current uniform list.
  47051. */
  47052. static AddUniforms(uniforms: string[]): void;
  47053. /**
  47054. * Add the required uniforms to the current buffer.
  47055. * @param uniformBuffer defines the current uniform buffer.
  47056. */
  47057. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47058. /**
  47059. * Add the required samplers to the current list.
  47060. * @param samplers defines the current sampler list.
  47061. */
  47062. static AddSamplers(samplers: string[]): void;
  47063. /**
  47064. * Makes a duplicate of the current configuration into another one.
  47065. * @param sheenConfiguration define the config where to copy the info
  47066. */
  47067. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47068. /**
  47069. * Serializes this BRDF configuration.
  47070. * @returns - An object with the serialized config.
  47071. */
  47072. serialize(): any;
  47073. /**
  47074. * Parses a anisotropy Configuration from a serialized object.
  47075. * @param source - Serialized object.
  47076. * @param scene Defines the scene we are parsing for
  47077. * @param rootUrl Defines the rootUrl to load from
  47078. */
  47079. parse(source: any, scene: Scene, rootUrl: string): void;
  47080. }
  47081. }
  47082. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47083. import { Nullable } from "babylonjs/types";
  47084. import { IAnimatable } from "babylonjs/Misc/tools";
  47085. import { Color3 } from "babylonjs/Maths/math";
  47086. import { SmartArray } from "babylonjs/Misc/smartArray";
  47087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47088. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47089. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47090. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47091. import { Engine } from "babylonjs/Engines/engine";
  47092. import { Scene } from "babylonjs/scene";
  47093. /**
  47094. * @hidden
  47095. */
  47096. export interface IMaterialSubSurfaceDefines {
  47097. SUBSURFACE: boolean;
  47098. SS_REFRACTION: boolean;
  47099. SS_TRANSLUCENCY: boolean;
  47100. SS_SCATERRING: boolean;
  47101. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47102. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47103. SS_REFRACTIONMAP_3D: boolean;
  47104. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47105. SS_LODINREFRACTIONALPHA: boolean;
  47106. SS_GAMMAREFRACTION: boolean;
  47107. SS_RGBDREFRACTION: boolean;
  47108. SS_LINEARSPECULARREFRACTION: boolean;
  47109. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47110. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47111. /** @hidden */
  47112. _areTexturesDirty: boolean;
  47113. }
  47114. /**
  47115. * Define the code related to the sub surface parameters of the pbr material.
  47116. */
  47117. export class PBRSubSurfaceConfiguration {
  47118. private _isRefractionEnabled;
  47119. /**
  47120. * Defines if the refraction is enabled in the material.
  47121. */
  47122. isRefractionEnabled: boolean;
  47123. private _isTranslucencyEnabled;
  47124. /**
  47125. * Defines if the translucency is enabled in the material.
  47126. */
  47127. isTranslucencyEnabled: boolean;
  47128. private _isScatteringEnabled;
  47129. /**
  47130. * Defines the refraction intensity of the material.
  47131. * The refraction when enabled replaces the Diffuse part of the material.
  47132. * The intensity helps transitionning between diffuse and refraction.
  47133. */
  47134. refractionIntensity: number;
  47135. /**
  47136. * Defines the translucency intensity of the material.
  47137. * When translucency has been enabled, this defines how much of the "translucency"
  47138. * is addded to the diffuse part of the material.
  47139. */
  47140. translucencyIntensity: number;
  47141. /**
  47142. * Defines the scattering intensity of the material.
  47143. * When scattering has been enabled, this defines how much of the "scattered light"
  47144. * is addded to the diffuse part of the material.
  47145. */
  47146. scatteringIntensity: number;
  47147. private _thicknessTexture;
  47148. /**
  47149. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47150. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47151. * 0 would mean minimumThickness
  47152. * 1 would mean maximumThickness
  47153. * The other channels might be use as a mask to vary the different effects intensity.
  47154. */
  47155. thicknessTexture: Nullable<BaseTexture>;
  47156. private _refractionTexture;
  47157. /**
  47158. * Defines the texture to use for refraction.
  47159. */
  47160. refractionTexture: Nullable<BaseTexture>;
  47161. private _indexOfRefraction;
  47162. /**
  47163. * Defines the index of refraction used in the material.
  47164. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47165. */
  47166. indexOfRefraction: number;
  47167. private _invertRefractionY;
  47168. /**
  47169. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47170. */
  47171. invertRefractionY: boolean;
  47172. private _linkRefractionWithTransparency;
  47173. /**
  47174. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47175. * Materials half opaque for instance using refraction could benefit from this control.
  47176. */
  47177. linkRefractionWithTransparency: boolean;
  47178. /**
  47179. * Defines the minimum thickness stored in the thickness map.
  47180. * If no thickness map is defined, this value will be used to simulate thickness.
  47181. */
  47182. minimumThickness: number;
  47183. /**
  47184. * Defines the maximum thickness stored in the thickness map.
  47185. */
  47186. maximumThickness: number;
  47187. /**
  47188. * Defines the volume tint of the material.
  47189. * This is used for both translucency and scattering.
  47190. */
  47191. tintColor: Color3;
  47192. /**
  47193. * Defines the distance at which the tint color should be found in the media.
  47194. * This is used for refraction only.
  47195. */
  47196. tintColorAtDistance: number;
  47197. /**
  47198. * Defines how far each channel transmit through the media.
  47199. * It is defined as a color to simplify it selection.
  47200. */
  47201. diffusionDistance: Color3;
  47202. private _useMaskFromThicknessTexture;
  47203. /**
  47204. * Stores the intensity of the different subsurface effects in the thickness texture.
  47205. * * the green channel is the translucency intensity.
  47206. * * the blue channel is the scattering intensity.
  47207. * * the alpha channel is the refraction intensity.
  47208. */
  47209. useMaskFromThicknessTexture: boolean;
  47210. /** @hidden */
  47211. private _internalMarkAllSubMeshesAsTexturesDirty;
  47212. /** @hidden */
  47213. _markAllSubMeshesAsTexturesDirty(): void;
  47214. /**
  47215. * Instantiate a new istance of sub surface configuration.
  47216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47217. */
  47218. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47219. /**
  47220. * Gets wehter the submesh is ready to be used or not.
  47221. * @param defines the list of "defines" to update.
  47222. * @param scene defines the scene the material belongs to.
  47223. * @returns - boolean indicating that the submesh is ready or not.
  47224. */
  47225. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47226. /**
  47227. * Checks to see if a texture is used in the material.
  47228. * @param defines the list of "defines" to update.
  47229. * @param scene defines the scene to the material belongs to.
  47230. */
  47231. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47232. /**
  47233. * Binds the material data.
  47234. * @param uniformBuffer defines the Uniform buffer to fill in.
  47235. * @param scene defines the scene the material belongs to.
  47236. * @param engine defines the engine the material belongs to.
  47237. * @param isFrozen defines wether the material is frozen or not.
  47238. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47239. */
  47240. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47241. /**
  47242. * Unbinds the material from the mesh.
  47243. * @param activeEffect defines the effect that should be unbound from.
  47244. * @returns true if unbound, otherwise false
  47245. */
  47246. unbind(activeEffect: Effect): boolean;
  47247. /**
  47248. * Returns the texture used for refraction or null if none is used.
  47249. * @param scene defines the scene the material belongs to.
  47250. * @returns - Refraction texture if present. If no refraction texture and refraction
  47251. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47252. */
  47253. private _getRefractionTexture;
  47254. /**
  47255. * Returns true if alpha blending should be disabled.
  47256. */
  47257. readonly disableAlphaBlending: boolean;
  47258. /**
  47259. * Fills the list of render target textures.
  47260. * @param renderTargets the list of render targets to update
  47261. */
  47262. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47263. /**
  47264. * Checks to see if a texture is used in the material.
  47265. * @param texture - Base texture to use.
  47266. * @returns - Boolean specifying if a texture is used in the material.
  47267. */
  47268. hasTexture(texture: BaseTexture): boolean;
  47269. /**
  47270. * Gets a boolean indicating that current material needs to register RTT
  47271. * @returns true if this uses a render target otherwise false.
  47272. */
  47273. hasRenderTargetTextures(): boolean;
  47274. /**
  47275. * Returns an array of the actively used textures.
  47276. * @param activeTextures Array of BaseTextures
  47277. */
  47278. getActiveTextures(activeTextures: BaseTexture[]): void;
  47279. /**
  47280. * Returns the animatable textures.
  47281. * @param animatables Array of animatable textures.
  47282. */
  47283. getAnimatables(animatables: IAnimatable[]): void;
  47284. /**
  47285. * Disposes the resources of the material.
  47286. * @param forceDisposeTextures - Forces the disposal of all textures.
  47287. */
  47288. dispose(forceDisposeTextures?: boolean): void;
  47289. /**
  47290. * Get the current class name of the texture useful for serialization or dynamic coding.
  47291. * @returns "PBRSubSurfaceConfiguration"
  47292. */
  47293. getClassName(): string;
  47294. /**
  47295. * Add fallbacks to the effect fallbacks list.
  47296. * @param defines defines the Base texture to use.
  47297. * @param fallbacks defines the current fallback list.
  47298. * @param currentRank defines the current fallback rank.
  47299. * @returns the new fallback rank.
  47300. */
  47301. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47302. /**
  47303. * Add the required uniforms to the current list.
  47304. * @param uniforms defines the current uniform list.
  47305. */
  47306. static AddUniforms(uniforms: string[]): void;
  47307. /**
  47308. * Add the required samplers to the current list.
  47309. * @param samplers defines the current sampler list.
  47310. */
  47311. static AddSamplers(samplers: string[]): void;
  47312. /**
  47313. * Add the required uniforms to the current buffer.
  47314. * @param uniformBuffer defines the current uniform buffer.
  47315. */
  47316. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47317. /**
  47318. * Makes a duplicate of the current configuration into another one.
  47319. * @param configuration define the config where to copy the info
  47320. */
  47321. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47322. /**
  47323. * Serializes this Sub Surface configuration.
  47324. * @returns - An object with the serialized config.
  47325. */
  47326. serialize(): any;
  47327. /**
  47328. * Parses a anisotropy Configuration from a serialized object.
  47329. * @param source - Serialized object.
  47330. * @param scene Defines the scene we are parsing for
  47331. * @param rootUrl Defines the rootUrl to load from
  47332. */
  47333. parse(source: any, scene: Scene, rootUrl: string): void;
  47334. }
  47335. }
  47336. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47337. /** @hidden */
  47338. export var pbrFragmentDeclaration: {
  47339. name: string;
  47340. shader: string;
  47341. };
  47342. }
  47343. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47344. /** @hidden */
  47345. export var pbrUboDeclaration: {
  47346. name: string;
  47347. shader: string;
  47348. };
  47349. }
  47350. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47351. /** @hidden */
  47352. export var pbrFragmentExtraDeclaration: {
  47353. name: string;
  47354. shader: string;
  47355. };
  47356. }
  47357. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47358. /** @hidden */
  47359. export var pbrFragmentSamplersDeclaration: {
  47360. name: string;
  47361. shader: string;
  47362. };
  47363. }
  47364. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47365. /** @hidden */
  47366. export var pbrHelperFunctions: {
  47367. name: string;
  47368. shader: string;
  47369. };
  47370. }
  47371. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47372. /** @hidden */
  47373. export var harmonicsFunctions: {
  47374. name: string;
  47375. shader: string;
  47376. };
  47377. }
  47378. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47379. /** @hidden */
  47380. export var pbrDirectLightingSetupFunctions: {
  47381. name: string;
  47382. shader: string;
  47383. };
  47384. }
  47385. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47386. /** @hidden */
  47387. export var pbrDirectLightingFalloffFunctions: {
  47388. name: string;
  47389. shader: string;
  47390. };
  47391. }
  47392. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47393. /** @hidden */
  47394. export var pbrBRDFFunctions: {
  47395. name: string;
  47396. shader: string;
  47397. };
  47398. }
  47399. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47400. /** @hidden */
  47401. export var pbrDirectLightingFunctions: {
  47402. name: string;
  47403. shader: string;
  47404. };
  47405. }
  47406. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47407. /** @hidden */
  47408. export var pbrIBLFunctions: {
  47409. name: string;
  47410. shader: string;
  47411. };
  47412. }
  47413. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47414. /** @hidden */
  47415. export var pbrDebug: {
  47416. name: string;
  47417. shader: string;
  47418. };
  47419. }
  47420. declare module "babylonjs/Shaders/pbr.fragment" {
  47421. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47422. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47423. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47424. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47425. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47426. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47427. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47428. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47429. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47430. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47431. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47432. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47433. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47434. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47435. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47436. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47437. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47438. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47439. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47440. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47441. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47442. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47443. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47444. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47445. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47446. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47447. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47448. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47449. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47450. /** @hidden */
  47451. export var pbrPixelShader: {
  47452. name: string;
  47453. shader: string;
  47454. };
  47455. }
  47456. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47457. /** @hidden */
  47458. export var pbrVertexDeclaration: {
  47459. name: string;
  47460. shader: string;
  47461. };
  47462. }
  47463. declare module "babylonjs/Shaders/pbr.vertex" {
  47464. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47465. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47466. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47467. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47468. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47469. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47470. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47471. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47472. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47473. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47474. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47475. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47476. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47477. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47478. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47479. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47480. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47481. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47482. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47483. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47484. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47485. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47486. /** @hidden */
  47487. export var pbrVertexShader: {
  47488. name: string;
  47489. shader: string;
  47490. };
  47491. }
  47492. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47493. import { IAnimatable } from "babylonjs/Misc/tools";
  47494. import { Nullable } from "babylonjs/types";
  47495. import { Scene } from "babylonjs/scene";
  47496. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47497. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47499. import { Mesh } from "babylonjs/Meshes/mesh";
  47500. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47501. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47502. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47503. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47504. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47505. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47506. import { Material } from "babylonjs/Materials/material";
  47507. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47508. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47510. import "babylonjs/Shaders/pbr.fragment";
  47511. import "babylonjs/Shaders/pbr.vertex";
  47512. /**
  47513. * Manages the defines for the PBR Material.
  47514. * @hidden
  47515. */
  47516. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47517. PBR: boolean;
  47518. MAINUV1: boolean;
  47519. MAINUV2: boolean;
  47520. UV1: boolean;
  47521. UV2: boolean;
  47522. ALBEDO: boolean;
  47523. ALBEDODIRECTUV: number;
  47524. VERTEXCOLOR: boolean;
  47525. AMBIENT: boolean;
  47526. AMBIENTDIRECTUV: number;
  47527. AMBIENTINGRAYSCALE: boolean;
  47528. OPACITY: boolean;
  47529. VERTEXALPHA: boolean;
  47530. OPACITYDIRECTUV: number;
  47531. OPACITYRGB: boolean;
  47532. ALPHATEST: boolean;
  47533. DEPTHPREPASS: boolean;
  47534. ALPHABLEND: boolean;
  47535. ALPHAFROMALBEDO: boolean;
  47536. ALPHATESTVALUE: string;
  47537. SPECULAROVERALPHA: boolean;
  47538. RADIANCEOVERALPHA: boolean;
  47539. ALPHAFRESNEL: boolean;
  47540. LINEARALPHAFRESNEL: boolean;
  47541. PREMULTIPLYALPHA: boolean;
  47542. EMISSIVE: boolean;
  47543. EMISSIVEDIRECTUV: number;
  47544. REFLECTIVITY: boolean;
  47545. REFLECTIVITYDIRECTUV: number;
  47546. SPECULARTERM: boolean;
  47547. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47548. MICROSURFACEAUTOMATIC: boolean;
  47549. LODBASEDMICROSFURACE: boolean;
  47550. MICROSURFACEMAP: boolean;
  47551. MICROSURFACEMAPDIRECTUV: number;
  47552. METALLICWORKFLOW: boolean;
  47553. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47554. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47555. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47556. AOSTOREINMETALMAPRED: boolean;
  47557. ENVIRONMENTBRDF: boolean;
  47558. ENVIRONMENTBRDF_RGBD: boolean;
  47559. NORMAL: boolean;
  47560. TANGENT: boolean;
  47561. BUMP: boolean;
  47562. BUMPDIRECTUV: number;
  47563. OBJECTSPACE_NORMALMAP: boolean;
  47564. PARALLAX: boolean;
  47565. PARALLAXOCCLUSION: boolean;
  47566. NORMALXYSCALE: boolean;
  47567. LIGHTMAP: boolean;
  47568. LIGHTMAPDIRECTUV: number;
  47569. USELIGHTMAPASSHADOWMAP: boolean;
  47570. GAMMALIGHTMAP: boolean;
  47571. REFLECTION: boolean;
  47572. REFLECTIONMAP_3D: boolean;
  47573. REFLECTIONMAP_SPHERICAL: boolean;
  47574. REFLECTIONMAP_PLANAR: boolean;
  47575. REFLECTIONMAP_CUBIC: boolean;
  47576. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47577. REFLECTIONMAP_PROJECTION: boolean;
  47578. REFLECTIONMAP_SKYBOX: boolean;
  47579. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47580. REFLECTIONMAP_EXPLICIT: boolean;
  47581. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47582. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47583. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47584. INVERTCUBICMAP: boolean;
  47585. USESPHERICALFROMREFLECTIONMAP: boolean;
  47586. USEIRRADIANCEMAP: boolean;
  47587. SPHERICAL_HARMONICS: boolean;
  47588. USESPHERICALINVERTEX: boolean;
  47589. REFLECTIONMAP_OPPOSITEZ: boolean;
  47590. LODINREFLECTIONALPHA: boolean;
  47591. GAMMAREFLECTION: boolean;
  47592. RGBDREFLECTION: boolean;
  47593. LINEARSPECULARREFLECTION: boolean;
  47594. RADIANCEOCCLUSION: boolean;
  47595. HORIZONOCCLUSION: boolean;
  47596. INSTANCES: boolean;
  47597. NUM_BONE_INFLUENCERS: number;
  47598. BonesPerMesh: number;
  47599. BONETEXTURE: boolean;
  47600. NONUNIFORMSCALING: boolean;
  47601. MORPHTARGETS: boolean;
  47602. MORPHTARGETS_NORMAL: boolean;
  47603. MORPHTARGETS_TANGENT: boolean;
  47604. MORPHTARGETS_UV: boolean;
  47605. NUM_MORPH_INFLUENCERS: number;
  47606. IMAGEPROCESSING: boolean;
  47607. VIGNETTE: boolean;
  47608. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47609. VIGNETTEBLENDMODEOPAQUE: boolean;
  47610. TONEMAPPING: boolean;
  47611. TONEMAPPING_ACES: boolean;
  47612. CONTRAST: boolean;
  47613. COLORCURVES: boolean;
  47614. COLORGRADING: boolean;
  47615. COLORGRADING3D: boolean;
  47616. SAMPLER3DGREENDEPTH: boolean;
  47617. SAMPLER3DBGRMAP: boolean;
  47618. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47619. EXPOSURE: boolean;
  47620. MULTIVIEW: boolean;
  47621. USEPHYSICALLIGHTFALLOFF: boolean;
  47622. USEGLTFLIGHTFALLOFF: boolean;
  47623. TWOSIDEDLIGHTING: boolean;
  47624. SHADOWFLOAT: boolean;
  47625. CLIPPLANE: boolean;
  47626. CLIPPLANE2: boolean;
  47627. CLIPPLANE3: boolean;
  47628. CLIPPLANE4: boolean;
  47629. POINTSIZE: boolean;
  47630. FOG: boolean;
  47631. LOGARITHMICDEPTH: boolean;
  47632. FORCENORMALFORWARD: boolean;
  47633. SPECULARAA: boolean;
  47634. CLEARCOAT: boolean;
  47635. CLEARCOAT_DEFAULTIOR: boolean;
  47636. CLEARCOAT_TEXTURE: boolean;
  47637. CLEARCOAT_TEXTUREDIRECTUV: number;
  47638. CLEARCOAT_BUMP: boolean;
  47639. CLEARCOAT_BUMPDIRECTUV: number;
  47640. CLEARCOAT_TINT: boolean;
  47641. CLEARCOAT_TINT_TEXTURE: boolean;
  47642. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47643. ANISOTROPIC: boolean;
  47644. ANISOTROPIC_TEXTURE: boolean;
  47645. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47646. BRDF_V_HEIGHT_CORRELATED: boolean;
  47647. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47648. SHEEN: boolean;
  47649. SHEEN_TEXTURE: boolean;
  47650. SHEEN_TEXTUREDIRECTUV: number;
  47651. SHEEN_LINKWITHALBEDO: boolean;
  47652. SUBSURFACE: boolean;
  47653. SS_REFRACTION: boolean;
  47654. SS_TRANSLUCENCY: boolean;
  47655. SS_SCATERRING: boolean;
  47656. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47657. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47658. SS_REFRACTIONMAP_3D: boolean;
  47659. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47660. SS_LODINREFRACTIONALPHA: boolean;
  47661. SS_GAMMAREFRACTION: boolean;
  47662. SS_RGBDREFRACTION: boolean;
  47663. SS_LINEARSPECULARREFRACTION: boolean;
  47664. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47665. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47666. UNLIT: boolean;
  47667. DEBUGMODE: number;
  47668. /**
  47669. * Initializes the PBR Material defines.
  47670. */
  47671. constructor();
  47672. /**
  47673. * Resets the PBR Material defines.
  47674. */
  47675. reset(): void;
  47676. }
  47677. /**
  47678. * The Physically based material base class of BJS.
  47679. *
  47680. * This offers the main features of a standard PBR material.
  47681. * For more information, please refer to the documentation :
  47682. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47683. */
  47684. export abstract class PBRBaseMaterial extends PushMaterial {
  47685. /**
  47686. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47687. */
  47688. static readonly PBRMATERIAL_OPAQUE: number;
  47689. /**
  47690. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47691. */
  47692. static readonly PBRMATERIAL_ALPHATEST: number;
  47693. /**
  47694. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47695. */
  47696. static readonly PBRMATERIAL_ALPHABLEND: number;
  47697. /**
  47698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47699. * They are also discarded below the alpha cutoff threshold to improve performances.
  47700. */
  47701. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47702. /**
  47703. * Defines the default value of how much AO map is occluding the analytical lights
  47704. * (point spot...).
  47705. */
  47706. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47707. /**
  47708. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47709. */
  47710. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47711. /**
  47712. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47713. * to enhance interoperability with other engines.
  47714. */
  47715. static readonly LIGHTFALLOFF_GLTF: number;
  47716. /**
  47717. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47718. * to enhance interoperability with other materials.
  47719. */
  47720. static readonly LIGHTFALLOFF_STANDARD: number;
  47721. /**
  47722. * Intensity of the direct lights e.g. the four lights available in your scene.
  47723. * This impacts both the direct diffuse and specular highlights.
  47724. */
  47725. protected _directIntensity: number;
  47726. /**
  47727. * Intensity of the emissive part of the material.
  47728. * This helps controlling the emissive effect without modifying the emissive color.
  47729. */
  47730. protected _emissiveIntensity: number;
  47731. /**
  47732. * Intensity of the environment e.g. how much the environment will light the object
  47733. * either through harmonics for rough material or through the refelction for shiny ones.
  47734. */
  47735. protected _environmentIntensity: number;
  47736. /**
  47737. * This is a special control allowing the reduction of the specular highlights coming from the
  47738. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47739. */
  47740. protected _specularIntensity: number;
  47741. /**
  47742. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47743. */
  47744. private _lightingInfos;
  47745. /**
  47746. * Debug Control allowing disabling the bump map on this material.
  47747. */
  47748. protected _disableBumpMap: boolean;
  47749. /**
  47750. * AKA Diffuse Texture in standard nomenclature.
  47751. */
  47752. protected _albedoTexture: Nullable<BaseTexture>;
  47753. /**
  47754. * AKA Occlusion Texture in other nomenclature.
  47755. */
  47756. protected _ambientTexture: Nullable<BaseTexture>;
  47757. /**
  47758. * AKA Occlusion Texture Intensity in other nomenclature.
  47759. */
  47760. protected _ambientTextureStrength: number;
  47761. /**
  47762. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47763. * 1 means it completely occludes it
  47764. * 0 mean it has no impact
  47765. */
  47766. protected _ambientTextureImpactOnAnalyticalLights: number;
  47767. /**
  47768. * Stores the alpha values in a texture.
  47769. */
  47770. protected _opacityTexture: Nullable<BaseTexture>;
  47771. /**
  47772. * Stores the reflection values in a texture.
  47773. */
  47774. protected _reflectionTexture: Nullable<BaseTexture>;
  47775. /**
  47776. * Stores the emissive values in a texture.
  47777. */
  47778. protected _emissiveTexture: Nullable<BaseTexture>;
  47779. /**
  47780. * AKA Specular texture in other nomenclature.
  47781. */
  47782. protected _reflectivityTexture: Nullable<BaseTexture>;
  47783. /**
  47784. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47785. */
  47786. protected _metallicTexture: Nullable<BaseTexture>;
  47787. /**
  47788. * Specifies the metallic scalar of the metallic/roughness workflow.
  47789. * Can also be used to scale the metalness values of the metallic texture.
  47790. */
  47791. protected _metallic: Nullable<number>;
  47792. /**
  47793. * Specifies the roughness scalar of the metallic/roughness workflow.
  47794. * Can also be used to scale the roughness values of the metallic texture.
  47795. */
  47796. protected _roughness: Nullable<number>;
  47797. /**
  47798. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47799. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47800. */
  47801. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47802. /**
  47803. * Stores surface normal data used to displace a mesh in a texture.
  47804. */
  47805. protected _bumpTexture: Nullable<BaseTexture>;
  47806. /**
  47807. * Stores the pre-calculated light information of a mesh in a texture.
  47808. */
  47809. protected _lightmapTexture: Nullable<BaseTexture>;
  47810. /**
  47811. * The color of a material in ambient lighting.
  47812. */
  47813. protected _ambientColor: Color3;
  47814. /**
  47815. * AKA Diffuse Color in other nomenclature.
  47816. */
  47817. protected _albedoColor: Color3;
  47818. /**
  47819. * AKA Specular Color in other nomenclature.
  47820. */
  47821. protected _reflectivityColor: Color3;
  47822. /**
  47823. * The color applied when light is reflected from a material.
  47824. */
  47825. protected _reflectionColor: Color3;
  47826. /**
  47827. * The color applied when light is emitted from a material.
  47828. */
  47829. protected _emissiveColor: Color3;
  47830. /**
  47831. * AKA Glossiness in other nomenclature.
  47832. */
  47833. protected _microSurface: number;
  47834. /**
  47835. * Specifies that the material will use the light map as a show map.
  47836. */
  47837. protected _useLightmapAsShadowmap: boolean;
  47838. /**
  47839. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47840. * makes the reflect vector face the model (under horizon).
  47841. */
  47842. protected _useHorizonOcclusion: boolean;
  47843. /**
  47844. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47845. * too much the area relying on ambient texture to define their ambient occlusion.
  47846. */
  47847. protected _useRadianceOcclusion: boolean;
  47848. /**
  47849. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47850. */
  47851. protected _useAlphaFromAlbedoTexture: boolean;
  47852. /**
  47853. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47854. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47855. */
  47856. protected _useSpecularOverAlpha: boolean;
  47857. /**
  47858. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47859. */
  47860. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47861. /**
  47862. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47863. */
  47864. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47865. /**
  47866. * Specifies if the metallic texture contains the roughness information in its green channel.
  47867. */
  47868. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47869. /**
  47870. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47871. */
  47872. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47873. /**
  47874. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47875. */
  47876. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47877. /**
  47878. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47879. */
  47880. protected _useAmbientInGrayScale: boolean;
  47881. /**
  47882. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47883. * The material will try to infer what glossiness each pixel should be.
  47884. */
  47885. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47886. /**
  47887. * Defines the falloff type used in this material.
  47888. * It by default is Physical.
  47889. */
  47890. protected _lightFalloff: number;
  47891. /**
  47892. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47893. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47894. */
  47895. protected _useRadianceOverAlpha: boolean;
  47896. /**
  47897. * Allows using an object space normal map (instead of tangent space).
  47898. */
  47899. protected _useObjectSpaceNormalMap: boolean;
  47900. /**
  47901. * Allows using the bump map in parallax mode.
  47902. */
  47903. protected _useParallax: boolean;
  47904. /**
  47905. * Allows using the bump map in parallax occlusion mode.
  47906. */
  47907. protected _useParallaxOcclusion: boolean;
  47908. /**
  47909. * Controls the scale bias of the parallax mode.
  47910. */
  47911. protected _parallaxScaleBias: number;
  47912. /**
  47913. * If sets to true, disables all the lights affecting the material.
  47914. */
  47915. protected _disableLighting: boolean;
  47916. /**
  47917. * Number of Simultaneous lights allowed on the material.
  47918. */
  47919. protected _maxSimultaneousLights: number;
  47920. /**
  47921. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47922. */
  47923. protected _invertNormalMapX: boolean;
  47924. /**
  47925. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47926. */
  47927. protected _invertNormalMapY: boolean;
  47928. /**
  47929. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47930. */
  47931. protected _twoSidedLighting: boolean;
  47932. /**
  47933. * Defines the alpha limits in alpha test mode.
  47934. */
  47935. protected _alphaCutOff: number;
  47936. /**
  47937. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47938. */
  47939. protected _forceAlphaTest: boolean;
  47940. /**
  47941. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47942. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47943. */
  47944. protected _useAlphaFresnel: boolean;
  47945. /**
  47946. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47947. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47948. */
  47949. protected _useLinearAlphaFresnel: boolean;
  47950. /**
  47951. * The transparency mode of the material.
  47952. */
  47953. protected _transparencyMode: Nullable<number>;
  47954. /**
  47955. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47956. * from cos thetav and roughness:
  47957. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47958. */
  47959. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47960. /**
  47961. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47962. */
  47963. protected _forceIrradianceInFragment: boolean;
  47964. /**
  47965. * Force normal to face away from face.
  47966. */
  47967. protected _forceNormalForward: boolean;
  47968. /**
  47969. * Enables specular anti aliasing in the PBR shader.
  47970. * It will both interacts on the Geometry for analytical and IBL lighting.
  47971. * It also prefilter the roughness map based on the bump values.
  47972. */
  47973. protected _enableSpecularAntiAliasing: boolean;
  47974. /**
  47975. * Default configuration related to image processing available in the PBR Material.
  47976. */
  47977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47978. /**
  47979. * Keep track of the image processing observer to allow dispose and replace.
  47980. */
  47981. private _imageProcessingObserver;
  47982. /**
  47983. * Attaches a new image processing configuration to the PBR Material.
  47984. * @param configuration
  47985. */
  47986. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47987. /**
  47988. * Stores the available render targets.
  47989. */
  47990. private _renderTargets;
  47991. /**
  47992. * Sets the global ambient color for the material used in lighting calculations.
  47993. */
  47994. private _globalAmbientColor;
  47995. /**
  47996. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47997. */
  47998. private _useLogarithmicDepth;
  47999. /**
  48000. * If set to true, no lighting calculations will be applied.
  48001. */
  48002. private _unlit;
  48003. private _debugMode;
  48004. /**
  48005. * @hidden
  48006. * This is reserved for the inspector.
  48007. * Defines the material debug mode.
  48008. * It helps seeing only some components of the material while troubleshooting.
  48009. */
  48010. debugMode: number;
  48011. /**
  48012. * @hidden
  48013. * This is reserved for the inspector.
  48014. * Specify from where on screen the debug mode should start.
  48015. * The value goes from -1 (full screen) to 1 (not visible)
  48016. * It helps with side by side comparison against the final render
  48017. * This defaults to -1
  48018. */
  48019. private debugLimit;
  48020. /**
  48021. * @hidden
  48022. * This is reserved for the inspector.
  48023. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48024. * You can use the factor to better multiply the final value.
  48025. */
  48026. private debugFactor;
  48027. /**
  48028. * Defines the clear coat layer parameters for the material.
  48029. */
  48030. readonly clearCoat: PBRClearCoatConfiguration;
  48031. /**
  48032. * Defines the anisotropic parameters for the material.
  48033. */
  48034. readonly anisotropy: PBRAnisotropicConfiguration;
  48035. /**
  48036. * Defines the BRDF parameters for the material.
  48037. */
  48038. readonly brdf: PBRBRDFConfiguration;
  48039. /**
  48040. * Defines the Sheen parameters for the material.
  48041. */
  48042. readonly sheen: PBRSheenConfiguration;
  48043. /**
  48044. * Defines the SubSurface parameters for the material.
  48045. */
  48046. readonly subSurface: PBRSubSurfaceConfiguration;
  48047. /**
  48048. * Custom callback helping to override the default shader used in the material.
  48049. */
  48050. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48051. /**
  48052. * Instantiates a new PBRMaterial instance.
  48053. *
  48054. * @param name The material name
  48055. * @param scene The scene the material will be use in.
  48056. */
  48057. constructor(name: string, scene: Scene);
  48058. /**
  48059. * Gets a boolean indicating that current material needs to register RTT
  48060. */
  48061. readonly hasRenderTargetTextures: boolean;
  48062. /**
  48063. * Gets the name of the material class.
  48064. */
  48065. getClassName(): string;
  48066. /**
  48067. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48068. */
  48069. /**
  48070. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48071. */
  48072. useLogarithmicDepth: boolean;
  48073. /**
  48074. * Gets the current transparency mode.
  48075. */
  48076. /**
  48077. * Sets the transparency mode of the material.
  48078. *
  48079. * | Value | Type | Description |
  48080. * | ----- | ----------------------------------- | ----------- |
  48081. * | 0 | OPAQUE | |
  48082. * | 1 | ALPHATEST | |
  48083. * | 2 | ALPHABLEND | |
  48084. * | 3 | ALPHATESTANDBLEND | |
  48085. *
  48086. */
  48087. transparencyMode: Nullable<number>;
  48088. /**
  48089. * Returns true if alpha blending should be disabled.
  48090. */
  48091. private readonly _disableAlphaBlending;
  48092. /**
  48093. * Specifies whether or not this material should be rendered in alpha blend mode.
  48094. */
  48095. needAlphaBlending(): boolean;
  48096. /**
  48097. * Specifies if the mesh will require alpha blending.
  48098. * @param mesh - BJS mesh.
  48099. */
  48100. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48101. /**
  48102. * Specifies whether or not this material should be rendered in alpha test mode.
  48103. */
  48104. needAlphaTesting(): boolean;
  48105. /**
  48106. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48107. */
  48108. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48109. /**
  48110. * Gets the texture used for the alpha test.
  48111. */
  48112. getAlphaTestTexture(): Nullable<BaseTexture>;
  48113. /**
  48114. * Specifies that the submesh is ready to be used.
  48115. * @param mesh - BJS mesh.
  48116. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48117. * @param useInstances - Specifies that instances should be used.
  48118. * @returns - boolean indicating that the submesh is ready or not.
  48119. */
  48120. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48121. /**
  48122. * Specifies if the material uses metallic roughness workflow.
  48123. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48124. */
  48125. isMetallicWorkflow(): boolean;
  48126. private _prepareEffect;
  48127. private _prepareDefines;
  48128. /**
  48129. * Force shader compilation
  48130. */
  48131. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48132. clipPlane: boolean;
  48133. }>): void;
  48134. /**
  48135. * Initializes the uniform buffer layout for the shader.
  48136. */
  48137. buildUniformLayout(): void;
  48138. /**
  48139. * Unbinds the material from the mesh
  48140. */
  48141. unbind(): void;
  48142. /**
  48143. * Binds the submesh data.
  48144. * @param world - The world matrix.
  48145. * @param mesh - The BJS mesh.
  48146. * @param subMesh - A submesh of the BJS mesh.
  48147. */
  48148. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48149. /**
  48150. * Returns the animatable textures.
  48151. * @returns - Array of animatable textures.
  48152. */
  48153. getAnimatables(): IAnimatable[];
  48154. /**
  48155. * Returns the texture used for reflections.
  48156. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48157. */
  48158. private _getReflectionTexture;
  48159. /**
  48160. * Returns an array of the actively used textures.
  48161. * @returns - Array of BaseTextures
  48162. */
  48163. getActiveTextures(): BaseTexture[];
  48164. /**
  48165. * Checks to see if a texture is used in the material.
  48166. * @param texture - Base texture to use.
  48167. * @returns - Boolean specifying if a texture is used in the material.
  48168. */
  48169. hasTexture(texture: BaseTexture): boolean;
  48170. /**
  48171. * Disposes the resources of the material.
  48172. * @param forceDisposeEffect - Forces the disposal of effects.
  48173. * @param forceDisposeTextures - Forces the disposal of all textures.
  48174. */
  48175. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48176. }
  48177. }
  48178. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48179. import { Nullable } from "babylonjs/types";
  48180. import { Scene } from "babylonjs/scene";
  48181. import { Color3 } from "babylonjs/Maths/math";
  48182. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48183. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48185. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48186. /**
  48187. * The Physically based material of BJS.
  48188. *
  48189. * This offers the main features of a standard PBR material.
  48190. * For more information, please refer to the documentation :
  48191. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48192. */
  48193. export class PBRMaterial extends PBRBaseMaterial {
  48194. /**
  48195. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48196. */
  48197. static readonly PBRMATERIAL_OPAQUE: number;
  48198. /**
  48199. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48200. */
  48201. static readonly PBRMATERIAL_ALPHATEST: number;
  48202. /**
  48203. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48204. */
  48205. static readonly PBRMATERIAL_ALPHABLEND: number;
  48206. /**
  48207. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48208. * They are also discarded below the alpha cutoff threshold to improve performances.
  48209. */
  48210. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48211. /**
  48212. * Defines the default value of how much AO map is occluding the analytical lights
  48213. * (point spot...).
  48214. */
  48215. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48216. /**
  48217. * Intensity of the direct lights e.g. the four lights available in your scene.
  48218. * This impacts both the direct diffuse and specular highlights.
  48219. */
  48220. directIntensity: number;
  48221. /**
  48222. * Intensity of the emissive part of the material.
  48223. * This helps controlling the emissive effect without modifying the emissive color.
  48224. */
  48225. emissiveIntensity: number;
  48226. /**
  48227. * Intensity of the environment e.g. how much the environment will light the object
  48228. * either through harmonics for rough material or through the refelction for shiny ones.
  48229. */
  48230. environmentIntensity: number;
  48231. /**
  48232. * This is a special control allowing the reduction of the specular highlights coming from the
  48233. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48234. */
  48235. specularIntensity: number;
  48236. /**
  48237. * Debug Control allowing disabling the bump map on this material.
  48238. */
  48239. disableBumpMap: boolean;
  48240. /**
  48241. * AKA Diffuse Texture in standard nomenclature.
  48242. */
  48243. albedoTexture: BaseTexture;
  48244. /**
  48245. * AKA Occlusion Texture in other nomenclature.
  48246. */
  48247. ambientTexture: BaseTexture;
  48248. /**
  48249. * AKA Occlusion Texture Intensity in other nomenclature.
  48250. */
  48251. ambientTextureStrength: number;
  48252. /**
  48253. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48254. * 1 means it completely occludes it
  48255. * 0 mean it has no impact
  48256. */
  48257. ambientTextureImpactOnAnalyticalLights: number;
  48258. /**
  48259. * Stores the alpha values in a texture.
  48260. */
  48261. opacityTexture: BaseTexture;
  48262. /**
  48263. * Stores the reflection values in a texture.
  48264. */
  48265. reflectionTexture: Nullable<BaseTexture>;
  48266. /**
  48267. * Stores the emissive values in a texture.
  48268. */
  48269. emissiveTexture: BaseTexture;
  48270. /**
  48271. * AKA Specular texture in other nomenclature.
  48272. */
  48273. reflectivityTexture: BaseTexture;
  48274. /**
  48275. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48276. */
  48277. metallicTexture: BaseTexture;
  48278. /**
  48279. * Specifies the metallic scalar of the metallic/roughness workflow.
  48280. * Can also be used to scale the metalness values of the metallic texture.
  48281. */
  48282. metallic: Nullable<number>;
  48283. /**
  48284. * Specifies the roughness scalar of the metallic/roughness workflow.
  48285. * Can also be used to scale the roughness values of the metallic texture.
  48286. */
  48287. roughness: Nullable<number>;
  48288. /**
  48289. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48290. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48291. */
  48292. microSurfaceTexture: BaseTexture;
  48293. /**
  48294. * Stores surface normal data used to displace a mesh in a texture.
  48295. */
  48296. bumpTexture: BaseTexture;
  48297. /**
  48298. * Stores the pre-calculated light information of a mesh in a texture.
  48299. */
  48300. lightmapTexture: BaseTexture;
  48301. /**
  48302. * Stores the refracted light information in a texture.
  48303. */
  48304. refractionTexture: Nullable<BaseTexture>;
  48305. /**
  48306. * The color of a material in ambient lighting.
  48307. */
  48308. ambientColor: Color3;
  48309. /**
  48310. * AKA Diffuse Color in other nomenclature.
  48311. */
  48312. albedoColor: Color3;
  48313. /**
  48314. * AKA Specular Color in other nomenclature.
  48315. */
  48316. reflectivityColor: Color3;
  48317. /**
  48318. * The color reflected from the material.
  48319. */
  48320. reflectionColor: Color3;
  48321. /**
  48322. * The color emitted from the material.
  48323. */
  48324. emissiveColor: Color3;
  48325. /**
  48326. * AKA Glossiness in other nomenclature.
  48327. */
  48328. microSurface: number;
  48329. /**
  48330. * source material index of refraction (IOR)' / 'destination material IOR.
  48331. */
  48332. indexOfRefraction: number;
  48333. /**
  48334. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48335. */
  48336. invertRefractionY: boolean;
  48337. /**
  48338. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48339. * Materials half opaque for instance using refraction could benefit from this control.
  48340. */
  48341. linkRefractionWithTransparency: boolean;
  48342. /**
  48343. * If true, the light map contains occlusion information instead of lighting info.
  48344. */
  48345. useLightmapAsShadowmap: boolean;
  48346. /**
  48347. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48348. */
  48349. useAlphaFromAlbedoTexture: boolean;
  48350. /**
  48351. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48352. */
  48353. forceAlphaTest: boolean;
  48354. /**
  48355. * Defines the alpha limits in alpha test mode.
  48356. */
  48357. alphaCutOff: number;
  48358. /**
  48359. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48360. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48361. */
  48362. useSpecularOverAlpha: boolean;
  48363. /**
  48364. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48365. */
  48366. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48367. /**
  48368. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48369. */
  48370. useRoughnessFromMetallicTextureAlpha: boolean;
  48371. /**
  48372. * Specifies if the metallic texture contains the roughness information in its green channel.
  48373. */
  48374. useRoughnessFromMetallicTextureGreen: boolean;
  48375. /**
  48376. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48377. */
  48378. useMetallnessFromMetallicTextureBlue: boolean;
  48379. /**
  48380. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48381. */
  48382. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48383. /**
  48384. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48385. */
  48386. useAmbientInGrayScale: boolean;
  48387. /**
  48388. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48389. * The material will try to infer what glossiness each pixel should be.
  48390. */
  48391. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48392. /**
  48393. * BJS is using an harcoded light falloff based on a manually sets up range.
  48394. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48395. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48396. */
  48397. /**
  48398. * BJS is using an harcoded light falloff based on a manually sets up range.
  48399. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48400. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48401. */
  48402. usePhysicalLightFalloff: boolean;
  48403. /**
  48404. * In order to support the falloff compatibility with gltf, a special mode has been added
  48405. * to reproduce the gltf light falloff.
  48406. */
  48407. /**
  48408. * In order to support the falloff compatibility with gltf, a special mode has been added
  48409. * to reproduce the gltf light falloff.
  48410. */
  48411. useGLTFLightFalloff: boolean;
  48412. /**
  48413. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48414. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48415. */
  48416. useRadianceOverAlpha: boolean;
  48417. /**
  48418. * Allows using an object space normal map (instead of tangent space).
  48419. */
  48420. useObjectSpaceNormalMap: boolean;
  48421. /**
  48422. * Allows using the bump map in parallax mode.
  48423. */
  48424. useParallax: boolean;
  48425. /**
  48426. * Allows using the bump map in parallax occlusion mode.
  48427. */
  48428. useParallaxOcclusion: boolean;
  48429. /**
  48430. * Controls the scale bias of the parallax mode.
  48431. */
  48432. parallaxScaleBias: number;
  48433. /**
  48434. * If sets to true, disables all the lights affecting the material.
  48435. */
  48436. disableLighting: boolean;
  48437. /**
  48438. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48439. */
  48440. forceIrradianceInFragment: boolean;
  48441. /**
  48442. * Number of Simultaneous lights allowed on the material.
  48443. */
  48444. maxSimultaneousLights: number;
  48445. /**
  48446. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48447. */
  48448. invertNormalMapX: boolean;
  48449. /**
  48450. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48451. */
  48452. invertNormalMapY: boolean;
  48453. /**
  48454. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48455. */
  48456. twoSidedLighting: boolean;
  48457. /**
  48458. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48459. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48460. */
  48461. useAlphaFresnel: boolean;
  48462. /**
  48463. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48464. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48465. */
  48466. useLinearAlphaFresnel: boolean;
  48467. /**
  48468. * Let user defines the brdf lookup texture used for IBL.
  48469. * A default 8bit version is embedded but you could point at :
  48470. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48471. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48472. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48473. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48474. */
  48475. environmentBRDFTexture: Nullable<BaseTexture>;
  48476. /**
  48477. * Force normal to face away from face.
  48478. */
  48479. forceNormalForward: boolean;
  48480. /**
  48481. * Enables specular anti aliasing in the PBR shader.
  48482. * It will both interacts on the Geometry for analytical and IBL lighting.
  48483. * It also prefilter the roughness map based on the bump values.
  48484. */
  48485. enableSpecularAntiAliasing: boolean;
  48486. /**
  48487. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48488. * makes the reflect vector face the model (under horizon).
  48489. */
  48490. useHorizonOcclusion: boolean;
  48491. /**
  48492. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48493. * too much the area relying on ambient texture to define their ambient occlusion.
  48494. */
  48495. useRadianceOcclusion: boolean;
  48496. /**
  48497. * If set to true, no lighting calculations will be applied.
  48498. */
  48499. unlit: boolean;
  48500. /**
  48501. * Gets the image processing configuration used either in this material.
  48502. */
  48503. /**
  48504. * Sets the Default image processing configuration used either in the this material.
  48505. *
  48506. * If sets to null, the scene one is in use.
  48507. */
  48508. imageProcessingConfiguration: ImageProcessingConfiguration;
  48509. /**
  48510. * Gets wether the color curves effect is enabled.
  48511. */
  48512. /**
  48513. * Sets wether the color curves effect is enabled.
  48514. */
  48515. cameraColorCurvesEnabled: boolean;
  48516. /**
  48517. * Gets wether the color grading effect is enabled.
  48518. */
  48519. /**
  48520. * Gets wether the color grading effect is enabled.
  48521. */
  48522. cameraColorGradingEnabled: boolean;
  48523. /**
  48524. * Gets wether tonemapping is enabled or not.
  48525. */
  48526. /**
  48527. * Sets wether tonemapping is enabled or not
  48528. */
  48529. cameraToneMappingEnabled: boolean;
  48530. /**
  48531. * The camera exposure used on this material.
  48532. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48533. * This corresponds to a photographic exposure.
  48534. */
  48535. /**
  48536. * The camera exposure used on this material.
  48537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48538. * This corresponds to a photographic exposure.
  48539. */
  48540. cameraExposure: number;
  48541. /**
  48542. * Gets The camera contrast used on this material.
  48543. */
  48544. /**
  48545. * Sets The camera contrast used on this material.
  48546. */
  48547. cameraContrast: number;
  48548. /**
  48549. * Gets the Color Grading 2D Lookup Texture.
  48550. */
  48551. /**
  48552. * Sets the Color Grading 2D Lookup Texture.
  48553. */
  48554. cameraColorGradingTexture: Nullable<BaseTexture>;
  48555. /**
  48556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48558. * 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;
  48559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48560. */
  48561. /**
  48562. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48563. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48564. * 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;
  48565. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48566. */
  48567. cameraColorCurves: Nullable<ColorCurves>;
  48568. /**
  48569. * Instantiates a new PBRMaterial instance.
  48570. *
  48571. * @param name The material name
  48572. * @param scene The scene the material will be use in.
  48573. */
  48574. constructor(name: string, scene: Scene);
  48575. /**
  48576. * Returns the name of this material class.
  48577. */
  48578. getClassName(): string;
  48579. /**
  48580. * Makes a duplicate of the current material.
  48581. * @param name - name to use for the new material.
  48582. */
  48583. clone(name: string): PBRMaterial;
  48584. /**
  48585. * Serializes this PBR Material.
  48586. * @returns - An object with the serialized material.
  48587. */
  48588. serialize(): any;
  48589. /**
  48590. * Parses a PBR Material from a serialized object.
  48591. * @param source - Serialized object.
  48592. * @param scene - BJS scene instance.
  48593. * @param rootUrl - url for the scene object
  48594. * @returns - PBRMaterial
  48595. */
  48596. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48597. }
  48598. }
  48599. declare module "babylonjs/Misc/dds" {
  48600. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48601. import { Engine } from "babylonjs/Engines/engine";
  48602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48603. import { Nullable } from "babylonjs/types";
  48604. import { Scene } from "babylonjs/scene";
  48605. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48606. /**
  48607. * Direct draw surface info
  48608. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48609. */
  48610. export interface DDSInfo {
  48611. /**
  48612. * Width of the texture
  48613. */
  48614. width: number;
  48615. /**
  48616. * Width of the texture
  48617. */
  48618. height: number;
  48619. /**
  48620. * Number of Mipmaps for the texture
  48621. * @see https://en.wikipedia.org/wiki/Mipmap
  48622. */
  48623. mipmapCount: number;
  48624. /**
  48625. * If the textures format is a known fourCC format
  48626. * @see https://www.fourcc.org/
  48627. */
  48628. isFourCC: boolean;
  48629. /**
  48630. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48631. */
  48632. isRGB: boolean;
  48633. /**
  48634. * If the texture is a lumincance format
  48635. */
  48636. isLuminance: boolean;
  48637. /**
  48638. * If this is a cube texture
  48639. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48640. */
  48641. isCube: boolean;
  48642. /**
  48643. * If the texture is a compressed format eg. FOURCC_DXT1
  48644. */
  48645. isCompressed: boolean;
  48646. /**
  48647. * The dxgiFormat of the texture
  48648. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48649. */
  48650. dxgiFormat: number;
  48651. /**
  48652. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48653. */
  48654. textureType: number;
  48655. /**
  48656. * Sphericle polynomial created for the dds texture
  48657. */
  48658. sphericalPolynomial?: SphericalPolynomial;
  48659. }
  48660. /**
  48661. * Class used to provide DDS decompression tools
  48662. */
  48663. export class DDSTools {
  48664. /**
  48665. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48666. */
  48667. static StoreLODInAlphaChannel: boolean;
  48668. /**
  48669. * Gets DDS information from an array buffer
  48670. * @param arrayBuffer defines the array buffer to read data from
  48671. * @returns the DDS information
  48672. */
  48673. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48674. private static _FloatView;
  48675. private static _Int32View;
  48676. private static _ToHalfFloat;
  48677. private static _FromHalfFloat;
  48678. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48679. private static _GetHalfFloatRGBAArrayBuffer;
  48680. private static _GetFloatRGBAArrayBuffer;
  48681. private static _GetFloatAsUIntRGBAArrayBuffer;
  48682. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48683. private static _GetRGBAArrayBuffer;
  48684. private static _ExtractLongWordOrder;
  48685. private static _GetRGBArrayBuffer;
  48686. private static _GetLuminanceArrayBuffer;
  48687. /**
  48688. * Uploads DDS Levels to a Babylon Texture
  48689. * @hidden
  48690. */
  48691. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48692. }
  48693. module "babylonjs/Engines/engine" {
  48694. interface Engine {
  48695. /**
  48696. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48697. * @param rootUrl defines the url where the file to load is located
  48698. * @param scene defines the current scene
  48699. * @param lodScale defines scale to apply to the mip map selection
  48700. * @param lodOffset defines offset to apply to the mip map selection
  48701. * @param onLoad defines an optional callback raised when the texture is loaded
  48702. * @param onError defines an optional callback raised if there is an issue to load the texture
  48703. * @param format defines the format of the data
  48704. * @param forcedExtension defines the extension to use to pick the right loader
  48705. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48706. * @returns the cube texture as an InternalTexture
  48707. */
  48708. 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;
  48709. }
  48710. }
  48711. }
  48712. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48713. import { Nullable } from "babylonjs/types";
  48714. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48715. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48716. /**
  48717. * Implementation of the DDS Texture Loader.
  48718. * @hidden
  48719. */
  48720. export class _DDSTextureLoader implements IInternalTextureLoader {
  48721. /**
  48722. * Defines wether the loader supports cascade loading the different faces.
  48723. */
  48724. readonly supportCascades: boolean;
  48725. /**
  48726. * This returns if the loader support the current file information.
  48727. * @param extension defines the file extension of the file being loaded
  48728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48729. * @param fallback defines the fallback internal texture if any
  48730. * @param isBase64 defines whether the texture is encoded as a base64
  48731. * @param isBuffer defines whether the texture data are stored as a buffer
  48732. * @returns true if the loader can load the specified file
  48733. */
  48734. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48735. /**
  48736. * Transform the url before loading if required.
  48737. * @param rootUrl the url of the texture
  48738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48739. * @returns the transformed texture
  48740. */
  48741. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48742. /**
  48743. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48744. * @param rootUrl the url of the texture
  48745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48746. * @returns the fallback texture
  48747. */
  48748. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48749. /**
  48750. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48751. * @param data contains the texture data
  48752. * @param texture defines the BabylonJS internal texture
  48753. * @param createPolynomials will be true if polynomials have been requested
  48754. * @param onLoad defines the callback to trigger once the texture is ready
  48755. * @param onError defines the callback to trigger in case of error
  48756. */
  48757. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48758. /**
  48759. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48760. * @param data contains the texture data
  48761. * @param texture defines the BabylonJS internal texture
  48762. * @param callback defines the method to call once ready to upload
  48763. */
  48764. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48765. }
  48766. }
  48767. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48768. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48769. /** @hidden */
  48770. export var rgbdEncodePixelShader: {
  48771. name: string;
  48772. shader: string;
  48773. };
  48774. }
  48775. declare module "babylonjs/Misc/environmentTextureTools" {
  48776. import { Nullable } from "babylonjs/types";
  48777. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48778. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48779. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48780. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48781. import "babylonjs/Shaders/rgbdEncode.fragment";
  48782. import "babylonjs/Shaders/rgbdDecode.fragment";
  48783. /**
  48784. * Raw texture data and descriptor sufficient for WebGL texture upload
  48785. */
  48786. export interface EnvironmentTextureInfo {
  48787. /**
  48788. * Version of the environment map
  48789. */
  48790. version: number;
  48791. /**
  48792. * Width of image
  48793. */
  48794. width: number;
  48795. /**
  48796. * Irradiance information stored in the file.
  48797. */
  48798. irradiance: any;
  48799. /**
  48800. * Specular information stored in the file.
  48801. */
  48802. specular: any;
  48803. }
  48804. /**
  48805. * Sets of helpers addressing the serialization and deserialization of environment texture
  48806. * stored in a BabylonJS env file.
  48807. * Those files are usually stored as .env files.
  48808. */
  48809. export class EnvironmentTextureTools {
  48810. /**
  48811. * Magic number identifying the env file.
  48812. */
  48813. private static _MagicBytes;
  48814. /**
  48815. * Gets the environment info from an env file.
  48816. * @param data The array buffer containing the .env bytes.
  48817. * @returns the environment file info (the json header) if successfully parsed.
  48818. */
  48819. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48820. /**
  48821. * Creates an environment texture from a loaded cube texture.
  48822. * @param texture defines the cube texture to convert in env file
  48823. * @return a promise containing the environment data if succesfull.
  48824. */
  48825. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48826. /**
  48827. * Creates a JSON representation of the spherical data.
  48828. * @param texture defines the texture containing the polynomials
  48829. * @return the JSON representation of the spherical info
  48830. */
  48831. private static _CreateEnvTextureIrradiance;
  48832. /**
  48833. * Uploads the texture info contained in the env file to the GPU.
  48834. * @param texture defines the internal texture to upload to
  48835. * @param arrayBuffer defines the buffer cotaining the data to load
  48836. * @param info defines the texture info retrieved through the GetEnvInfo method
  48837. * @returns a promise
  48838. */
  48839. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48840. /**
  48841. * Uploads the levels of image data to the GPU.
  48842. * @param texture defines the internal texture to upload to
  48843. * @param imageData defines the array buffer views of image data [mipmap][face]
  48844. * @returns a promise
  48845. */
  48846. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48847. /**
  48848. * Uploads spherical polynomials information to the texture.
  48849. * @param texture defines the texture we are trying to upload the information to
  48850. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48851. */
  48852. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48853. /** @hidden */
  48854. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48855. }
  48856. }
  48857. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48858. import { Nullable } from "babylonjs/types";
  48859. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48860. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48861. /**
  48862. * Implementation of the ENV Texture Loader.
  48863. * @hidden
  48864. */
  48865. export class _ENVTextureLoader implements IInternalTextureLoader {
  48866. /**
  48867. * Defines wether the loader supports cascade loading the different faces.
  48868. */
  48869. readonly supportCascades: boolean;
  48870. /**
  48871. * This returns if the loader support the current file information.
  48872. * @param extension defines the file extension of the file being loaded
  48873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48874. * @param fallback defines the fallback internal texture if any
  48875. * @param isBase64 defines whether the texture is encoded as a base64
  48876. * @param isBuffer defines whether the texture data are stored as a buffer
  48877. * @returns true if the loader can load the specified file
  48878. */
  48879. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48880. /**
  48881. * Transform the url before loading if required.
  48882. * @param rootUrl the url of the texture
  48883. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48884. * @returns the transformed texture
  48885. */
  48886. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48887. /**
  48888. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48889. * @param rootUrl the url of the texture
  48890. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48891. * @returns the fallback texture
  48892. */
  48893. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48894. /**
  48895. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48896. * @param data contains the texture data
  48897. * @param texture defines the BabylonJS internal texture
  48898. * @param createPolynomials will be true if polynomials have been requested
  48899. * @param onLoad defines the callback to trigger once the texture is ready
  48900. * @param onError defines the callback to trigger in case of error
  48901. */
  48902. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48903. /**
  48904. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48905. * @param data contains the texture data
  48906. * @param texture defines the BabylonJS internal texture
  48907. * @param callback defines the method to call once ready to upload
  48908. */
  48909. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48910. }
  48911. }
  48912. declare module "babylonjs/Misc/khronosTextureContainer" {
  48913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48914. /**
  48915. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48916. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48917. */
  48918. export class KhronosTextureContainer {
  48919. /** contents of the KTX container file */
  48920. arrayBuffer: any;
  48921. private static HEADER_LEN;
  48922. private static COMPRESSED_2D;
  48923. private static COMPRESSED_3D;
  48924. private static TEX_2D;
  48925. private static TEX_3D;
  48926. /**
  48927. * Gets the openGL type
  48928. */
  48929. glType: number;
  48930. /**
  48931. * Gets the openGL type size
  48932. */
  48933. glTypeSize: number;
  48934. /**
  48935. * Gets the openGL format
  48936. */
  48937. glFormat: number;
  48938. /**
  48939. * Gets the openGL internal format
  48940. */
  48941. glInternalFormat: number;
  48942. /**
  48943. * Gets the base internal format
  48944. */
  48945. glBaseInternalFormat: number;
  48946. /**
  48947. * Gets image width in pixel
  48948. */
  48949. pixelWidth: number;
  48950. /**
  48951. * Gets image height in pixel
  48952. */
  48953. pixelHeight: number;
  48954. /**
  48955. * Gets image depth in pixels
  48956. */
  48957. pixelDepth: number;
  48958. /**
  48959. * Gets the number of array elements
  48960. */
  48961. numberOfArrayElements: number;
  48962. /**
  48963. * Gets the number of faces
  48964. */
  48965. numberOfFaces: number;
  48966. /**
  48967. * Gets the number of mipmap levels
  48968. */
  48969. numberOfMipmapLevels: number;
  48970. /**
  48971. * Gets the bytes of key value data
  48972. */
  48973. bytesOfKeyValueData: number;
  48974. /**
  48975. * Gets the load type
  48976. */
  48977. loadType: number;
  48978. /**
  48979. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48980. */
  48981. isInvalid: boolean;
  48982. /**
  48983. * Creates a new KhronosTextureContainer
  48984. * @param arrayBuffer contents of the KTX container file
  48985. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48986. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48987. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48988. */
  48989. constructor(
  48990. /** contents of the KTX container file */
  48991. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48992. /**
  48993. * Uploads KTX content to a Babylon Texture.
  48994. * It is assumed that the texture has already been created & is currently bound
  48995. * @hidden
  48996. */
  48997. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48998. private _upload2DCompressedLevels;
  48999. }
  49000. }
  49001. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49002. import { Nullable } from "babylonjs/types";
  49003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49004. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49005. /**
  49006. * Implementation of the KTX Texture Loader.
  49007. * @hidden
  49008. */
  49009. export class _KTXTextureLoader implements IInternalTextureLoader {
  49010. /**
  49011. * Defines wether the loader supports cascade loading the different faces.
  49012. */
  49013. readonly supportCascades: boolean;
  49014. /**
  49015. * This returns if the loader support the current file information.
  49016. * @param extension defines the file extension of the file being loaded
  49017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49018. * @param fallback defines the fallback internal texture if any
  49019. * @param isBase64 defines whether the texture is encoded as a base64
  49020. * @param isBuffer defines whether the texture data are stored as a buffer
  49021. * @returns true if the loader can load the specified file
  49022. */
  49023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49024. /**
  49025. * Transform the url before loading if required.
  49026. * @param rootUrl the url of the texture
  49027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49028. * @returns the transformed texture
  49029. */
  49030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49031. /**
  49032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49033. * @param rootUrl the url of the texture
  49034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49035. * @returns the fallback texture
  49036. */
  49037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49038. /**
  49039. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49040. * @param data contains the texture data
  49041. * @param texture defines the BabylonJS internal texture
  49042. * @param createPolynomials will be true if polynomials have been requested
  49043. * @param onLoad defines the callback to trigger once the texture is ready
  49044. * @param onError defines the callback to trigger in case of error
  49045. */
  49046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49047. /**
  49048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49049. * @param data contains the texture data
  49050. * @param texture defines the BabylonJS internal texture
  49051. * @param callback defines the method to call once ready to upload
  49052. */
  49053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49054. }
  49055. }
  49056. declare module "babylonjs/Helpers/sceneHelpers" {
  49057. import { Nullable } from "babylonjs/types";
  49058. import { Mesh } from "babylonjs/Meshes/mesh";
  49059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49060. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49061. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49062. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49063. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49064. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49065. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49066. import "babylonjs/Meshes/Builders/boxBuilder";
  49067. /** @hidden */
  49068. export var _forceSceneHelpersToBundle: boolean;
  49069. module "babylonjs/scene" {
  49070. interface Scene {
  49071. /**
  49072. * Creates a default light for the scene.
  49073. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49074. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49075. */
  49076. createDefaultLight(replace?: boolean): void;
  49077. /**
  49078. * Creates a default camera for the scene.
  49079. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49080. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49081. * @param replace has default false, when true replaces the active camera in the scene
  49082. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49083. */
  49084. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49085. /**
  49086. * Creates a default camera and a default light.
  49087. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49088. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49089. * @param replace has the default false, when true replaces the active camera/light in the scene
  49090. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49091. */
  49092. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49093. /**
  49094. * Creates a new sky box
  49095. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49096. * @param environmentTexture defines the texture to use as environment texture
  49097. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49098. * @param scale defines the overall scale of the skybox
  49099. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49100. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49101. * @returns a new mesh holding the sky box
  49102. */
  49103. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49104. /**
  49105. * Creates a new environment
  49106. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49107. * @param options defines the options you can use to configure the environment
  49108. * @returns the new EnvironmentHelper
  49109. */
  49110. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49111. /**
  49112. * Creates a new VREXperienceHelper
  49113. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49114. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49115. * @returns a new VREXperienceHelper
  49116. */
  49117. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49118. /**
  49119. * Creates a new XREXperienceHelper
  49120. * @see http://doc.babylonjs.com/how_to/webxr
  49121. * @returns a promise for a new XREXperienceHelper
  49122. */
  49123. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49124. }
  49125. }
  49126. }
  49127. declare module "babylonjs/Helpers/videoDome" {
  49128. import { Scene } from "babylonjs/scene";
  49129. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49130. import { Mesh } from "babylonjs/Meshes/mesh";
  49131. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49132. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49133. import "babylonjs/Meshes/Builders/sphereBuilder";
  49134. /**
  49135. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49136. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49137. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49138. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49139. */
  49140. export class VideoDome extends TransformNode {
  49141. /**
  49142. * Define the video source as a Monoscopic panoramic 360 video.
  49143. */
  49144. static readonly MODE_MONOSCOPIC: number;
  49145. /**
  49146. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49147. */
  49148. static readonly MODE_TOPBOTTOM: number;
  49149. /**
  49150. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49151. */
  49152. static readonly MODE_SIDEBYSIDE: number;
  49153. private _useDirectMapping;
  49154. /**
  49155. * The video texture being displayed on the sphere
  49156. */
  49157. protected _videoTexture: VideoTexture;
  49158. /**
  49159. * Gets the video texture being displayed on the sphere
  49160. */
  49161. readonly videoTexture: VideoTexture;
  49162. /**
  49163. * The skybox material
  49164. */
  49165. protected _material: BackgroundMaterial;
  49166. /**
  49167. * The surface used for the skybox
  49168. */
  49169. protected _mesh: Mesh;
  49170. /**
  49171. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49172. * Also see the options.resolution property.
  49173. */
  49174. fovMultiplier: number;
  49175. private _videoMode;
  49176. /**
  49177. * Gets or set the current video mode for the video. It can be:
  49178. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49179. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49180. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49181. */
  49182. videoMode: number;
  49183. /**
  49184. * Oberserver used in Stereoscopic VR Mode.
  49185. */
  49186. private _onBeforeCameraRenderObserver;
  49187. /**
  49188. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49189. * @param name Element's name, child elements will append suffixes for their own names.
  49190. * @param urlsOrVideo defines the url(s) or the video element to use
  49191. * @param options An object containing optional or exposed sub element properties
  49192. */
  49193. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49194. resolution?: number;
  49195. clickToPlay?: boolean;
  49196. autoPlay?: boolean;
  49197. loop?: boolean;
  49198. size?: number;
  49199. poster?: string;
  49200. faceForward?: boolean;
  49201. useDirectMapping?: boolean;
  49202. }, scene: Scene);
  49203. private _changeVideoMode;
  49204. /**
  49205. * Releases resources associated with this node.
  49206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49208. */
  49209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49210. }
  49211. }
  49212. declare module "babylonjs/Helpers/index" {
  49213. export * from "babylonjs/Helpers/environmentHelper";
  49214. export * from "babylonjs/Helpers/photoDome";
  49215. export * from "babylonjs/Helpers/sceneHelpers";
  49216. export * from "babylonjs/Helpers/videoDome";
  49217. }
  49218. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49219. import { PerfCounter } from "babylonjs/Misc/tools";
  49220. import { IDisposable } from "babylonjs/scene";
  49221. import { Engine } from "babylonjs/Engines/engine";
  49222. /**
  49223. * This class can be used to get instrumentation data from a Babylon engine
  49224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49225. */
  49226. export class EngineInstrumentation implements IDisposable {
  49227. /**
  49228. * Define the instrumented engine.
  49229. */
  49230. engine: Engine;
  49231. private _captureGPUFrameTime;
  49232. private _gpuFrameTimeToken;
  49233. private _gpuFrameTime;
  49234. private _captureShaderCompilationTime;
  49235. private _shaderCompilationTime;
  49236. private _onBeginFrameObserver;
  49237. private _onEndFrameObserver;
  49238. private _onBeforeShaderCompilationObserver;
  49239. private _onAfterShaderCompilationObserver;
  49240. /**
  49241. * Gets the perf counter used for GPU frame time
  49242. */
  49243. readonly gpuFrameTimeCounter: PerfCounter;
  49244. /**
  49245. * Gets the GPU frame time capture status
  49246. */
  49247. /**
  49248. * Enable or disable the GPU frame time capture
  49249. */
  49250. captureGPUFrameTime: boolean;
  49251. /**
  49252. * Gets the perf counter used for shader compilation time
  49253. */
  49254. readonly shaderCompilationTimeCounter: PerfCounter;
  49255. /**
  49256. * Gets the shader compilation time capture status
  49257. */
  49258. /**
  49259. * Enable or disable the shader compilation time capture
  49260. */
  49261. captureShaderCompilationTime: boolean;
  49262. /**
  49263. * Instantiates a new engine instrumentation.
  49264. * This class can be used to get instrumentation data from a Babylon engine
  49265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49266. * @param engine Defines the engine to instrument
  49267. */
  49268. constructor(
  49269. /**
  49270. * Define the instrumented engine.
  49271. */
  49272. engine: Engine);
  49273. /**
  49274. * Dispose and release associated resources.
  49275. */
  49276. dispose(): void;
  49277. }
  49278. }
  49279. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49280. import { PerfCounter } from "babylonjs/Misc/tools";
  49281. import { Scene, IDisposable } from "babylonjs/scene";
  49282. /**
  49283. * This class can be used to get instrumentation data from a Babylon engine
  49284. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49285. */
  49286. export class SceneInstrumentation implements IDisposable {
  49287. /**
  49288. * Defines the scene to instrument
  49289. */
  49290. scene: Scene;
  49291. private _captureActiveMeshesEvaluationTime;
  49292. private _activeMeshesEvaluationTime;
  49293. private _captureRenderTargetsRenderTime;
  49294. private _renderTargetsRenderTime;
  49295. private _captureFrameTime;
  49296. private _frameTime;
  49297. private _captureRenderTime;
  49298. private _renderTime;
  49299. private _captureInterFrameTime;
  49300. private _interFrameTime;
  49301. private _captureParticlesRenderTime;
  49302. private _particlesRenderTime;
  49303. private _captureSpritesRenderTime;
  49304. private _spritesRenderTime;
  49305. private _capturePhysicsTime;
  49306. private _physicsTime;
  49307. private _captureAnimationsTime;
  49308. private _animationsTime;
  49309. private _captureCameraRenderTime;
  49310. private _cameraRenderTime;
  49311. private _onBeforeActiveMeshesEvaluationObserver;
  49312. private _onAfterActiveMeshesEvaluationObserver;
  49313. private _onBeforeRenderTargetsRenderObserver;
  49314. private _onAfterRenderTargetsRenderObserver;
  49315. private _onAfterRenderObserver;
  49316. private _onBeforeDrawPhaseObserver;
  49317. private _onAfterDrawPhaseObserver;
  49318. private _onBeforeAnimationsObserver;
  49319. private _onBeforeParticlesRenderingObserver;
  49320. private _onAfterParticlesRenderingObserver;
  49321. private _onBeforeSpritesRenderingObserver;
  49322. private _onAfterSpritesRenderingObserver;
  49323. private _onBeforePhysicsObserver;
  49324. private _onAfterPhysicsObserver;
  49325. private _onAfterAnimationsObserver;
  49326. private _onBeforeCameraRenderObserver;
  49327. private _onAfterCameraRenderObserver;
  49328. /**
  49329. * Gets the perf counter used for active meshes evaluation time
  49330. */
  49331. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49332. /**
  49333. * Gets the active meshes evaluation time capture status
  49334. */
  49335. /**
  49336. * Enable or disable the active meshes evaluation time capture
  49337. */
  49338. captureActiveMeshesEvaluationTime: boolean;
  49339. /**
  49340. * Gets the perf counter used for render targets render time
  49341. */
  49342. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49343. /**
  49344. * Gets the render targets render time capture status
  49345. */
  49346. /**
  49347. * Enable or disable the render targets render time capture
  49348. */
  49349. captureRenderTargetsRenderTime: boolean;
  49350. /**
  49351. * Gets the perf counter used for particles render time
  49352. */
  49353. readonly particlesRenderTimeCounter: PerfCounter;
  49354. /**
  49355. * Gets the particles render time capture status
  49356. */
  49357. /**
  49358. * Enable or disable the particles render time capture
  49359. */
  49360. captureParticlesRenderTime: boolean;
  49361. /**
  49362. * Gets the perf counter used for sprites render time
  49363. */
  49364. readonly spritesRenderTimeCounter: PerfCounter;
  49365. /**
  49366. * Gets the sprites render time capture status
  49367. */
  49368. /**
  49369. * Enable or disable the sprites render time capture
  49370. */
  49371. captureSpritesRenderTime: boolean;
  49372. /**
  49373. * Gets the perf counter used for physics time
  49374. */
  49375. readonly physicsTimeCounter: PerfCounter;
  49376. /**
  49377. * Gets the physics time capture status
  49378. */
  49379. /**
  49380. * Enable or disable the physics time capture
  49381. */
  49382. capturePhysicsTime: boolean;
  49383. /**
  49384. * Gets the perf counter used for animations time
  49385. */
  49386. readonly animationsTimeCounter: PerfCounter;
  49387. /**
  49388. * Gets the animations time capture status
  49389. */
  49390. /**
  49391. * Enable or disable the animations time capture
  49392. */
  49393. captureAnimationsTime: boolean;
  49394. /**
  49395. * Gets the perf counter used for frame time capture
  49396. */
  49397. readonly frameTimeCounter: PerfCounter;
  49398. /**
  49399. * Gets the frame time capture status
  49400. */
  49401. /**
  49402. * Enable or disable the frame time capture
  49403. */
  49404. captureFrameTime: boolean;
  49405. /**
  49406. * Gets the perf counter used for inter-frames time capture
  49407. */
  49408. readonly interFrameTimeCounter: PerfCounter;
  49409. /**
  49410. * Gets the inter-frames time capture status
  49411. */
  49412. /**
  49413. * Enable or disable the inter-frames time capture
  49414. */
  49415. captureInterFrameTime: boolean;
  49416. /**
  49417. * Gets the perf counter used for render time capture
  49418. */
  49419. readonly renderTimeCounter: PerfCounter;
  49420. /**
  49421. * Gets the render time capture status
  49422. */
  49423. /**
  49424. * Enable or disable the render time capture
  49425. */
  49426. captureRenderTime: boolean;
  49427. /**
  49428. * Gets the perf counter used for camera render time capture
  49429. */
  49430. readonly cameraRenderTimeCounter: PerfCounter;
  49431. /**
  49432. * Gets the camera render time capture status
  49433. */
  49434. /**
  49435. * Enable or disable the camera render time capture
  49436. */
  49437. captureCameraRenderTime: boolean;
  49438. /**
  49439. * Gets the perf counter used for draw calls
  49440. */
  49441. readonly drawCallsCounter: PerfCounter;
  49442. /**
  49443. * Instantiates a new scene instrumentation.
  49444. * This class can be used to get instrumentation data from a Babylon engine
  49445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49446. * @param scene Defines the scene to instrument
  49447. */
  49448. constructor(
  49449. /**
  49450. * Defines the scene to instrument
  49451. */
  49452. scene: Scene);
  49453. /**
  49454. * Dispose and release associated resources.
  49455. */
  49456. dispose(): void;
  49457. }
  49458. }
  49459. declare module "babylonjs/Instrumentation/index" {
  49460. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49461. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49462. export * from "babylonjs/Instrumentation/timeToken";
  49463. }
  49464. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49465. /** @hidden */
  49466. export var glowMapGenerationPixelShader: {
  49467. name: string;
  49468. shader: string;
  49469. };
  49470. }
  49471. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49472. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49473. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49474. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49475. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49476. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49477. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49478. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49479. /** @hidden */
  49480. export var glowMapGenerationVertexShader: {
  49481. name: string;
  49482. shader: string;
  49483. };
  49484. }
  49485. declare module "babylonjs/Layers/effectLayer" {
  49486. import { Observable } from "babylonjs/Misc/observable";
  49487. import { Nullable } from "babylonjs/types";
  49488. import { Camera } from "babylonjs/Cameras/camera";
  49489. import { Scene } from "babylonjs/scene";
  49490. import { Color4, ISize } from "babylonjs/Maths/math";
  49491. import { Engine } from "babylonjs/Engines/engine";
  49492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49494. import { Mesh } from "babylonjs/Meshes/mesh";
  49495. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49498. import { Effect } from "babylonjs/Materials/effect";
  49499. import { Material } from "babylonjs/Materials/material";
  49500. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49501. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49502. /**
  49503. * Effect layer options. This helps customizing the behaviour
  49504. * of the effect layer.
  49505. */
  49506. export interface IEffectLayerOptions {
  49507. /**
  49508. * Multiplication factor apply to the canvas size to compute the render target size
  49509. * used to generated the objects (the smaller the faster).
  49510. */
  49511. mainTextureRatio: number;
  49512. /**
  49513. * Enforces a fixed size texture to ensure effect stability across devices.
  49514. */
  49515. mainTextureFixedSize?: number;
  49516. /**
  49517. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49518. */
  49519. alphaBlendingMode: number;
  49520. /**
  49521. * The camera attached to the layer.
  49522. */
  49523. camera: Nullable<Camera>;
  49524. /**
  49525. * The rendering group to draw the layer in.
  49526. */
  49527. renderingGroupId: number;
  49528. }
  49529. /**
  49530. * The effect layer Helps adding post process effect blended with the main pass.
  49531. *
  49532. * This can be for instance use to generate glow or higlight effects on the scene.
  49533. *
  49534. * The effect layer class can not be used directly and is intented to inherited from to be
  49535. * customized per effects.
  49536. */
  49537. export abstract class EffectLayer {
  49538. private _vertexBuffers;
  49539. private _indexBuffer;
  49540. private _cachedDefines;
  49541. private _effectLayerMapGenerationEffect;
  49542. private _effectLayerOptions;
  49543. private _mergeEffect;
  49544. protected _scene: Scene;
  49545. protected _engine: Engine;
  49546. protected _maxSize: number;
  49547. protected _mainTextureDesiredSize: ISize;
  49548. protected _mainTexture: RenderTargetTexture;
  49549. protected _shouldRender: boolean;
  49550. protected _postProcesses: PostProcess[];
  49551. protected _textures: BaseTexture[];
  49552. protected _emissiveTextureAndColor: {
  49553. texture: Nullable<BaseTexture>;
  49554. color: Color4;
  49555. };
  49556. /**
  49557. * The name of the layer
  49558. */
  49559. name: string;
  49560. /**
  49561. * The clear color of the texture used to generate the glow map.
  49562. */
  49563. neutralColor: Color4;
  49564. /**
  49565. * Specifies wether the highlight layer is enabled or not.
  49566. */
  49567. isEnabled: boolean;
  49568. /**
  49569. * Gets the camera attached to the layer.
  49570. */
  49571. readonly camera: Nullable<Camera>;
  49572. /**
  49573. * Gets the rendering group id the layer should render in.
  49574. */
  49575. renderingGroupId: number;
  49576. /**
  49577. * An event triggered when the effect layer has been disposed.
  49578. */
  49579. onDisposeObservable: Observable<EffectLayer>;
  49580. /**
  49581. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49582. */
  49583. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49584. /**
  49585. * An event triggered when the generated texture is being merged in the scene.
  49586. */
  49587. onBeforeComposeObservable: Observable<EffectLayer>;
  49588. /**
  49589. * An event triggered when the generated texture has been merged in the scene.
  49590. */
  49591. onAfterComposeObservable: Observable<EffectLayer>;
  49592. /**
  49593. * An event triggered when the efffect layer changes its size.
  49594. */
  49595. onSizeChangedObservable: Observable<EffectLayer>;
  49596. /** @hidden */
  49597. static _SceneComponentInitialization: (scene: Scene) => void;
  49598. /**
  49599. * Instantiates a new effect Layer and references it in the scene.
  49600. * @param name The name of the layer
  49601. * @param scene The scene to use the layer in
  49602. */
  49603. constructor(
  49604. /** The Friendly of the effect in the scene */
  49605. name: string, scene: Scene);
  49606. /**
  49607. * Get the effect name of the layer.
  49608. * @return The effect name
  49609. */
  49610. abstract getEffectName(): string;
  49611. /**
  49612. * Checks for the readiness of the element composing the layer.
  49613. * @param subMesh the mesh to check for
  49614. * @param useInstances specify wether or not to use instances to render the mesh
  49615. * @return true if ready otherwise, false
  49616. */
  49617. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49618. /**
  49619. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49620. * @returns true if the effect requires stencil during the main canvas render pass.
  49621. */
  49622. abstract needStencil(): boolean;
  49623. /**
  49624. * Create the merge effect. This is the shader use to blit the information back
  49625. * to the main canvas at the end of the scene rendering.
  49626. * @returns The effect containing the shader used to merge the effect on the main canvas
  49627. */
  49628. protected abstract _createMergeEffect(): Effect;
  49629. /**
  49630. * Creates the render target textures and post processes used in the effect layer.
  49631. */
  49632. protected abstract _createTextureAndPostProcesses(): void;
  49633. /**
  49634. * Implementation specific of rendering the generating effect on the main canvas.
  49635. * @param effect The effect used to render through
  49636. */
  49637. protected abstract _internalRender(effect: Effect): void;
  49638. /**
  49639. * Sets the required values for both the emissive texture and and the main color.
  49640. */
  49641. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49642. /**
  49643. * Free any resources and references associated to a mesh.
  49644. * Internal use
  49645. * @param mesh The mesh to free.
  49646. */
  49647. abstract _disposeMesh(mesh: Mesh): void;
  49648. /**
  49649. * Serializes this layer (Glow or Highlight for example)
  49650. * @returns a serialized layer object
  49651. */
  49652. abstract serialize?(): any;
  49653. /**
  49654. * Initializes the effect layer with the required options.
  49655. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49656. */
  49657. protected _init(options: Partial<IEffectLayerOptions>): void;
  49658. /**
  49659. * Generates the index buffer of the full screen quad blending to the main canvas.
  49660. */
  49661. private _generateIndexBuffer;
  49662. /**
  49663. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49664. */
  49665. private _generateVertexBuffer;
  49666. /**
  49667. * Sets the main texture desired size which is the closest power of two
  49668. * of the engine canvas size.
  49669. */
  49670. private _setMainTextureSize;
  49671. /**
  49672. * Creates the main texture for the effect layer.
  49673. */
  49674. protected _createMainTexture(): void;
  49675. /**
  49676. * Adds specific effects defines.
  49677. * @param defines The defines to add specifics to.
  49678. */
  49679. protected _addCustomEffectDefines(defines: string[]): void;
  49680. /**
  49681. * Checks for the readiness of the element composing the layer.
  49682. * @param subMesh the mesh to check for
  49683. * @param useInstances specify wether or not to use instances to render the mesh
  49684. * @param emissiveTexture the associated emissive texture used to generate the glow
  49685. * @return true if ready otherwise, false
  49686. */
  49687. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49688. /**
  49689. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49690. */
  49691. render(): void;
  49692. /**
  49693. * Determine if a given mesh will be used in the current effect.
  49694. * @param mesh mesh to test
  49695. * @returns true if the mesh will be used
  49696. */
  49697. hasMesh(mesh: AbstractMesh): boolean;
  49698. /**
  49699. * Returns true if the layer contains information to display, otherwise false.
  49700. * @returns true if the glow layer should be rendered
  49701. */
  49702. shouldRender(): boolean;
  49703. /**
  49704. * Returns true if the mesh should render, otherwise false.
  49705. * @param mesh The mesh to render
  49706. * @returns true if it should render otherwise false
  49707. */
  49708. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49709. /**
  49710. * Returns true if the mesh can be rendered, otherwise false.
  49711. * @param mesh The mesh to render
  49712. * @param material The material used on the mesh
  49713. * @returns true if it can be rendered otherwise false
  49714. */
  49715. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49716. /**
  49717. * Returns true if the mesh should render, otherwise false.
  49718. * @param mesh The mesh to render
  49719. * @returns true if it should render otherwise false
  49720. */
  49721. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49722. /**
  49723. * Renders the submesh passed in parameter to the generation map.
  49724. */
  49725. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49726. /**
  49727. * Rebuild the required buffers.
  49728. * @hidden Internal use only.
  49729. */
  49730. _rebuild(): void;
  49731. /**
  49732. * Dispose only the render target textures and post process.
  49733. */
  49734. private _disposeTextureAndPostProcesses;
  49735. /**
  49736. * Dispose the highlight layer and free resources.
  49737. */
  49738. dispose(): void;
  49739. /**
  49740. * Gets the class name of the effect layer
  49741. * @returns the string with the class name of the effect layer
  49742. */
  49743. getClassName(): string;
  49744. /**
  49745. * Creates an effect layer from parsed effect layer data
  49746. * @param parsedEffectLayer defines effect layer data
  49747. * @param scene defines the current scene
  49748. * @param rootUrl defines the root URL containing the effect layer information
  49749. * @returns a parsed effect Layer
  49750. */
  49751. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49752. }
  49753. }
  49754. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49755. import { Scene } from "babylonjs/scene";
  49756. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49757. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49758. import { AbstractScene } from "babylonjs/abstractScene";
  49759. module "babylonjs/abstractScene" {
  49760. interface AbstractScene {
  49761. /**
  49762. * The list of effect layers (highlights/glow) added to the scene
  49763. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49764. * @see http://doc.babylonjs.com/how_to/glow_layer
  49765. */
  49766. effectLayers: Array<EffectLayer>;
  49767. /**
  49768. * Removes the given effect layer from this scene.
  49769. * @param toRemove defines the effect layer to remove
  49770. * @returns the index of the removed effect layer
  49771. */
  49772. removeEffectLayer(toRemove: EffectLayer): number;
  49773. /**
  49774. * Adds the given effect layer to this scene
  49775. * @param newEffectLayer defines the effect layer to add
  49776. */
  49777. addEffectLayer(newEffectLayer: EffectLayer): void;
  49778. }
  49779. }
  49780. /**
  49781. * Defines the layer scene component responsible to manage any effect layers
  49782. * in a given scene.
  49783. */
  49784. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49785. /**
  49786. * The component name helpfull to identify the component in the list of scene components.
  49787. */
  49788. readonly name: string;
  49789. /**
  49790. * The scene the component belongs to.
  49791. */
  49792. scene: Scene;
  49793. private _engine;
  49794. private _renderEffects;
  49795. private _needStencil;
  49796. private _previousStencilState;
  49797. /**
  49798. * Creates a new instance of the component for the given scene
  49799. * @param scene Defines the scene to register the component in
  49800. */
  49801. constructor(scene: Scene);
  49802. /**
  49803. * Registers the component in a given scene
  49804. */
  49805. register(): void;
  49806. /**
  49807. * Rebuilds the elements related to this component in case of
  49808. * context lost for instance.
  49809. */
  49810. rebuild(): void;
  49811. /**
  49812. * Serializes the component data to the specified json object
  49813. * @param serializationObject The object to serialize to
  49814. */
  49815. serialize(serializationObject: any): void;
  49816. /**
  49817. * Adds all the elements from the container to the scene
  49818. * @param container the container holding the elements
  49819. */
  49820. addFromContainer(container: AbstractScene): void;
  49821. /**
  49822. * Removes all the elements in the container from the scene
  49823. * @param container contains the elements to remove
  49824. * @param dispose if the removed element should be disposed (default: false)
  49825. */
  49826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49827. /**
  49828. * Disposes the component and the associated ressources.
  49829. */
  49830. dispose(): void;
  49831. private _isReadyForMesh;
  49832. private _renderMainTexture;
  49833. private _setStencil;
  49834. private _setStencilBack;
  49835. private _draw;
  49836. private _drawCamera;
  49837. private _drawRenderingGroup;
  49838. }
  49839. }
  49840. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49841. /** @hidden */
  49842. export var glowMapMergePixelShader: {
  49843. name: string;
  49844. shader: string;
  49845. };
  49846. }
  49847. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49848. /** @hidden */
  49849. export var glowMapMergeVertexShader: {
  49850. name: string;
  49851. shader: string;
  49852. };
  49853. }
  49854. declare module "babylonjs/Layers/glowLayer" {
  49855. import { Nullable } from "babylonjs/types";
  49856. import { Camera } from "babylonjs/Cameras/camera";
  49857. import { Scene } from "babylonjs/scene";
  49858. import { Color4 } from "babylonjs/Maths/math";
  49859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49861. import { Mesh } from "babylonjs/Meshes/mesh";
  49862. import { Texture } from "babylonjs/Materials/Textures/texture";
  49863. import { Effect } from "babylonjs/Materials/effect";
  49864. import { Material } from "babylonjs/Materials/material";
  49865. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49866. import "babylonjs/Shaders/glowMapMerge.fragment";
  49867. import "babylonjs/Shaders/glowMapMerge.vertex";
  49868. import "babylonjs/Layers/effectLayerSceneComponent";
  49869. module "babylonjs/abstractScene" {
  49870. interface AbstractScene {
  49871. /**
  49872. * Return a the first highlight layer of the scene with a given name.
  49873. * @param name The name of the highlight layer to look for.
  49874. * @return The highlight layer if found otherwise null.
  49875. */
  49876. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49877. }
  49878. }
  49879. /**
  49880. * Glow layer options. This helps customizing the behaviour
  49881. * of the glow layer.
  49882. */
  49883. export interface IGlowLayerOptions {
  49884. /**
  49885. * Multiplication factor apply to the canvas size to compute the render target size
  49886. * used to generated the glowing objects (the smaller the faster).
  49887. */
  49888. mainTextureRatio: number;
  49889. /**
  49890. * Enforces a fixed size texture to ensure resize independant blur.
  49891. */
  49892. mainTextureFixedSize?: number;
  49893. /**
  49894. * How big is the kernel of the blur texture.
  49895. */
  49896. blurKernelSize: number;
  49897. /**
  49898. * The camera attached to the layer.
  49899. */
  49900. camera: Nullable<Camera>;
  49901. /**
  49902. * Enable MSAA by chosing the number of samples.
  49903. */
  49904. mainTextureSamples?: number;
  49905. /**
  49906. * The rendering group to draw the layer in.
  49907. */
  49908. renderingGroupId: number;
  49909. }
  49910. /**
  49911. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49912. *
  49913. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49914. * glowy meshes to your scene.
  49915. *
  49916. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49917. */
  49918. export class GlowLayer extends EffectLayer {
  49919. /**
  49920. * Effect Name of the layer.
  49921. */
  49922. static readonly EffectName: string;
  49923. /**
  49924. * The default blur kernel size used for the glow.
  49925. */
  49926. static DefaultBlurKernelSize: number;
  49927. /**
  49928. * The default texture size ratio used for the glow.
  49929. */
  49930. static DefaultTextureRatio: number;
  49931. /**
  49932. * Sets the kernel size of the blur.
  49933. */
  49934. /**
  49935. * Gets the kernel size of the blur.
  49936. */
  49937. blurKernelSize: number;
  49938. /**
  49939. * Sets the glow intensity.
  49940. */
  49941. /**
  49942. * Gets the glow intensity.
  49943. */
  49944. intensity: number;
  49945. private _options;
  49946. private _intensity;
  49947. private _horizontalBlurPostprocess1;
  49948. private _verticalBlurPostprocess1;
  49949. private _horizontalBlurPostprocess2;
  49950. private _verticalBlurPostprocess2;
  49951. private _blurTexture1;
  49952. private _blurTexture2;
  49953. private _postProcesses1;
  49954. private _postProcesses2;
  49955. private _includedOnlyMeshes;
  49956. private _excludedMeshes;
  49957. /**
  49958. * Callback used to let the user override the color selection on a per mesh basis
  49959. */
  49960. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49961. /**
  49962. * Callback used to let the user override the texture selection on a per mesh basis
  49963. */
  49964. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49965. /**
  49966. * Instantiates a new glow Layer and references it to the scene.
  49967. * @param name The name of the layer
  49968. * @param scene The scene to use the layer in
  49969. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49970. */
  49971. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49972. /**
  49973. * Get the effect name of the layer.
  49974. * @return The effect name
  49975. */
  49976. getEffectName(): string;
  49977. /**
  49978. * Create the merge effect. This is the shader use to blit the information back
  49979. * to the main canvas at the end of the scene rendering.
  49980. */
  49981. protected _createMergeEffect(): Effect;
  49982. /**
  49983. * Creates the render target textures and post processes used in the glow layer.
  49984. */
  49985. protected _createTextureAndPostProcesses(): void;
  49986. /**
  49987. * Checks for the readiness of the element composing the layer.
  49988. * @param subMesh the mesh to check for
  49989. * @param useInstances specify wether or not to use instances to render the mesh
  49990. * @param emissiveTexture the associated emissive texture used to generate the glow
  49991. * @return true if ready otherwise, false
  49992. */
  49993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49994. /**
  49995. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49996. */
  49997. needStencil(): boolean;
  49998. /**
  49999. * Returns true if the mesh can be rendered, otherwise false.
  50000. * @param mesh The mesh to render
  50001. * @param material The material used on the mesh
  50002. * @returns true if it can be rendered otherwise false
  50003. */
  50004. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50005. /**
  50006. * Implementation specific of rendering the generating effect on the main canvas.
  50007. * @param effect The effect used to render through
  50008. */
  50009. protected _internalRender(effect: Effect): void;
  50010. /**
  50011. * Sets the required values for both the emissive texture and and the main color.
  50012. */
  50013. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50014. /**
  50015. * Returns true if the mesh should render, otherwise false.
  50016. * @param mesh The mesh to render
  50017. * @returns true if it should render otherwise false
  50018. */
  50019. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50020. /**
  50021. * Adds specific effects defines.
  50022. * @param defines The defines to add specifics to.
  50023. */
  50024. protected _addCustomEffectDefines(defines: string[]): void;
  50025. /**
  50026. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50027. * @param mesh The mesh to exclude from the glow layer
  50028. */
  50029. addExcludedMesh(mesh: Mesh): void;
  50030. /**
  50031. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50032. * @param mesh The mesh to remove
  50033. */
  50034. removeExcludedMesh(mesh: Mesh): void;
  50035. /**
  50036. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50037. * @param mesh The mesh to include in the glow layer
  50038. */
  50039. addIncludedOnlyMesh(mesh: Mesh): void;
  50040. /**
  50041. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50042. * @param mesh The mesh to remove
  50043. */
  50044. removeIncludedOnlyMesh(mesh: Mesh): void;
  50045. /**
  50046. * Determine if a given mesh will be used in the glow layer
  50047. * @param mesh The mesh to test
  50048. * @returns true if the mesh will be highlighted by the current glow layer
  50049. */
  50050. hasMesh(mesh: AbstractMesh): boolean;
  50051. /**
  50052. * Free any resources and references associated to a mesh.
  50053. * Internal use
  50054. * @param mesh The mesh to free.
  50055. * @hidden
  50056. */
  50057. _disposeMesh(mesh: Mesh): void;
  50058. /**
  50059. * Gets the class name of the effect layer
  50060. * @returns the string with the class name of the effect layer
  50061. */
  50062. getClassName(): string;
  50063. /**
  50064. * Serializes this glow layer
  50065. * @returns a serialized glow layer object
  50066. */
  50067. serialize(): any;
  50068. /**
  50069. * Creates a Glow Layer from parsed glow layer data
  50070. * @param parsedGlowLayer defines glow layer data
  50071. * @param scene defines the current scene
  50072. * @param rootUrl defines the root URL containing the glow layer information
  50073. * @returns a parsed Glow Layer
  50074. */
  50075. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50076. }
  50077. }
  50078. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50079. /** @hidden */
  50080. export var glowBlurPostProcessPixelShader: {
  50081. name: string;
  50082. shader: string;
  50083. };
  50084. }
  50085. declare module "babylonjs/Layers/highlightLayer" {
  50086. import { Observable } from "babylonjs/Misc/observable";
  50087. import { Nullable } from "babylonjs/types";
  50088. import { Camera } from "babylonjs/Cameras/camera";
  50089. import { Scene } from "babylonjs/scene";
  50090. import { Color3, Color4 } from "babylonjs/Maths/math";
  50091. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50093. import { Mesh } from "babylonjs/Meshes/mesh";
  50094. import { Effect } from "babylonjs/Materials/effect";
  50095. import { Material } from "babylonjs/Materials/material";
  50096. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50097. import "babylonjs/Shaders/glowMapMerge.fragment";
  50098. import "babylonjs/Shaders/glowMapMerge.vertex";
  50099. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50100. module "babylonjs/abstractScene" {
  50101. interface AbstractScene {
  50102. /**
  50103. * Return a the first highlight layer of the scene with a given name.
  50104. * @param name The name of the highlight layer to look for.
  50105. * @return The highlight layer if found otherwise null.
  50106. */
  50107. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50108. }
  50109. }
  50110. /**
  50111. * Highlight layer options. This helps customizing the behaviour
  50112. * of the highlight layer.
  50113. */
  50114. export interface IHighlightLayerOptions {
  50115. /**
  50116. * Multiplication factor apply to the canvas size to compute the render target size
  50117. * used to generated the glowing objects (the smaller the faster).
  50118. */
  50119. mainTextureRatio: number;
  50120. /**
  50121. * Enforces a fixed size texture to ensure resize independant blur.
  50122. */
  50123. mainTextureFixedSize?: number;
  50124. /**
  50125. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50126. * of the picture to blur (the smaller the faster).
  50127. */
  50128. blurTextureSizeRatio: number;
  50129. /**
  50130. * How big in texel of the blur texture is the vertical blur.
  50131. */
  50132. blurVerticalSize: number;
  50133. /**
  50134. * How big in texel of the blur texture is the horizontal blur.
  50135. */
  50136. blurHorizontalSize: number;
  50137. /**
  50138. * Alpha blending mode used to apply the blur. Default is combine.
  50139. */
  50140. alphaBlendingMode: number;
  50141. /**
  50142. * The camera attached to the layer.
  50143. */
  50144. camera: Nullable<Camera>;
  50145. /**
  50146. * Should we display highlight as a solid stroke?
  50147. */
  50148. isStroke?: boolean;
  50149. /**
  50150. * The rendering group to draw the layer in.
  50151. */
  50152. renderingGroupId: number;
  50153. }
  50154. /**
  50155. * The highlight layer Helps adding a glow effect around a mesh.
  50156. *
  50157. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50158. * glowy meshes to your scene.
  50159. *
  50160. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50161. */
  50162. export class HighlightLayer extends EffectLayer {
  50163. name: string;
  50164. /**
  50165. * Effect Name of the highlight layer.
  50166. */
  50167. static readonly EffectName: string;
  50168. /**
  50169. * The neutral color used during the preparation of the glow effect.
  50170. * This is black by default as the blend operation is a blend operation.
  50171. */
  50172. static NeutralColor: Color4;
  50173. /**
  50174. * Stencil value used for glowing meshes.
  50175. */
  50176. static GlowingMeshStencilReference: number;
  50177. /**
  50178. * Stencil value used for the other meshes in the scene.
  50179. */
  50180. static NormalMeshStencilReference: number;
  50181. /**
  50182. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50183. */
  50184. innerGlow: boolean;
  50185. /**
  50186. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50187. */
  50188. outerGlow: boolean;
  50189. /**
  50190. * Specifies the horizontal size of the blur.
  50191. */
  50192. /**
  50193. * Gets the horizontal size of the blur.
  50194. */
  50195. blurHorizontalSize: number;
  50196. /**
  50197. * Specifies the vertical size of the blur.
  50198. */
  50199. /**
  50200. * Gets the vertical size of the blur.
  50201. */
  50202. blurVerticalSize: number;
  50203. /**
  50204. * An event triggered when the highlight layer is being blurred.
  50205. */
  50206. onBeforeBlurObservable: Observable<HighlightLayer>;
  50207. /**
  50208. * An event triggered when the highlight layer has been blurred.
  50209. */
  50210. onAfterBlurObservable: Observable<HighlightLayer>;
  50211. private _instanceGlowingMeshStencilReference;
  50212. private _options;
  50213. private _downSamplePostprocess;
  50214. private _horizontalBlurPostprocess;
  50215. private _verticalBlurPostprocess;
  50216. private _blurTexture;
  50217. private _meshes;
  50218. private _excludedMeshes;
  50219. /**
  50220. * Instantiates a new highlight Layer and references it to the scene..
  50221. * @param name The name of the layer
  50222. * @param scene The scene to use the layer in
  50223. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50224. */
  50225. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50226. /**
  50227. * Get the effect name of the layer.
  50228. * @return The effect name
  50229. */
  50230. getEffectName(): string;
  50231. /**
  50232. * Create the merge effect. This is the shader use to blit the information back
  50233. * to the main canvas at the end of the scene rendering.
  50234. */
  50235. protected _createMergeEffect(): Effect;
  50236. /**
  50237. * Creates the render target textures and post processes used in the highlight layer.
  50238. */
  50239. protected _createTextureAndPostProcesses(): void;
  50240. /**
  50241. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50242. */
  50243. needStencil(): boolean;
  50244. /**
  50245. * Checks for the readiness of the element composing the layer.
  50246. * @param subMesh the mesh to check for
  50247. * @param useInstances specify wether or not to use instances to render the mesh
  50248. * @param emissiveTexture the associated emissive texture used to generate the glow
  50249. * @return true if ready otherwise, false
  50250. */
  50251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50252. /**
  50253. * Implementation specific of rendering the generating effect on the main canvas.
  50254. * @param effect The effect used to render through
  50255. */
  50256. protected _internalRender(effect: Effect): void;
  50257. /**
  50258. * Returns true if the layer contains information to display, otherwise false.
  50259. */
  50260. shouldRender(): boolean;
  50261. /**
  50262. * Returns true if the mesh should render, otherwise false.
  50263. * @param mesh The mesh to render
  50264. * @returns true if it should render otherwise false
  50265. */
  50266. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50267. /**
  50268. * Sets the required values for both the emissive texture and and the main color.
  50269. */
  50270. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50271. /**
  50272. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50273. * @param mesh The mesh to exclude from the highlight layer
  50274. */
  50275. addExcludedMesh(mesh: Mesh): void;
  50276. /**
  50277. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50278. * @param mesh The mesh to highlight
  50279. */
  50280. removeExcludedMesh(mesh: Mesh): void;
  50281. /**
  50282. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50283. * @param mesh mesh to test
  50284. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50285. */
  50286. hasMesh(mesh: AbstractMesh): boolean;
  50287. /**
  50288. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50289. * @param mesh The mesh to highlight
  50290. * @param color The color of the highlight
  50291. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50292. */
  50293. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50294. /**
  50295. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50296. * @param mesh The mesh to highlight
  50297. */
  50298. removeMesh(mesh: Mesh): void;
  50299. /**
  50300. * Force the stencil to the normal expected value for none glowing parts
  50301. */
  50302. private _defaultStencilReference;
  50303. /**
  50304. * Free any resources and references associated to a mesh.
  50305. * Internal use
  50306. * @param mesh The mesh to free.
  50307. * @hidden
  50308. */
  50309. _disposeMesh(mesh: Mesh): void;
  50310. /**
  50311. * Dispose the highlight layer and free resources.
  50312. */
  50313. dispose(): void;
  50314. /**
  50315. * Gets the class name of the effect layer
  50316. * @returns the string with the class name of the effect layer
  50317. */
  50318. getClassName(): string;
  50319. /**
  50320. * Serializes this Highlight layer
  50321. * @returns a serialized Highlight layer object
  50322. */
  50323. serialize(): any;
  50324. /**
  50325. * Creates a Highlight layer from parsed Highlight layer data
  50326. * @param parsedHightlightLayer defines the Highlight layer data
  50327. * @param scene defines the current scene
  50328. * @param rootUrl defines the root URL containing the Highlight layer information
  50329. * @returns a parsed Highlight layer
  50330. */
  50331. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50332. }
  50333. }
  50334. declare module "babylonjs/Layers/layerSceneComponent" {
  50335. import { Scene } from "babylonjs/scene";
  50336. import { ISceneComponent } from "babylonjs/sceneComponent";
  50337. import { Layer } from "babylonjs/Layers/layer";
  50338. import { AbstractScene } from "babylonjs/abstractScene";
  50339. module "babylonjs/abstractScene" {
  50340. interface AbstractScene {
  50341. /**
  50342. * The list of layers (background and foreground) of the scene
  50343. */
  50344. layers: Array<Layer>;
  50345. }
  50346. }
  50347. /**
  50348. * Defines the layer scene component responsible to manage any layers
  50349. * in a given scene.
  50350. */
  50351. export class LayerSceneComponent implements ISceneComponent {
  50352. /**
  50353. * The component name helpfull to identify the component in the list of scene components.
  50354. */
  50355. readonly name: string;
  50356. /**
  50357. * The scene the component belongs to.
  50358. */
  50359. scene: Scene;
  50360. private _engine;
  50361. /**
  50362. * Creates a new instance of the component for the given scene
  50363. * @param scene Defines the scene to register the component in
  50364. */
  50365. constructor(scene: Scene);
  50366. /**
  50367. * Registers the component in a given scene
  50368. */
  50369. register(): void;
  50370. /**
  50371. * Rebuilds the elements related to this component in case of
  50372. * context lost for instance.
  50373. */
  50374. rebuild(): void;
  50375. /**
  50376. * Disposes the component and the associated ressources.
  50377. */
  50378. dispose(): void;
  50379. private _draw;
  50380. private _drawCameraPredicate;
  50381. private _drawCameraBackground;
  50382. private _drawCameraForeground;
  50383. private _drawRenderTargetPredicate;
  50384. private _drawRenderTargetBackground;
  50385. private _drawRenderTargetForeground;
  50386. /**
  50387. * Adds all the elements from the container to the scene
  50388. * @param container the container holding the elements
  50389. */
  50390. addFromContainer(container: AbstractScene): void;
  50391. /**
  50392. * Removes all the elements in the container from the scene
  50393. * @param container contains the elements to remove
  50394. * @param dispose if the removed element should be disposed (default: false)
  50395. */
  50396. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50397. }
  50398. }
  50399. declare module "babylonjs/Shaders/layer.fragment" {
  50400. /** @hidden */
  50401. export var layerPixelShader: {
  50402. name: string;
  50403. shader: string;
  50404. };
  50405. }
  50406. declare module "babylonjs/Shaders/layer.vertex" {
  50407. /** @hidden */
  50408. export var layerVertexShader: {
  50409. name: string;
  50410. shader: string;
  50411. };
  50412. }
  50413. declare module "babylonjs/Layers/layer" {
  50414. import { Observable } from "babylonjs/Misc/observable";
  50415. import { Nullable } from "babylonjs/types";
  50416. import { Scene } from "babylonjs/scene";
  50417. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50418. import { Texture } from "babylonjs/Materials/Textures/texture";
  50419. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50420. import "babylonjs/Shaders/layer.fragment";
  50421. import "babylonjs/Shaders/layer.vertex";
  50422. /**
  50423. * This represents a full screen 2d layer.
  50424. * This can be useful to display a picture in the background of your scene for instance.
  50425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50426. */
  50427. export class Layer {
  50428. /**
  50429. * Define the name of the layer.
  50430. */
  50431. name: string;
  50432. /**
  50433. * Define the texture the layer should display.
  50434. */
  50435. texture: Nullable<Texture>;
  50436. /**
  50437. * Is the layer in background or foreground.
  50438. */
  50439. isBackground: boolean;
  50440. /**
  50441. * Define the color of the layer (instead of texture).
  50442. */
  50443. color: Color4;
  50444. /**
  50445. * Define the scale of the layer in order to zoom in out of the texture.
  50446. */
  50447. scale: Vector2;
  50448. /**
  50449. * Define an offset for the layer in order to shift the texture.
  50450. */
  50451. offset: Vector2;
  50452. /**
  50453. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50454. */
  50455. alphaBlendingMode: number;
  50456. /**
  50457. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50458. * Alpha test will not mix with the background color in case of transparency.
  50459. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50460. */
  50461. alphaTest: boolean;
  50462. /**
  50463. * Define a mask to restrict the layer to only some of the scene cameras.
  50464. */
  50465. layerMask: number;
  50466. /**
  50467. * Define the list of render target the layer is visible into.
  50468. */
  50469. renderTargetTextures: RenderTargetTexture[];
  50470. /**
  50471. * Define if the layer is only used in renderTarget or if it also
  50472. * renders in the main frame buffer of the canvas.
  50473. */
  50474. renderOnlyInRenderTargetTextures: boolean;
  50475. private _scene;
  50476. private _vertexBuffers;
  50477. private _indexBuffer;
  50478. private _effect;
  50479. private _alphaTestEffect;
  50480. /**
  50481. * An event triggered when the layer is disposed.
  50482. */
  50483. onDisposeObservable: Observable<Layer>;
  50484. private _onDisposeObserver;
  50485. /**
  50486. * Back compatibility with callback before the onDisposeObservable existed.
  50487. * The set callback will be triggered when the layer has been disposed.
  50488. */
  50489. onDispose: () => void;
  50490. /**
  50491. * An event triggered before rendering the scene
  50492. */
  50493. onBeforeRenderObservable: Observable<Layer>;
  50494. private _onBeforeRenderObserver;
  50495. /**
  50496. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50497. * The set callback will be triggered just before rendering the layer.
  50498. */
  50499. onBeforeRender: () => void;
  50500. /**
  50501. * An event triggered after rendering the scene
  50502. */
  50503. onAfterRenderObservable: Observable<Layer>;
  50504. private _onAfterRenderObserver;
  50505. /**
  50506. * Back compatibility with callback before the onAfterRenderObservable existed.
  50507. * The set callback will be triggered just after rendering the layer.
  50508. */
  50509. onAfterRender: () => void;
  50510. /**
  50511. * Instantiates a new layer.
  50512. * This represents a full screen 2d layer.
  50513. * This can be useful to display a picture in the background of your scene for instance.
  50514. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50515. * @param name Define the name of the layer in the scene
  50516. * @param imgUrl Define the url of the texture to display in the layer
  50517. * @param scene Define the scene the layer belongs to
  50518. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50519. * @param color Defines a color for the layer
  50520. */
  50521. constructor(
  50522. /**
  50523. * Define the name of the layer.
  50524. */
  50525. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50526. private _createIndexBuffer;
  50527. /** @hidden */
  50528. _rebuild(): void;
  50529. /**
  50530. * Renders the layer in the scene.
  50531. */
  50532. render(): void;
  50533. /**
  50534. * Disposes and releases the associated ressources.
  50535. */
  50536. dispose(): void;
  50537. }
  50538. }
  50539. declare module "babylonjs/Layers/index" {
  50540. export * from "babylonjs/Layers/effectLayer";
  50541. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50542. export * from "babylonjs/Layers/glowLayer";
  50543. export * from "babylonjs/Layers/highlightLayer";
  50544. export * from "babylonjs/Layers/layer";
  50545. export * from "babylonjs/Layers/layerSceneComponent";
  50546. }
  50547. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50548. /** @hidden */
  50549. export var lensFlarePixelShader: {
  50550. name: string;
  50551. shader: string;
  50552. };
  50553. }
  50554. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50555. /** @hidden */
  50556. export var lensFlareVertexShader: {
  50557. name: string;
  50558. shader: string;
  50559. };
  50560. }
  50561. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50562. import { Scene } from "babylonjs/scene";
  50563. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50565. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50566. import "babylonjs/Shaders/lensFlare.fragment";
  50567. import "babylonjs/Shaders/lensFlare.vertex";
  50568. /**
  50569. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50570. * It is usually composed of several `lensFlare`.
  50571. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50572. */
  50573. export class LensFlareSystem {
  50574. /**
  50575. * Define the name of the lens flare system
  50576. */
  50577. name: string;
  50578. /**
  50579. * List of lens flares used in this system.
  50580. */
  50581. lensFlares: LensFlare[];
  50582. /**
  50583. * Define a limit from the border the lens flare can be visible.
  50584. */
  50585. borderLimit: number;
  50586. /**
  50587. * Define a viewport border we do not want to see the lens flare in.
  50588. */
  50589. viewportBorder: number;
  50590. /**
  50591. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50592. */
  50593. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50594. /**
  50595. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50596. */
  50597. layerMask: number;
  50598. /**
  50599. * Define the id of the lens flare system in the scene.
  50600. * (equal to name by default)
  50601. */
  50602. id: string;
  50603. private _scene;
  50604. private _emitter;
  50605. private _vertexBuffers;
  50606. private _indexBuffer;
  50607. private _effect;
  50608. private _positionX;
  50609. private _positionY;
  50610. private _isEnabled;
  50611. /** @hidden */
  50612. static _SceneComponentInitialization: (scene: Scene) => void;
  50613. /**
  50614. * Instantiates a lens flare system.
  50615. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50616. * It is usually composed of several `lensFlare`.
  50617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50618. * @param name Define the name of the lens flare system in the scene
  50619. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50620. * @param scene Define the scene the lens flare system belongs to
  50621. */
  50622. constructor(
  50623. /**
  50624. * Define the name of the lens flare system
  50625. */
  50626. name: string, emitter: any, scene: Scene);
  50627. /**
  50628. * Define if the lens flare system is enabled.
  50629. */
  50630. isEnabled: boolean;
  50631. /**
  50632. * Get the scene the effects belongs to.
  50633. * @returns the scene holding the lens flare system
  50634. */
  50635. getScene(): Scene;
  50636. /**
  50637. * Get the emitter of the lens flare system.
  50638. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50639. * @returns the emitter of the lens flare system
  50640. */
  50641. getEmitter(): any;
  50642. /**
  50643. * Set the emitter of the lens flare system.
  50644. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50645. * @param newEmitter Define the new emitter of the system
  50646. */
  50647. setEmitter(newEmitter: any): void;
  50648. /**
  50649. * Get the lens flare system emitter position.
  50650. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50651. * @returns the position
  50652. */
  50653. getEmitterPosition(): Vector3;
  50654. /**
  50655. * @hidden
  50656. */
  50657. computeEffectivePosition(globalViewport: Viewport): boolean;
  50658. /** @hidden */
  50659. _isVisible(): boolean;
  50660. /**
  50661. * @hidden
  50662. */
  50663. render(): boolean;
  50664. /**
  50665. * Dispose and release the lens flare with its associated resources.
  50666. */
  50667. dispose(): void;
  50668. /**
  50669. * Parse a lens flare system from a JSON repressentation
  50670. * @param parsedLensFlareSystem Define the JSON to parse
  50671. * @param scene Define the scene the parsed system should be instantiated in
  50672. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50673. * @returns the parsed system
  50674. */
  50675. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50676. /**
  50677. * Serialize the current Lens Flare System into a JSON representation.
  50678. * @returns the serialized JSON
  50679. */
  50680. serialize(): any;
  50681. }
  50682. }
  50683. declare module "babylonjs/LensFlares/lensFlare" {
  50684. import { Nullable } from "babylonjs/types";
  50685. import { Color3 } from "babylonjs/Maths/math";
  50686. import { Texture } from "babylonjs/Materials/Textures/texture";
  50687. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50688. /**
  50689. * This represents one of the lens effect in a `lensFlareSystem`.
  50690. * It controls one of the indiviual texture used in the effect.
  50691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50692. */
  50693. export class LensFlare {
  50694. /**
  50695. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50696. */
  50697. size: number;
  50698. /**
  50699. * 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.
  50700. */
  50701. position: number;
  50702. /**
  50703. * Define the lens color.
  50704. */
  50705. color: Color3;
  50706. /**
  50707. * Define the lens texture.
  50708. */
  50709. texture: Nullable<Texture>;
  50710. /**
  50711. * Define the alpha mode to render this particular lens.
  50712. */
  50713. alphaMode: number;
  50714. private _system;
  50715. /**
  50716. * Creates a new Lens Flare.
  50717. * This represents one of the lens effect in a `lensFlareSystem`.
  50718. * It controls one of the indiviual texture used in the effect.
  50719. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50720. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50721. * @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.
  50722. * @param color Define the lens color
  50723. * @param imgUrl Define the lens texture url
  50724. * @param system Define the `lensFlareSystem` this flare is part of
  50725. * @returns The newly created Lens Flare
  50726. */
  50727. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50728. /**
  50729. * Instantiates a new Lens Flare.
  50730. * This represents one of the lens effect in a `lensFlareSystem`.
  50731. * It controls one of the indiviual texture used in the effect.
  50732. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50733. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50734. * @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.
  50735. * @param color Define the lens color
  50736. * @param imgUrl Define the lens texture url
  50737. * @param system Define the `lensFlareSystem` this flare is part of
  50738. */
  50739. constructor(
  50740. /**
  50741. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50742. */
  50743. size: number,
  50744. /**
  50745. * 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.
  50746. */
  50747. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50748. /**
  50749. * Dispose and release the lens flare with its associated resources.
  50750. */
  50751. dispose(): void;
  50752. }
  50753. }
  50754. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50755. import { Nullable } from "babylonjs/types";
  50756. import { Scene } from "babylonjs/scene";
  50757. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50758. import { AbstractScene } from "babylonjs/abstractScene";
  50759. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50760. module "babylonjs/abstractScene" {
  50761. interface AbstractScene {
  50762. /**
  50763. * The list of lens flare system added to the scene
  50764. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50765. */
  50766. lensFlareSystems: Array<LensFlareSystem>;
  50767. /**
  50768. * Removes the given lens flare system from this scene.
  50769. * @param toRemove The lens flare system to remove
  50770. * @returns The index of the removed lens flare system
  50771. */
  50772. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50773. /**
  50774. * Adds the given lens flare system to this scene
  50775. * @param newLensFlareSystem The lens flare system to add
  50776. */
  50777. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50778. /**
  50779. * Gets a lens flare system using its name
  50780. * @param name defines the name to look for
  50781. * @returns the lens flare system or null if not found
  50782. */
  50783. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50784. /**
  50785. * Gets a lens flare system using its id
  50786. * @param id defines the id to look for
  50787. * @returns the lens flare system or null if not found
  50788. */
  50789. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50790. }
  50791. }
  50792. /**
  50793. * Defines the lens flare scene component responsible to manage any lens flares
  50794. * in a given scene.
  50795. */
  50796. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50797. /**
  50798. * The component name helpfull to identify the component in the list of scene components.
  50799. */
  50800. readonly name: string;
  50801. /**
  50802. * The scene the component belongs to.
  50803. */
  50804. scene: Scene;
  50805. /**
  50806. * Creates a new instance of the component for the given scene
  50807. * @param scene Defines the scene to register the component in
  50808. */
  50809. constructor(scene: Scene);
  50810. /**
  50811. * Registers the component in a given scene
  50812. */
  50813. register(): void;
  50814. /**
  50815. * Rebuilds the elements related to this component in case of
  50816. * context lost for instance.
  50817. */
  50818. rebuild(): void;
  50819. /**
  50820. * Adds all the elements from the container to the scene
  50821. * @param container the container holding the elements
  50822. */
  50823. addFromContainer(container: AbstractScene): void;
  50824. /**
  50825. * Removes all the elements in the container from the scene
  50826. * @param container contains the elements to remove
  50827. * @param dispose if the removed element should be disposed (default: false)
  50828. */
  50829. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50830. /**
  50831. * Serializes the component data to the specified json object
  50832. * @param serializationObject The object to serialize to
  50833. */
  50834. serialize(serializationObject: any): void;
  50835. /**
  50836. * Disposes the component and the associated ressources.
  50837. */
  50838. dispose(): void;
  50839. private _draw;
  50840. }
  50841. }
  50842. declare module "babylonjs/LensFlares/index" {
  50843. export * from "babylonjs/LensFlares/lensFlare";
  50844. export * from "babylonjs/LensFlares/lensFlareSystem";
  50845. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50846. }
  50847. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50848. import { Scene } from "babylonjs/scene";
  50849. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50850. import { AbstractScene } from "babylonjs/abstractScene";
  50851. /**
  50852. * Defines the shadow generator component responsible to manage any shadow generators
  50853. * in a given scene.
  50854. */
  50855. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50856. /**
  50857. * The component name helpfull to identify the component in the list of scene components.
  50858. */
  50859. readonly name: string;
  50860. /**
  50861. * The scene the component belongs to.
  50862. */
  50863. scene: Scene;
  50864. /**
  50865. * Creates a new instance of the component for the given scene
  50866. * @param scene Defines the scene to register the component in
  50867. */
  50868. constructor(scene: Scene);
  50869. /**
  50870. * Registers the component in a given scene
  50871. */
  50872. register(): void;
  50873. /**
  50874. * Rebuilds the elements related to this component in case of
  50875. * context lost for instance.
  50876. */
  50877. rebuild(): void;
  50878. /**
  50879. * Serializes the component data to the specified json object
  50880. * @param serializationObject The object to serialize to
  50881. */
  50882. serialize(serializationObject: any): void;
  50883. /**
  50884. * Adds all the elements from the container to the scene
  50885. * @param container the container holding the elements
  50886. */
  50887. addFromContainer(container: AbstractScene): void;
  50888. /**
  50889. * Removes all the elements in the container from the scene
  50890. * @param container contains the elements to remove
  50891. * @param dispose if the removed element should be disposed (default: false)
  50892. */
  50893. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50894. /**
  50895. * Rebuilds the elements related to this component in case of
  50896. * context lost for instance.
  50897. */
  50898. dispose(): void;
  50899. private _gatherRenderTargets;
  50900. }
  50901. }
  50902. declare module "babylonjs/Lights/Shadows/index" {
  50903. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50904. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50905. }
  50906. declare module "babylonjs/Lights/pointLight" {
  50907. import { Scene } from "babylonjs/scene";
  50908. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50910. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50911. import { Effect } from "babylonjs/Materials/effect";
  50912. /**
  50913. * A point light is a light defined by an unique point in world space.
  50914. * The light is emitted in every direction from this point.
  50915. * A good example of a point light is a standard light bulb.
  50916. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50917. */
  50918. export class PointLight extends ShadowLight {
  50919. private _shadowAngle;
  50920. /**
  50921. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50922. * This specifies what angle the shadow will use to be created.
  50923. *
  50924. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50925. */
  50926. /**
  50927. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50928. * This specifies what angle the shadow will use to be created.
  50929. *
  50930. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50931. */
  50932. shadowAngle: number;
  50933. /**
  50934. * Gets the direction if it has been set.
  50935. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50936. */
  50937. /**
  50938. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50939. */
  50940. direction: Vector3;
  50941. /**
  50942. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50943. * A PointLight emits the light in every direction.
  50944. * It can cast shadows.
  50945. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50946. * ```javascript
  50947. * var pointLight = new PointLight("pl", camera.position, scene);
  50948. * ```
  50949. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50950. * @param name The light friendly name
  50951. * @param position The position of the point light in the scene
  50952. * @param scene The scene the lights belongs to
  50953. */
  50954. constructor(name: string, position: Vector3, scene: Scene);
  50955. /**
  50956. * Returns the string "PointLight"
  50957. * @returns the class name
  50958. */
  50959. getClassName(): string;
  50960. /**
  50961. * Returns the integer 0.
  50962. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50963. */
  50964. getTypeID(): number;
  50965. /**
  50966. * Specifies wether or not the shadowmap should be a cube texture.
  50967. * @returns true if the shadowmap needs to be a cube texture.
  50968. */
  50969. needCube(): boolean;
  50970. /**
  50971. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50972. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50973. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50974. */
  50975. getShadowDirection(faceIndex?: number): Vector3;
  50976. /**
  50977. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50978. * - fov = PI / 2
  50979. * - aspect ratio : 1.0
  50980. * - z-near and far equal to the active camera minZ and maxZ.
  50981. * Returns the PointLight.
  50982. */
  50983. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50984. protected _buildUniformLayout(): void;
  50985. /**
  50986. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50987. * @param effect The effect to update
  50988. * @param lightIndex The index of the light in the effect to update
  50989. * @returns The point light
  50990. */
  50991. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50992. /**
  50993. * Prepares the list of defines specific to the light type.
  50994. * @param defines the list of defines
  50995. * @param lightIndex defines the index of the light for the effect
  50996. */
  50997. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50998. }
  50999. }
  51000. declare module "babylonjs/Lights/index" {
  51001. export * from "babylonjs/Lights/light";
  51002. export * from "babylonjs/Lights/shadowLight";
  51003. export * from "babylonjs/Lights/Shadows/index";
  51004. export * from "babylonjs/Lights/directionalLight";
  51005. export * from "babylonjs/Lights/hemisphericLight";
  51006. export * from "babylonjs/Lights/pointLight";
  51007. export * from "babylonjs/Lights/spotLight";
  51008. }
  51009. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51010. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51011. /**
  51012. * Header information of HDR texture files.
  51013. */
  51014. export interface HDRInfo {
  51015. /**
  51016. * The height of the texture in pixels.
  51017. */
  51018. height: number;
  51019. /**
  51020. * The width of the texture in pixels.
  51021. */
  51022. width: number;
  51023. /**
  51024. * The index of the beginning of the data in the binary file.
  51025. */
  51026. dataPosition: number;
  51027. }
  51028. /**
  51029. * This groups tools to convert HDR texture to native colors array.
  51030. */
  51031. export class HDRTools {
  51032. private static Ldexp;
  51033. private static Rgbe2float;
  51034. private static readStringLine;
  51035. /**
  51036. * Reads header information from an RGBE texture stored in a native array.
  51037. * More information on this format are available here:
  51038. * https://en.wikipedia.org/wiki/RGBE_image_format
  51039. *
  51040. * @param uint8array The binary file stored in native array.
  51041. * @return The header information.
  51042. */
  51043. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51044. /**
  51045. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51046. * This RGBE texture needs to store the information as a panorama.
  51047. *
  51048. * More information on this format are available here:
  51049. * https://en.wikipedia.org/wiki/RGBE_image_format
  51050. *
  51051. * @param buffer The binary file stored in an array buffer.
  51052. * @param size The expected size of the extracted cubemap.
  51053. * @return The Cube Map information.
  51054. */
  51055. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51056. /**
  51057. * Returns the pixels data extracted from an RGBE texture.
  51058. * This pixels will be stored left to right up to down in the R G B order in one array.
  51059. *
  51060. * More information on this format are available here:
  51061. * https://en.wikipedia.org/wiki/RGBE_image_format
  51062. *
  51063. * @param uint8array The binary file stored in an array buffer.
  51064. * @param hdrInfo The header information of the file.
  51065. * @return The pixels data in RGB right to left up to down order.
  51066. */
  51067. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51068. private static RGBE_ReadPixels_RLE;
  51069. }
  51070. }
  51071. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51072. import { Nullable } from "babylonjs/types";
  51073. import { Scene } from "babylonjs/scene";
  51074. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51076. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51077. /**
  51078. * This represents a texture coming from an HDR input.
  51079. *
  51080. * The only supported format is currently panorama picture stored in RGBE format.
  51081. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51082. */
  51083. export class HDRCubeTexture extends BaseTexture {
  51084. private static _facesMapping;
  51085. private _generateHarmonics;
  51086. private _noMipmap;
  51087. private _textureMatrix;
  51088. private _size;
  51089. private _onLoad;
  51090. private _onError;
  51091. /**
  51092. * The texture URL.
  51093. */
  51094. url: string;
  51095. /**
  51096. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51097. */
  51098. coordinatesMode: number;
  51099. protected _isBlocking: boolean;
  51100. /**
  51101. * Sets wether or not the texture is blocking during loading.
  51102. */
  51103. /**
  51104. * Gets wether or not the texture is blocking during loading.
  51105. */
  51106. isBlocking: boolean;
  51107. protected _rotationY: number;
  51108. /**
  51109. * Sets texture matrix rotation angle around Y axis in radians.
  51110. */
  51111. /**
  51112. * Gets texture matrix rotation angle around Y axis radians.
  51113. */
  51114. rotationY: number;
  51115. /**
  51116. * Gets or sets the center of the bounding box associated with the cube texture
  51117. * It must define where the camera used to render the texture was set
  51118. */
  51119. boundingBoxPosition: Vector3;
  51120. private _boundingBoxSize;
  51121. /**
  51122. * Gets or sets the size of the bounding box associated with the cube texture
  51123. * When defined, the cubemap will switch to local mode
  51124. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51125. * @example https://www.babylonjs-playground.com/#RNASML
  51126. */
  51127. boundingBoxSize: Vector3;
  51128. /**
  51129. * Instantiates an HDRTexture from the following parameters.
  51130. *
  51131. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51132. * @param scene The scene the texture will be used in
  51133. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51134. * @param noMipmap Forces to not generate the mipmap if true
  51135. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51136. * @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)
  51137. * @param reserved Reserved flag for internal use.
  51138. */
  51139. 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>);
  51140. /**
  51141. * Get the current class name of the texture useful for serialization or dynamic coding.
  51142. * @returns "HDRCubeTexture"
  51143. */
  51144. getClassName(): string;
  51145. /**
  51146. * Occurs when the file is raw .hdr file.
  51147. */
  51148. private loadTexture;
  51149. clone(): HDRCubeTexture;
  51150. delayLoad(): void;
  51151. /**
  51152. * Get the texture reflection matrix used to rotate/transform the reflection.
  51153. * @returns the reflection matrix
  51154. */
  51155. getReflectionTextureMatrix(): Matrix;
  51156. /**
  51157. * Set the texture reflection matrix used to rotate/transform the reflection.
  51158. * @param value Define the reflection matrix to set
  51159. */
  51160. setReflectionTextureMatrix(value: Matrix): void;
  51161. /**
  51162. * Parses a JSON representation of an HDR Texture in order to create the texture
  51163. * @param parsedTexture Define the JSON representation
  51164. * @param scene Define the scene the texture should be created in
  51165. * @param rootUrl Define the root url in case we need to load relative dependencies
  51166. * @returns the newly created texture after parsing
  51167. */
  51168. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51169. serialize(): any;
  51170. }
  51171. }
  51172. declare module "babylonjs/Physics/physicsEngine" {
  51173. import { Nullable } from "babylonjs/types";
  51174. import { Vector3 } from "babylonjs/Maths/math";
  51175. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51176. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51177. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51178. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51179. /**
  51180. * Class used to control physics engine
  51181. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51182. */
  51183. export class PhysicsEngine implements IPhysicsEngine {
  51184. private _physicsPlugin;
  51185. /**
  51186. * Global value used to control the smallest number supported by the simulation
  51187. */
  51188. static Epsilon: number;
  51189. private _impostors;
  51190. private _joints;
  51191. /**
  51192. * Gets the gravity vector used by the simulation
  51193. */
  51194. gravity: Vector3;
  51195. /**
  51196. * Factory used to create the default physics plugin.
  51197. * @returns The default physics plugin
  51198. */
  51199. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51200. /**
  51201. * Creates a new Physics Engine
  51202. * @param gravity defines the gravity vector used by the simulation
  51203. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51204. */
  51205. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51206. /**
  51207. * Sets the gravity vector used by the simulation
  51208. * @param gravity defines the gravity vector to use
  51209. */
  51210. setGravity(gravity: Vector3): void;
  51211. /**
  51212. * Set the time step of the physics engine.
  51213. * Default is 1/60.
  51214. * To slow it down, enter 1/600 for example.
  51215. * To speed it up, 1/30
  51216. * @param newTimeStep defines the new timestep to apply to this world.
  51217. */
  51218. setTimeStep(newTimeStep?: number): void;
  51219. /**
  51220. * Get the time step of the physics engine.
  51221. * @returns the current time step
  51222. */
  51223. getTimeStep(): number;
  51224. /**
  51225. * Release all resources
  51226. */
  51227. dispose(): void;
  51228. /**
  51229. * Gets the name of the current physics plugin
  51230. * @returns the name of the plugin
  51231. */
  51232. getPhysicsPluginName(): string;
  51233. /**
  51234. * Adding a new impostor for the impostor tracking.
  51235. * This will be done by the impostor itself.
  51236. * @param impostor the impostor to add
  51237. */
  51238. addImpostor(impostor: PhysicsImpostor): void;
  51239. /**
  51240. * Remove an impostor from the engine.
  51241. * This impostor and its mesh will not longer be updated by the physics engine.
  51242. * @param impostor the impostor to remove
  51243. */
  51244. removeImpostor(impostor: PhysicsImpostor): void;
  51245. /**
  51246. * Add a joint to the physics engine
  51247. * @param mainImpostor defines the main impostor to which the joint is added.
  51248. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51249. * @param joint defines the joint that will connect both impostors.
  51250. */
  51251. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51252. /**
  51253. * Removes a joint from the simulation
  51254. * @param mainImpostor defines the impostor used with the joint
  51255. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51256. * @param joint defines the joint to remove
  51257. */
  51258. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51259. /**
  51260. * Called by the scene. No need to call it.
  51261. * @param delta defines the timespam between frames
  51262. */
  51263. _step(delta: number): void;
  51264. /**
  51265. * Gets the current plugin used to run the simulation
  51266. * @returns current plugin
  51267. */
  51268. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51269. /**
  51270. * Gets the list of physic impostors
  51271. * @returns an array of PhysicsImpostor
  51272. */
  51273. getImpostors(): Array<PhysicsImpostor>;
  51274. /**
  51275. * Gets the impostor for a physics enabled object
  51276. * @param object defines the object impersonated by the impostor
  51277. * @returns the PhysicsImpostor or null if not found
  51278. */
  51279. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51280. /**
  51281. * Gets the impostor for a physics body object
  51282. * @param body defines physics body used by the impostor
  51283. * @returns the PhysicsImpostor or null if not found
  51284. */
  51285. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51286. /**
  51287. * Does a raycast in the physics world
  51288. * @param from when should the ray start?
  51289. * @param to when should the ray end?
  51290. * @returns PhysicsRaycastResult
  51291. */
  51292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51293. }
  51294. }
  51295. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51296. import { Nullable } from "babylonjs/types";
  51297. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51299. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51300. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51301. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51302. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51303. /** @hidden */
  51304. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51305. private _useDeltaForWorldStep;
  51306. world: any;
  51307. name: string;
  51308. private _physicsMaterials;
  51309. private _fixedTimeStep;
  51310. private _cannonRaycastResult;
  51311. private _raycastResult;
  51312. private _physicsBodysToRemoveAfterStep;
  51313. BJSCANNON: any;
  51314. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51315. setGravity(gravity: Vector3): void;
  51316. setTimeStep(timeStep: number): void;
  51317. getTimeStep(): number;
  51318. executeStep(delta: number): void;
  51319. private _removeMarkedPhysicsBodiesFromWorld;
  51320. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51321. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51322. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51323. private _processChildMeshes;
  51324. removePhysicsBody(impostor: PhysicsImpostor): void;
  51325. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51326. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51327. private _addMaterial;
  51328. private _checkWithEpsilon;
  51329. private _createShape;
  51330. private _createHeightmap;
  51331. private _minus90X;
  51332. private _plus90X;
  51333. private _tmpPosition;
  51334. private _tmpDeltaPosition;
  51335. private _tmpUnityRotation;
  51336. private _updatePhysicsBodyTransformation;
  51337. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51338. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51339. isSupported(): boolean;
  51340. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51341. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51342. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51343. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51344. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51345. getBodyMass(impostor: PhysicsImpostor): number;
  51346. getBodyFriction(impostor: PhysicsImpostor): number;
  51347. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51348. getBodyRestitution(impostor: PhysicsImpostor): number;
  51349. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51350. sleepBody(impostor: PhysicsImpostor): void;
  51351. wakeUpBody(impostor: PhysicsImpostor): void;
  51352. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51353. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51354. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51355. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51356. getRadius(impostor: PhysicsImpostor): number;
  51357. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51358. dispose(): void;
  51359. private _extendNamespace;
  51360. /**
  51361. * Does a raycast in the physics world
  51362. * @param from when should the ray start?
  51363. * @param to when should the ray end?
  51364. * @returns PhysicsRaycastResult
  51365. */
  51366. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51367. }
  51368. }
  51369. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51370. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51371. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51372. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51374. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51375. import { Nullable } from "babylonjs/types";
  51376. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51377. /** @hidden */
  51378. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51379. world: any;
  51380. name: string;
  51381. BJSOIMO: any;
  51382. private _raycastResult;
  51383. constructor(iterations?: number, oimoInjection?: any);
  51384. setGravity(gravity: Vector3): void;
  51385. setTimeStep(timeStep: number): void;
  51386. getTimeStep(): number;
  51387. private _tmpImpostorsArray;
  51388. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51392. private _tmpPositionVector;
  51393. removePhysicsBody(impostor: PhysicsImpostor): void;
  51394. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51395. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51396. isSupported(): boolean;
  51397. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51398. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51399. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51400. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51401. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51402. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51403. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51404. getBodyMass(impostor: PhysicsImpostor): number;
  51405. getBodyFriction(impostor: PhysicsImpostor): number;
  51406. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51407. getBodyRestitution(impostor: PhysicsImpostor): number;
  51408. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51409. sleepBody(impostor: PhysicsImpostor): void;
  51410. wakeUpBody(impostor: PhysicsImpostor): void;
  51411. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51412. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51413. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51414. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51415. getRadius(impostor: PhysicsImpostor): number;
  51416. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51417. dispose(): void;
  51418. /**
  51419. * Does a raycast in the physics world
  51420. * @param from when should the ray start?
  51421. * @param to when should the ray end?
  51422. * @returns PhysicsRaycastResult
  51423. */
  51424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51425. }
  51426. }
  51427. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51428. import { Nullable } from "babylonjs/types";
  51429. import { Scene } from "babylonjs/scene";
  51430. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51431. import { Mesh } from "babylonjs/Meshes/mesh";
  51432. /**
  51433. * Class containing static functions to help procedurally build meshes
  51434. */
  51435. export class RibbonBuilder {
  51436. /**
  51437. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51438. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51439. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51440. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51441. * * 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
  51442. * * 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
  51443. * * 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
  51444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51447. * * 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
  51448. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51449. * * 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
  51450. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51452. * @param name defines the name of the mesh
  51453. * @param options defines the options used to create the mesh
  51454. * @param scene defines the hosting scene
  51455. * @returns the ribbon mesh
  51456. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51458. */
  51459. static CreateRibbon(name: string, options: {
  51460. pathArray: Vector3[][];
  51461. closeArray?: boolean;
  51462. closePath?: boolean;
  51463. offset?: number;
  51464. updatable?: boolean;
  51465. sideOrientation?: number;
  51466. frontUVs?: Vector4;
  51467. backUVs?: Vector4;
  51468. instance?: Mesh;
  51469. invertUV?: boolean;
  51470. uvs?: Vector2[];
  51471. colors?: Color4[];
  51472. }, scene?: Nullable<Scene>): Mesh;
  51473. }
  51474. }
  51475. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51476. import { Nullable } from "babylonjs/types";
  51477. import { Scene } from "babylonjs/scene";
  51478. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51479. import { Mesh } from "babylonjs/Meshes/mesh";
  51480. /**
  51481. * Class containing static functions to help procedurally build meshes
  51482. */
  51483. export class ShapeBuilder {
  51484. /**
  51485. * 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.
  51486. * * 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.
  51487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51488. * * 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.
  51489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51490. * * 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
  51491. * * 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
  51492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51497. * @param name defines the name of the mesh
  51498. * @param options defines the options used to create the mesh
  51499. * @param scene defines the hosting scene
  51500. * @returns the extruded shape mesh
  51501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51503. */
  51504. static ExtrudeShape(name: string, options: {
  51505. shape: Vector3[];
  51506. path: Vector3[];
  51507. scale?: number;
  51508. rotation?: number;
  51509. cap?: number;
  51510. updatable?: boolean;
  51511. sideOrientation?: number;
  51512. frontUVs?: Vector4;
  51513. backUVs?: Vector4;
  51514. instance?: Mesh;
  51515. invertUV?: boolean;
  51516. }, scene?: Nullable<Scene>): Mesh;
  51517. /**
  51518. * Creates an custom extruded shape mesh.
  51519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51520. * * 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.
  51521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51522. * * 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
  51523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51524. * * 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
  51525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51528. * * 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
  51529. * * 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
  51530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51535. * @param name defines the name of the mesh
  51536. * @param options defines the options used to create the mesh
  51537. * @param scene defines the hosting scene
  51538. * @returns the custom extruded shape mesh
  51539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51542. */
  51543. static ExtrudeShapeCustom(name: string, options: {
  51544. shape: Vector3[];
  51545. path: Vector3[];
  51546. scaleFunction?: any;
  51547. rotationFunction?: any;
  51548. ribbonCloseArray?: boolean;
  51549. ribbonClosePath?: boolean;
  51550. cap?: number;
  51551. updatable?: boolean;
  51552. sideOrientation?: number;
  51553. frontUVs?: Vector4;
  51554. backUVs?: Vector4;
  51555. instance?: Mesh;
  51556. invertUV?: boolean;
  51557. }, scene?: Nullable<Scene>): Mesh;
  51558. private static _ExtrudeShapeGeneric;
  51559. }
  51560. }
  51561. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51562. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51563. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51564. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51565. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51566. import { Nullable } from "babylonjs/types";
  51567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51568. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51569. /**
  51570. * AmmoJS Physics plugin
  51571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51572. * @see https://github.com/kripken/ammo.js/
  51573. */
  51574. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51575. private _useDeltaForWorldStep;
  51576. /**
  51577. * Reference to the Ammo library
  51578. */
  51579. bjsAMMO: any;
  51580. /**
  51581. * Created ammoJS world which physics bodies are added to
  51582. */
  51583. world: any;
  51584. /**
  51585. * Name of the plugin
  51586. */
  51587. name: string;
  51588. private _timeStep;
  51589. private _fixedTimeStep;
  51590. private _maxSteps;
  51591. private _tmpQuaternion;
  51592. private _tmpAmmoTransform;
  51593. private _tmpAmmoQuaternion;
  51594. private _tmpAmmoConcreteContactResultCallback;
  51595. private _collisionConfiguration;
  51596. private _dispatcher;
  51597. private _overlappingPairCache;
  51598. private _solver;
  51599. private _softBodySolver;
  51600. private _tmpAmmoVectorA;
  51601. private _tmpAmmoVectorB;
  51602. private _tmpAmmoVectorC;
  51603. private _tmpAmmoVectorD;
  51604. private _tmpContactCallbackResult;
  51605. private _tmpAmmoVectorRCA;
  51606. private _tmpAmmoVectorRCB;
  51607. private _raycastResult;
  51608. private static readonly DISABLE_COLLISION_FLAG;
  51609. private static readonly KINEMATIC_FLAG;
  51610. private static readonly DISABLE_DEACTIVATION_FLAG;
  51611. /**
  51612. * Initializes the ammoJS plugin
  51613. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51614. * @param ammoInjection can be used to inject your own ammo reference
  51615. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51616. */
  51617. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51618. /**
  51619. * Sets the gravity of the physics world (m/(s^2))
  51620. * @param gravity Gravity to set
  51621. */
  51622. setGravity(gravity: Vector3): void;
  51623. /**
  51624. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51625. * @param timeStep timestep to use in seconds
  51626. */
  51627. setTimeStep(timeStep: number): void;
  51628. /**
  51629. * 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)
  51630. * @param fixedTimeStep fixedTimeStep to use in seconds
  51631. */
  51632. setFixedTimeStep(fixedTimeStep: number): void;
  51633. /**
  51634. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51635. * @param maxSteps the maximum number of steps by the physics engine per frame
  51636. */
  51637. setMaxSteps(maxSteps: number): void;
  51638. /**
  51639. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51640. * @returns the current timestep in seconds
  51641. */
  51642. getTimeStep(): number;
  51643. private _isImpostorInContact;
  51644. private _isImpostorPairInContact;
  51645. private _stepSimulation;
  51646. /**
  51647. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51648. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51649. * After the step the babylon meshes are set to the position of the physics imposters
  51650. * @param delta amount of time to step forward
  51651. * @param impostors array of imposters to update before/after the step
  51652. */
  51653. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51654. /**
  51655. * Update babylon mesh to match physics world object
  51656. * @param impostor imposter to match
  51657. */
  51658. private _afterSoftStep;
  51659. /**
  51660. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51661. * @param impostor imposter to match
  51662. */
  51663. private _ropeStep;
  51664. /**
  51665. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51666. * @param impostor imposter to match
  51667. */
  51668. private _softbodyOrClothStep;
  51669. private _tmpVector;
  51670. private _tmpMatrix;
  51671. /**
  51672. * Applies an impulse on the imposter
  51673. * @param impostor imposter to apply impulse to
  51674. * @param force amount of force to be applied to the imposter
  51675. * @param contactPoint the location to apply the impulse on the imposter
  51676. */
  51677. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51678. /**
  51679. * Applies a force on the imposter
  51680. * @param impostor imposter to apply force
  51681. * @param force amount of force to be applied to the imposter
  51682. * @param contactPoint the location to apply the force on the imposter
  51683. */
  51684. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51685. /**
  51686. * Creates a physics body using the plugin
  51687. * @param impostor the imposter to create the physics body on
  51688. */
  51689. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51690. /**
  51691. * Removes the physics body from the imposter and disposes of the body's memory
  51692. * @param impostor imposter to remove the physics body from
  51693. */
  51694. removePhysicsBody(impostor: PhysicsImpostor): void;
  51695. /**
  51696. * Generates a joint
  51697. * @param impostorJoint the imposter joint to create the joint with
  51698. */
  51699. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51700. /**
  51701. * Removes a joint
  51702. * @param impostorJoint the imposter joint to remove the joint from
  51703. */
  51704. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51705. private _addMeshVerts;
  51706. /**
  51707. * Initialise the soft body vertices to match its object's (mesh) vertices
  51708. * Softbody vertices (nodes) are in world space and to match this
  51709. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51710. * @param impostor to create the softbody for
  51711. */
  51712. private _softVertexData;
  51713. /**
  51714. * Create an impostor's soft body
  51715. * @param impostor to create the softbody for
  51716. */
  51717. private _createSoftbody;
  51718. /**
  51719. * Create cloth for an impostor
  51720. * @param impostor to create the softbody for
  51721. */
  51722. private _createCloth;
  51723. /**
  51724. * Create rope for an impostor
  51725. * @param impostor to create the softbody for
  51726. */
  51727. private _createRope;
  51728. private _addHullVerts;
  51729. private _createShape;
  51730. /**
  51731. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51732. * @param impostor imposter containing the physics body and babylon object
  51733. */
  51734. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51735. /**
  51736. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51737. * @param impostor imposter containing the physics body and babylon object
  51738. * @param newPosition new position
  51739. * @param newRotation new rotation
  51740. */
  51741. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51742. /**
  51743. * If this plugin is supported
  51744. * @returns true if its supported
  51745. */
  51746. isSupported(): boolean;
  51747. /**
  51748. * Sets the linear velocity of the physics body
  51749. * @param impostor imposter to set the velocity on
  51750. * @param velocity velocity to set
  51751. */
  51752. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51753. /**
  51754. * Sets the angular velocity of the physics body
  51755. * @param impostor imposter to set the velocity on
  51756. * @param velocity velocity to set
  51757. */
  51758. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51759. /**
  51760. * gets the linear velocity
  51761. * @param impostor imposter to get linear velocity from
  51762. * @returns linear velocity
  51763. */
  51764. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51765. /**
  51766. * gets the angular velocity
  51767. * @param impostor imposter to get angular velocity from
  51768. * @returns angular velocity
  51769. */
  51770. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51771. /**
  51772. * Sets the mass of physics body
  51773. * @param impostor imposter to set the mass on
  51774. * @param mass mass to set
  51775. */
  51776. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51777. /**
  51778. * Gets the mass of the physics body
  51779. * @param impostor imposter to get the mass from
  51780. * @returns mass
  51781. */
  51782. getBodyMass(impostor: PhysicsImpostor): number;
  51783. /**
  51784. * Gets friction of the impostor
  51785. * @param impostor impostor to get friction from
  51786. * @returns friction value
  51787. */
  51788. getBodyFriction(impostor: PhysicsImpostor): number;
  51789. /**
  51790. * Sets friction of the impostor
  51791. * @param impostor impostor to set friction on
  51792. * @param friction friction value
  51793. */
  51794. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51795. /**
  51796. * Gets restitution of the impostor
  51797. * @param impostor impostor to get restitution from
  51798. * @returns restitution value
  51799. */
  51800. getBodyRestitution(impostor: PhysicsImpostor): number;
  51801. /**
  51802. * Sets resitution of the impostor
  51803. * @param impostor impostor to set resitution on
  51804. * @param restitution resitution value
  51805. */
  51806. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51807. /**
  51808. * Gets pressure inside the impostor
  51809. * @param impostor impostor to get pressure from
  51810. * @returns pressure value
  51811. */
  51812. getBodyPressure(impostor: PhysicsImpostor): number;
  51813. /**
  51814. * Sets pressure inside a soft body impostor
  51815. * Cloth and rope must remain 0 pressure
  51816. * @param impostor impostor to set pressure on
  51817. * @param pressure pressure value
  51818. */
  51819. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51820. /**
  51821. * Gets stiffness of the impostor
  51822. * @param impostor impostor to get stiffness from
  51823. * @returns pressure value
  51824. */
  51825. getBodyStiffness(impostor: PhysicsImpostor): number;
  51826. /**
  51827. * Sets stiffness of the impostor
  51828. * @param impostor impostor to set stiffness on
  51829. * @param stiffness stiffness value from 0 to 1
  51830. */
  51831. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51832. /**
  51833. * Gets velocityIterations of the impostor
  51834. * @param impostor impostor to get velocity iterations from
  51835. * @returns velocityIterations value
  51836. */
  51837. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51838. /**
  51839. * Sets velocityIterations of the impostor
  51840. * @param impostor impostor to set velocity iterations on
  51841. * @param velocityIterations velocityIterations value
  51842. */
  51843. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51844. /**
  51845. * Gets positionIterations of the impostor
  51846. * @param impostor impostor to get position iterations from
  51847. * @returns positionIterations value
  51848. */
  51849. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51850. /**
  51851. * Sets positionIterations of the impostor
  51852. * @param impostor impostor to set position on
  51853. * @param positionIterations positionIterations value
  51854. */
  51855. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51856. /**
  51857. * Append an anchor to a cloth object
  51858. * @param impostor is the cloth impostor to add anchor to
  51859. * @param otherImpostor is the rigid impostor to anchor to
  51860. * @param width ratio across width from 0 to 1
  51861. * @param height ratio up height from 0 to 1
  51862. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51863. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51864. */
  51865. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51866. /**
  51867. * Append an hook to a rope object
  51868. * @param impostor is the rope impostor to add hook to
  51869. * @param otherImpostor is the rigid impostor to hook to
  51870. * @param length ratio along the rope from 0 to 1
  51871. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51872. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51873. */
  51874. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51875. /**
  51876. * Sleeps the physics body and stops it from being active
  51877. * @param impostor impostor to sleep
  51878. */
  51879. sleepBody(impostor: PhysicsImpostor): void;
  51880. /**
  51881. * Activates the physics body
  51882. * @param impostor impostor to activate
  51883. */
  51884. wakeUpBody(impostor: PhysicsImpostor): void;
  51885. /**
  51886. * Updates the distance parameters of the joint
  51887. * @param joint joint to update
  51888. * @param maxDistance maximum distance of the joint
  51889. * @param minDistance minimum distance of the joint
  51890. */
  51891. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51892. /**
  51893. * Sets a motor on the joint
  51894. * @param joint joint to set motor on
  51895. * @param speed speed of the motor
  51896. * @param maxForce maximum force of the motor
  51897. * @param motorIndex index of the motor
  51898. */
  51899. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51900. /**
  51901. * Sets the motors limit
  51902. * @param joint joint to set limit on
  51903. * @param upperLimit upper limit
  51904. * @param lowerLimit lower limit
  51905. */
  51906. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51907. /**
  51908. * Syncs the position and rotation of a mesh with the impostor
  51909. * @param mesh mesh to sync
  51910. * @param impostor impostor to update the mesh with
  51911. */
  51912. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51913. /**
  51914. * Gets the radius of the impostor
  51915. * @param impostor impostor to get radius from
  51916. * @returns the radius
  51917. */
  51918. getRadius(impostor: PhysicsImpostor): number;
  51919. /**
  51920. * Gets the box size of the impostor
  51921. * @param impostor impostor to get box size from
  51922. * @param result the resulting box size
  51923. */
  51924. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51925. /**
  51926. * Disposes of the impostor
  51927. */
  51928. dispose(): void;
  51929. /**
  51930. * Does a raycast in the physics world
  51931. * @param from when should the ray start?
  51932. * @param to when should the ray end?
  51933. * @returns PhysicsRaycastResult
  51934. */
  51935. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51936. }
  51937. }
  51938. declare module "babylonjs/Probes/reflectionProbe" {
  51939. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51940. import { Vector3 } from "babylonjs/Maths/math";
  51941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51942. import { Nullable } from "babylonjs/types";
  51943. import { Scene } from "babylonjs/scene";
  51944. module "babylonjs/abstractScene" {
  51945. interface AbstractScene {
  51946. /**
  51947. * The list of reflection probes added to the scene
  51948. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51949. */
  51950. reflectionProbes: Array<ReflectionProbe>;
  51951. /**
  51952. * Removes the given reflection probe from this scene.
  51953. * @param toRemove The reflection probe to remove
  51954. * @returns The index of the removed reflection probe
  51955. */
  51956. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51957. /**
  51958. * Adds the given reflection probe to this scene.
  51959. * @param newReflectionProbe The reflection probe to add
  51960. */
  51961. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51962. }
  51963. }
  51964. /**
  51965. * Class used to generate realtime reflection / refraction cube textures
  51966. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51967. */
  51968. export class ReflectionProbe {
  51969. /** defines the name of the probe */
  51970. name: string;
  51971. private _scene;
  51972. private _renderTargetTexture;
  51973. private _projectionMatrix;
  51974. private _viewMatrix;
  51975. private _target;
  51976. private _add;
  51977. private _attachedMesh;
  51978. private _invertYAxis;
  51979. /** Gets or sets probe position (center of the cube map) */
  51980. position: Vector3;
  51981. /**
  51982. * Creates a new reflection probe
  51983. * @param name defines the name of the probe
  51984. * @param size defines the texture resolution (for each face)
  51985. * @param scene defines the hosting scene
  51986. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51987. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51988. */
  51989. constructor(
  51990. /** defines the name of the probe */
  51991. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51992. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51993. samples: number;
  51994. /** Gets or sets the refresh rate to use (on every frame by default) */
  51995. refreshRate: number;
  51996. /**
  51997. * Gets the hosting scene
  51998. * @returns a Scene
  51999. */
  52000. getScene(): Scene;
  52001. /** Gets the internal CubeTexture used to render to */
  52002. readonly cubeTexture: RenderTargetTexture;
  52003. /** Gets the list of meshes to render */
  52004. readonly renderList: Nullable<AbstractMesh[]>;
  52005. /**
  52006. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52007. * @param mesh defines the mesh to attach to
  52008. */
  52009. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52010. /**
  52011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52012. * @param renderingGroupId The rendering group id corresponding to its index
  52013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52014. */
  52015. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52016. /**
  52017. * Clean all associated resources
  52018. */
  52019. dispose(): void;
  52020. /**
  52021. * Converts the reflection probe information to a readable string for debug purpose.
  52022. * @param fullDetails Supports for multiple levels of logging within scene loading
  52023. * @returns the human readable reflection probe info
  52024. */
  52025. toString(fullDetails?: boolean): string;
  52026. /**
  52027. * Get the class name of the relfection probe.
  52028. * @returns "ReflectionProbe"
  52029. */
  52030. getClassName(): string;
  52031. /**
  52032. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52033. * @returns The JSON representation of the texture
  52034. */
  52035. serialize(): any;
  52036. /**
  52037. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52038. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52039. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52040. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52041. * @returns The parsed reflection probe if successful
  52042. */
  52043. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52044. }
  52045. }
  52046. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52047. /** @hidden */
  52048. export var _BabylonLoaderRegistered: boolean;
  52049. }
  52050. declare module "babylonjs/Loading/Plugins/index" {
  52051. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52052. }
  52053. declare module "babylonjs/Loading/index" {
  52054. export * from "babylonjs/Loading/loadingScreen";
  52055. export * from "babylonjs/Loading/Plugins/index";
  52056. export * from "babylonjs/Loading/sceneLoader";
  52057. export * from "babylonjs/Loading/sceneLoaderFlags";
  52058. }
  52059. declare module "babylonjs/Materials/Background/index" {
  52060. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52061. }
  52062. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52063. import { Scene } from "babylonjs/scene";
  52064. import { Color3 } from "babylonjs/Maths/math";
  52065. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52067. /**
  52068. * The Physically based simple base material of BJS.
  52069. *
  52070. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52071. * It is used as the base class for both the specGloss and metalRough conventions.
  52072. */
  52073. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52074. /**
  52075. * Number of Simultaneous lights allowed on the material.
  52076. */
  52077. maxSimultaneousLights: number;
  52078. /**
  52079. * If sets to true, disables all the lights affecting the material.
  52080. */
  52081. disableLighting: boolean;
  52082. /**
  52083. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52084. */
  52085. environmentTexture: BaseTexture;
  52086. /**
  52087. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52088. */
  52089. invertNormalMapX: boolean;
  52090. /**
  52091. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52092. */
  52093. invertNormalMapY: boolean;
  52094. /**
  52095. * Normal map used in the model.
  52096. */
  52097. normalTexture: BaseTexture;
  52098. /**
  52099. * Emissivie color used to self-illuminate the model.
  52100. */
  52101. emissiveColor: Color3;
  52102. /**
  52103. * Emissivie texture used to self-illuminate the model.
  52104. */
  52105. emissiveTexture: BaseTexture;
  52106. /**
  52107. * Occlusion Channel Strenght.
  52108. */
  52109. occlusionStrength: number;
  52110. /**
  52111. * Occlusion Texture of the material (adding extra occlusion effects).
  52112. */
  52113. occlusionTexture: BaseTexture;
  52114. /**
  52115. * Defines the alpha limits in alpha test mode.
  52116. */
  52117. alphaCutOff: number;
  52118. /**
  52119. * Gets the current double sided mode.
  52120. */
  52121. /**
  52122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52123. */
  52124. doubleSided: boolean;
  52125. /**
  52126. * Stores the pre-calculated light information of a mesh in a texture.
  52127. */
  52128. lightmapTexture: BaseTexture;
  52129. /**
  52130. * If true, the light map contains occlusion information instead of lighting info.
  52131. */
  52132. useLightmapAsShadowmap: boolean;
  52133. /**
  52134. * Instantiates a new PBRMaterial instance.
  52135. *
  52136. * @param name The material name
  52137. * @param scene The scene the material will be use in.
  52138. */
  52139. constructor(name: string, scene: Scene);
  52140. getClassName(): string;
  52141. }
  52142. }
  52143. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52144. import { Scene } from "babylonjs/scene";
  52145. import { Color3 } from "babylonjs/Maths/math";
  52146. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52147. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52148. /**
  52149. * The PBR material of BJS following the metal roughness convention.
  52150. *
  52151. * This fits to the PBR convention in the GLTF definition:
  52152. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52153. */
  52154. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52155. /**
  52156. * The base color has two different interpretations depending on the value of metalness.
  52157. * When the material is a metal, the base color is the specific measured reflectance value
  52158. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52159. * of the material.
  52160. */
  52161. baseColor: Color3;
  52162. /**
  52163. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52164. * well as opacity information in the alpha channel.
  52165. */
  52166. baseTexture: BaseTexture;
  52167. /**
  52168. * Specifies the metallic scalar value of the material.
  52169. * Can also be used to scale the metalness values of the metallic texture.
  52170. */
  52171. metallic: number;
  52172. /**
  52173. * Specifies the roughness scalar value of the material.
  52174. * Can also be used to scale the roughness values of the metallic texture.
  52175. */
  52176. roughness: number;
  52177. /**
  52178. * Texture containing both the metallic value in the B channel and the
  52179. * roughness value in the G channel to keep better precision.
  52180. */
  52181. metallicRoughnessTexture: BaseTexture;
  52182. /**
  52183. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52184. *
  52185. * @param name The material name
  52186. * @param scene The scene the material will be use in.
  52187. */
  52188. constructor(name: string, scene: Scene);
  52189. /**
  52190. * Return the currrent class name of the material.
  52191. */
  52192. getClassName(): string;
  52193. /**
  52194. * Makes a duplicate of the current material.
  52195. * @param name - name to use for the new material.
  52196. */
  52197. clone(name: string): PBRMetallicRoughnessMaterial;
  52198. /**
  52199. * Serialize the material to a parsable JSON object.
  52200. */
  52201. serialize(): any;
  52202. /**
  52203. * Parses a JSON object correponding to the serialize function.
  52204. */
  52205. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52206. }
  52207. }
  52208. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52209. import { Scene } from "babylonjs/scene";
  52210. import { Color3 } from "babylonjs/Maths/math";
  52211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52212. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52213. /**
  52214. * The PBR material of BJS following the specular glossiness convention.
  52215. *
  52216. * This fits to the PBR convention in the GLTF definition:
  52217. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52218. */
  52219. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52220. /**
  52221. * Specifies the diffuse color of the material.
  52222. */
  52223. diffuseColor: Color3;
  52224. /**
  52225. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52226. * channel.
  52227. */
  52228. diffuseTexture: BaseTexture;
  52229. /**
  52230. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52231. */
  52232. specularColor: Color3;
  52233. /**
  52234. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52235. */
  52236. glossiness: number;
  52237. /**
  52238. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52239. */
  52240. specularGlossinessTexture: BaseTexture;
  52241. /**
  52242. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52243. *
  52244. * @param name The material name
  52245. * @param scene The scene the material will be use in.
  52246. */
  52247. constructor(name: string, scene: Scene);
  52248. /**
  52249. * Return the currrent class name of the material.
  52250. */
  52251. getClassName(): string;
  52252. /**
  52253. * Makes a duplicate of the current material.
  52254. * @param name - name to use for the new material.
  52255. */
  52256. clone(name: string): PBRSpecularGlossinessMaterial;
  52257. /**
  52258. * Serialize the material to a parsable JSON object.
  52259. */
  52260. serialize(): any;
  52261. /**
  52262. * Parses a JSON object correponding to the serialize function.
  52263. */
  52264. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52265. }
  52266. }
  52267. declare module "babylonjs/Materials/PBR/index" {
  52268. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52269. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52270. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52271. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52272. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52273. }
  52274. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52275. import { Nullable } from "babylonjs/types";
  52276. import { Scene } from "babylonjs/scene";
  52277. import { Matrix } from "babylonjs/Maths/math";
  52278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52279. /**
  52280. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52281. * It can help converting any input color in a desired output one. This can then be used to create effects
  52282. * from sepia, black and white to sixties or futuristic rendering...
  52283. *
  52284. * The only supported format is currently 3dl.
  52285. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52286. */
  52287. export class ColorGradingTexture extends BaseTexture {
  52288. /**
  52289. * The current texture matrix. (will always be identity in color grading texture)
  52290. */
  52291. private _textureMatrix;
  52292. /**
  52293. * The texture URL.
  52294. */
  52295. url: string;
  52296. /**
  52297. * Empty line regex stored for GC.
  52298. */
  52299. private static _noneEmptyLineRegex;
  52300. private _engine;
  52301. /**
  52302. * Instantiates a ColorGradingTexture from the following parameters.
  52303. *
  52304. * @param url The location of the color gradind data (currently only supporting 3dl)
  52305. * @param scene The scene the texture will be used in
  52306. */
  52307. constructor(url: string, scene: Scene);
  52308. /**
  52309. * Returns the texture matrix used in most of the material.
  52310. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52311. */
  52312. getTextureMatrix(): Matrix;
  52313. /**
  52314. * Occurs when the file being loaded is a .3dl LUT file.
  52315. */
  52316. private load3dlTexture;
  52317. /**
  52318. * Starts the loading process of the texture.
  52319. */
  52320. private loadTexture;
  52321. /**
  52322. * Clones the color gradind texture.
  52323. */
  52324. clone(): ColorGradingTexture;
  52325. /**
  52326. * Called during delayed load for textures.
  52327. */
  52328. delayLoad(): void;
  52329. /**
  52330. * Parses a color grading texture serialized by Babylon.
  52331. * @param parsedTexture The texture information being parsedTexture
  52332. * @param scene The scene to load the texture in
  52333. * @param rootUrl The root url of the data assets to load
  52334. * @return A color gradind texture
  52335. */
  52336. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52337. /**
  52338. * Serializes the LUT texture to json format.
  52339. */
  52340. serialize(): any;
  52341. }
  52342. }
  52343. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52345. import { Scene } from "babylonjs/scene";
  52346. import { Nullable } from "babylonjs/types";
  52347. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52348. /**
  52349. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52350. */
  52351. export class EquiRectangularCubeTexture extends BaseTexture {
  52352. /** The six faces of the cube. */
  52353. private static _FacesMapping;
  52354. private _noMipmap;
  52355. private _onLoad;
  52356. private _onError;
  52357. /** The size of the cubemap. */
  52358. private _size;
  52359. /** The buffer of the image. */
  52360. private _buffer;
  52361. /** The width of the input image. */
  52362. private _width;
  52363. /** The height of the input image. */
  52364. private _height;
  52365. /** The URL to the image. */
  52366. url: string;
  52367. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52368. coordinatesMode: number;
  52369. /**
  52370. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52371. * @param url The location of the image
  52372. * @param scene The scene the texture will be used in
  52373. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52374. * @param noMipmap Forces to not generate the mipmap if true
  52375. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52376. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52377. * @param onLoad — defines a callback called when texture is loaded
  52378. * @param onError — defines a callback called if there is an error
  52379. */
  52380. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52381. /**
  52382. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52383. */
  52384. private loadImage;
  52385. /**
  52386. * Convert the image buffer into a cubemap and create a CubeTexture.
  52387. */
  52388. private loadTexture;
  52389. /**
  52390. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52391. * @param buffer The ArrayBuffer that should be converted.
  52392. * @returns The buffer as Float32Array.
  52393. */
  52394. private getFloat32ArrayFromArrayBuffer;
  52395. /**
  52396. * Get the current class name of the texture useful for serialization or dynamic coding.
  52397. * @returns "EquiRectangularCubeTexture"
  52398. */
  52399. getClassName(): string;
  52400. /**
  52401. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52402. * @returns A clone of the current EquiRectangularCubeTexture.
  52403. */
  52404. clone(): EquiRectangularCubeTexture;
  52405. }
  52406. }
  52407. declare module "babylonjs/Misc/tga" {
  52408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52409. /**
  52410. * Based on jsTGALoader - Javascript loader for TGA file
  52411. * By Vincent Thibault
  52412. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52413. */
  52414. export class TGATools {
  52415. private static _TYPE_INDEXED;
  52416. private static _TYPE_RGB;
  52417. private static _TYPE_GREY;
  52418. private static _TYPE_RLE_INDEXED;
  52419. private static _TYPE_RLE_RGB;
  52420. private static _TYPE_RLE_GREY;
  52421. private static _ORIGIN_MASK;
  52422. private static _ORIGIN_SHIFT;
  52423. private static _ORIGIN_BL;
  52424. private static _ORIGIN_BR;
  52425. private static _ORIGIN_UL;
  52426. private static _ORIGIN_UR;
  52427. /**
  52428. * Gets the header of a TGA file
  52429. * @param data defines the TGA data
  52430. * @returns the header
  52431. */
  52432. static GetTGAHeader(data: Uint8Array): any;
  52433. /**
  52434. * Uploads TGA content to a Babylon Texture
  52435. * @hidden
  52436. */
  52437. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52438. /** @hidden */
  52439. 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;
  52440. /** @hidden */
  52441. 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;
  52442. /** @hidden */
  52443. 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;
  52444. /** @hidden */
  52445. 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;
  52446. /** @hidden */
  52447. 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;
  52448. /** @hidden */
  52449. 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;
  52450. }
  52451. }
  52452. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52453. import { Nullable } from "babylonjs/types";
  52454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52455. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52456. /**
  52457. * Implementation of the TGA Texture Loader.
  52458. * @hidden
  52459. */
  52460. export class _TGATextureLoader implements IInternalTextureLoader {
  52461. /**
  52462. * Defines wether the loader supports cascade loading the different faces.
  52463. */
  52464. readonly supportCascades: boolean;
  52465. /**
  52466. * This returns if the loader support the current file information.
  52467. * @param extension defines the file extension of the file being loaded
  52468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52469. * @param fallback defines the fallback internal texture if any
  52470. * @param isBase64 defines whether the texture is encoded as a base64
  52471. * @param isBuffer defines whether the texture data are stored as a buffer
  52472. * @returns true if the loader can load the specified file
  52473. */
  52474. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52475. /**
  52476. * Transform the url before loading if required.
  52477. * @param rootUrl the url of the texture
  52478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52479. * @returns the transformed texture
  52480. */
  52481. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52482. /**
  52483. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52484. * @param rootUrl the url of the texture
  52485. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52486. * @returns the fallback texture
  52487. */
  52488. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52489. /**
  52490. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52491. * @param data contains the texture data
  52492. * @param texture defines the BabylonJS internal texture
  52493. * @param createPolynomials will be true if polynomials have been requested
  52494. * @param onLoad defines the callback to trigger once the texture is ready
  52495. * @param onError defines the callback to trigger in case of error
  52496. */
  52497. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52498. /**
  52499. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52500. * @param data contains the texture data
  52501. * @param texture defines the BabylonJS internal texture
  52502. * @param callback defines the method to call once ready to upload
  52503. */
  52504. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52505. }
  52506. }
  52507. declare module "babylonjs/Misc/basis" {
  52508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52509. /**
  52510. * Info about the .basis files
  52511. */
  52512. class BasisFileInfo {
  52513. /**
  52514. * If the file has alpha
  52515. */
  52516. hasAlpha: boolean;
  52517. /**
  52518. * Info about each image of the basis file
  52519. */
  52520. images: Array<{
  52521. levels: Array<{
  52522. width: number;
  52523. height: number;
  52524. transcodedPixels: ArrayBufferView;
  52525. }>;
  52526. }>;
  52527. }
  52528. /**
  52529. * Result of transcoding a basis file
  52530. */
  52531. class TranscodeResult {
  52532. /**
  52533. * Info about the .basis file
  52534. */
  52535. fileInfo: BasisFileInfo;
  52536. /**
  52537. * Format to use when loading the file
  52538. */
  52539. format: number;
  52540. }
  52541. /**
  52542. * Configuration options for the Basis transcoder
  52543. */
  52544. export class BasisTranscodeConfiguration {
  52545. /**
  52546. * Supported compression formats used to determine the supported output format of the transcoder
  52547. */
  52548. supportedCompressionFormats?: {
  52549. /**
  52550. * etc1 compression format
  52551. */
  52552. etc1?: boolean;
  52553. /**
  52554. * s3tc compression format
  52555. */
  52556. s3tc?: boolean;
  52557. /**
  52558. * pvrtc compression format
  52559. */
  52560. pvrtc?: boolean;
  52561. /**
  52562. * etc2 compression format
  52563. */
  52564. etc2?: boolean;
  52565. };
  52566. /**
  52567. * If mipmap levels should be loaded for transcoded images (Default: true)
  52568. */
  52569. loadMipmapLevels?: boolean;
  52570. /**
  52571. * Index of a single image to load (Default: all images)
  52572. */
  52573. loadSingleImage?: number;
  52574. }
  52575. /**
  52576. * Used to load .Basis files
  52577. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52578. */
  52579. export class BasisTools {
  52580. private static _IgnoreSupportedFormats;
  52581. /**
  52582. * URL to use when loading the basis transcoder
  52583. */
  52584. static JSModuleURL: string;
  52585. /**
  52586. * URL to use when loading the wasm module for the transcoder
  52587. */
  52588. static WasmModuleURL: string;
  52589. /**
  52590. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52591. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52592. * @returns internal format corresponding to the Basis format
  52593. */
  52594. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52595. private static _WorkerPromise;
  52596. private static _Worker;
  52597. private static _actionId;
  52598. private static _CreateWorkerAsync;
  52599. /**
  52600. * Transcodes a loaded image file to compressed pixel data
  52601. * @param imageData image data to transcode
  52602. * @param config configuration options for the transcoding
  52603. * @returns a promise resulting in the transcoded image
  52604. */
  52605. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52606. /**
  52607. * Loads a texture from the transcode result
  52608. * @param texture texture load to
  52609. * @param transcodeResult the result of transcoding the basis file to load from
  52610. */
  52611. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52612. }
  52613. }
  52614. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52615. import { Nullable } from "babylonjs/types";
  52616. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52617. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52618. /**
  52619. * Loader for .basis file format
  52620. */
  52621. export class _BasisTextureLoader implements IInternalTextureLoader {
  52622. /**
  52623. * Defines whether the loader supports cascade loading the different faces.
  52624. */
  52625. readonly supportCascades: boolean;
  52626. /**
  52627. * This returns if the loader support the current file information.
  52628. * @param extension defines the file extension of the file being loaded
  52629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52630. * @param fallback defines the fallback internal texture if any
  52631. * @param isBase64 defines whether the texture is encoded as a base64
  52632. * @param isBuffer defines whether the texture data are stored as a buffer
  52633. * @returns true if the loader can load the specified file
  52634. */
  52635. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52636. /**
  52637. * Transform the url before loading if required.
  52638. * @param rootUrl the url of the texture
  52639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52640. * @returns the transformed texture
  52641. */
  52642. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52643. /**
  52644. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52645. * @param rootUrl the url of the texture
  52646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52647. * @returns the fallback texture
  52648. */
  52649. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52650. /**
  52651. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52652. * @param data contains the texture data
  52653. * @param texture defines the BabylonJS internal texture
  52654. * @param createPolynomials will be true if polynomials have been requested
  52655. * @param onLoad defines the callback to trigger once the texture is ready
  52656. * @param onError defines the callback to trigger in case of error
  52657. */
  52658. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52659. /**
  52660. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52661. * @param data contains the texture data
  52662. * @param texture defines the BabylonJS internal texture
  52663. * @param callback defines the method to call once ready to upload
  52664. */
  52665. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52666. }
  52667. }
  52668. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52669. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52670. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52671. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52672. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52673. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52674. }
  52675. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52676. import { Scene } from "babylonjs/scene";
  52677. import { Texture } from "babylonjs/Materials/Textures/texture";
  52678. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52679. /**
  52680. * 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.
  52681. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52682. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52683. */
  52684. export class CustomProceduralTexture extends ProceduralTexture {
  52685. private _animate;
  52686. private _time;
  52687. private _config;
  52688. private _texturePath;
  52689. /**
  52690. * Instantiates a new Custom Procedural Texture.
  52691. * 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.
  52692. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52693. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52694. * @param name Define the name of the texture
  52695. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52696. * @param size Define the size of the texture to create
  52697. * @param scene Define the scene the texture belongs to
  52698. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52699. * @param generateMipMaps Define if the texture should creates mip maps or not
  52700. */
  52701. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52702. private _loadJson;
  52703. /**
  52704. * Is the texture ready to be used ? (rendered at least once)
  52705. * @returns true if ready, otherwise, false.
  52706. */
  52707. isReady(): boolean;
  52708. /**
  52709. * Render the texture to its associated render target.
  52710. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52711. */
  52712. render(useCameraPostProcess?: boolean): void;
  52713. /**
  52714. * Update the list of dependant textures samplers in the shader.
  52715. */
  52716. updateTextures(): void;
  52717. /**
  52718. * Update the uniform values of the procedural texture in the shader.
  52719. */
  52720. updateShaderUniforms(): void;
  52721. /**
  52722. * Define if the texture animates or not.
  52723. */
  52724. animate: boolean;
  52725. }
  52726. }
  52727. declare module "babylonjs/Shaders/noise.fragment" {
  52728. /** @hidden */
  52729. export var noisePixelShader: {
  52730. name: string;
  52731. shader: string;
  52732. };
  52733. }
  52734. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52735. import { Nullable } from "babylonjs/types";
  52736. import { Scene } from "babylonjs/scene";
  52737. import { Texture } from "babylonjs/Materials/Textures/texture";
  52738. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52739. import "babylonjs/Shaders/noise.fragment";
  52740. /**
  52741. * Class used to generate noise procedural textures
  52742. */
  52743. export class NoiseProceduralTexture extends ProceduralTexture {
  52744. private _time;
  52745. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52746. brightness: number;
  52747. /** Defines the number of octaves to process */
  52748. octaves: number;
  52749. /** Defines the level of persistence (0.8 by default) */
  52750. persistence: number;
  52751. /** Gets or sets animation speed factor (default is 1) */
  52752. animationSpeedFactor: number;
  52753. /**
  52754. * Creates a new NoiseProceduralTexture
  52755. * @param name defines the name fo the texture
  52756. * @param size defines the size of the texture (default is 256)
  52757. * @param scene defines the hosting scene
  52758. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52759. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52760. */
  52761. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52762. private _updateShaderUniforms;
  52763. protected _getDefines(): string;
  52764. /** Generate the current state of the procedural texture */
  52765. render(useCameraPostProcess?: boolean): void;
  52766. /**
  52767. * Serializes this noise procedural texture
  52768. * @returns a serialized noise procedural texture object
  52769. */
  52770. serialize(): any;
  52771. /**
  52772. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52773. * @param parsedTexture defines parsed texture data
  52774. * @param scene defines the current scene
  52775. * @param rootUrl defines the root URL containing noise procedural texture information
  52776. * @returns a parsed NoiseProceduralTexture
  52777. */
  52778. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52779. }
  52780. }
  52781. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52782. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52783. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52784. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52785. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52786. }
  52787. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52788. import { Nullable } from "babylonjs/types";
  52789. import { Scene } from "babylonjs/scene";
  52790. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52791. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52792. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52793. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52794. /**
  52795. * Raw cube texture where the raw buffers are passed in
  52796. */
  52797. export class RawCubeTexture extends CubeTexture {
  52798. /**
  52799. * Creates a cube texture where the raw buffers are passed in.
  52800. * @param scene defines the scene the texture is attached to
  52801. * @param data defines the array of data to use to create each face
  52802. * @param size defines the size of the textures
  52803. * @param format defines the format of the data
  52804. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52805. * @param generateMipMaps defines if the engine should generate the mip levels
  52806. * @param invertY defines if data must be stored with Y axis inverted
  52807. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52808. * @param compression defines the compression used (null by default)
  52809. */
  52810. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52811. /**
  52812. * Updates the raw cube texture.
  52813. * @param data defines the data to store
  52814. * @param format defines the data format
  52815. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52816. * @param invertY defines if data must be stored with Y axis inverted
  52817. * @param compression defines the compression used (null by default)
  52818. * @param level defines which level of the texture to update
  52819. */
  52820. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52821. /**
  52822. * Updates a raw cube texture with RGBD encoded data.
  52823. * @param data defines the array of data [mipmap][face] to use to create each face
  52824. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52827. * @returns a promsie that resolves when the operation is complete
  52828. */
  52829. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52830. /**
  52831. * Clones the raw cube texture.
  52832. * @return a new cube texture
  52833. */
  52834. clone(): CubeTexture;
  52835. /** @hidden */
  52836. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52837. }
  52838. }
  52839. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52840. import { Scene } from "babylonjs/scene";
  52841. import { Texture } from "babylonjs/Materials/Textures/texture";
  52842. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52843. /**
  52844. * Class used to store 3D textures containing user data
  52845. */
  52846. export class RawTexture3D extends Texture {
  52847. /** Gets or sets the texture format to use */
  52848. format: number;
  52849. private _engine;
  52850. /**
  52851. * Create a new RawTexture3D
  52852. * @param data defines the data of the texture
  52853. * @param width defines the width of the texture
  52854. * @param height defines the height of the texture
  52855. * @param depth defines the depth of the texture
  52856. * @param format defines the texture format to use
  52857. * @param scene defines the hosting scene
  52858. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52859. * @param invertY defines if texture must be stored with Y axis inverted
  52860. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52861. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52862. */
  52863. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52864. /** Gets or sets the texture format to use */
  52865. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52866. /**
  52867. * Update the texture with new data
  52868. * @param data defines the data to store in the texture
  52869. */
  52870. update(data: ArrayBufferView): void;
  52871. }
  52872. }
  52873. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52874. import { Scene } from "babylonjs/scene";
  52875. import { Plane } from "babylonjs/Maths/math";
  52876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52877. /**
  52878. * Creates a refraction texture used by refraction channel of the standard material.
  52879. * It is like a mirror but to see through a material.
  52880. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52881. */
  52882. export class RefractionTexture extends RenderTargetTexture {
  52883. /**
  52884. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52885. * 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.
  52886. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52887. */
  52888. refractionPlane: Plane;
  52889. /**
  52890. * Define how deep under the surface we should see.
  52891. */
  52892. depth: number;
  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. * @param name Define the texture name
  52898. * @param size Define the size of the underlying texture
  52899. * @param scene Define the scene the refraction belongs to
  52900. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52901. */
  52902. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52903. /**
  52904. * Clone the refraction texture.
  52905. * @returns the cloned texture
  52906. */
  52907. clone(): RefractionTexture;
  52908. /**
  52909. * Serialize the texture to a JSON representation you could use in Parse later on
  52910. * @returns the serialized JSON representation
  52911. */
  52912. serialize(): any;
  52913. }
  52914. }
  52915. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52916. import { Nullable } from "babylonjs/types";
  52917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52918. import { Matrix } from "babylonjs/Maths/math";
  52919. import { Engine } from "babylonjs/Engines/engine";
  52920. import { Scene } from "babylonjs/scene";
  52921. /**
  52922. * Defines the options related to the creation of an HtmlElementTexture
  52923. */
  52924. export interface IHtmlElementTextureOptions {
  52925. /**
  52926. * Defines wether mip maps should be created or not.
  52927. */
  52928. generateMipMaps?: boolean;
  52929. /**
  52930. * Defines the sampling mode of the texture.
  52931. */
  52932. samplingMode?: number;
  52933. /**
  52934. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52935. */
  52936. engine: Nullable<Engine>;
  52937. /**
  52938. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52939. */
  52940. scene: Nullable<Scene>;
  52941. }
  52942. /**
  52943. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52944. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52945. * is automatically managed.
  52946. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52947. * in your application.
  52948. *
  52949. * As the update is not automatic, you need to call them manually.
  52950. */
  52951. export class HtmlElementTexture extends BaseTexture {
  52952. /**
  52953. * The texture URL.
  52954. */
  52955. element: HTMLVideoElement | HTMLCanvasElement;
  52956. private static readonly DefaultOptions;
  52957. private _textureMatrix;
  52958. private _engine;
  52959. private _isVideo;
  52960. private _generateMipMaps;
  52961. private _samplingMode;
  52962. /**
  52963. * Instantiates a HtmlElementTexture from the following parameters.
  52964. *
  52965. * @param name Defines the name of the texture
  52966. * @param element Defines the video or canvas the texture is filled with
  52967. * @param options Defines the other none mandatory texture creation options
  52968. */
  52969. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52970. private _createInternalTexture;
  52971. /**
  52972. * Returns the texture matrix used in most of the material.
  52973. */
  52974. getTextureMatrix(): Matrix;
  52975. /**
  52976. * Updates the content of the texture.
  52977. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52978. */
  52979. update(invertY?: Nullable<boolean>): void;
  52980. }
  52981. }
  52982. declare module "babylonjs/Materials/Textures/index" {
  52983. export * from "babylonjs/Materials/Textures/baseTexture";
  52984. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52985. export * from "babylonjs/Materials/Textures/cubeTexture";
  52986. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52987. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52988. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52989. export * from "babylonjs/Materials/Textures/internalTexture";
  52990. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52991. export * from "babylonjs/Materials/Textures/Loaders/index";
  52992. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52993. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52994. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52995. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52996. export * from "babylonjs/Materials/Textures/rawTexture";
  52997. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52998. export * from "babylonjs/Materials/Textures/refractionTexture";
  52999. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53000. export * from "babylonjs/Materials/Textures/texture";
  53001. export * from "babylonjs/Materials/Textures/videoTexture";
  53002. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53003. }
  53004. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53005. /**
  53006. * Enum used to define the target of a block
  53007. */
  53008. export enum NodeMaterialBlockTargets {
  53009. /** Vertex shader */
  53010. Vertex = 1,
  53011. /** Fragment shader */
  53012. Fragment = 2,
  53013. /** Vertex and Fragment */
  53014. VertexAndFragment = 3
  53015. }
  53016. }
  53017. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53018. /**
  53019. * Defines the kind of connection point for node based material
  53020. */
  53021. export enum NodeMaterialBlockConnectionPointTypes {
  53022. /** Float */
  53023. Float = 1,
  53024. /** Int */
  53025. Int = 2,
  53026. /** Vector2 */
  53027. Vector2 = 4,
  53028. /** Vector3 */
  53029. Vector3 = 8,
  53030. /** Vector4 */
  53031. Vector4 = 16,
  53032. /** Color3 */
  53033. Color3 = 32,
  53034. /** Color4 */
  53035. Color4 = 64,
  53036. /** Matrix */
  53037. Matrix = 128,
  53038. /** Texture */
  53039. Texture = 256,
  53040. /** Texture3D */
  53041. Texture3D = 512,
  53042. /** Vector3 or Color3 */
  53043. Vector3OrColor3 = 40,
  53044. /** Vector3 or Vector4 */
  53045. Vector3OrVector4 = 24,
  53046. /** Vector4 or Color4 */
  53047. Vector4OrColor4 = 80,
  53048. /** Color3 or Color4 */
  53049. Color3OrColor4 = 96,
  53050. /** Vector3 or Color3 */
  53051. Vector3OrColor3OrVector4OrColor4 = 120,
  53052. /** Detect type based on connection */
  53053. AutoDetect = 1024,
  53054. /** Output type that will be defined by input type */
  53055. BasedOnInput = 2048,
  53056. /** Light */
  53057. Light = 4096
  53058. }
  53059. }
  53060. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  53061. /**
  53062. * Enum used to define well known values e.g. values automatically provided by the system
  53063. */
  53064. export enum NodeMaterialWellKnownValues {
  53065. /** World */
  53066. World = 1,
  53067. /** View */
  53068. View = 2,
  53069. /** Projection */
  53070. Projection = 3,
  53071. /** ViewProjection */
  53072. ViewProjection = 4,
  53073. /** WorldView */
  53074. WorldView = 5,
  53075. /** WorldViewProjection */
  53076. WorldViewProjection = 6,
  53077. /** CameraPosition */
  53078. CameraPosition = 7,
  53079. /** Will be filled by the block itself */
  53080. Automatic = 8
  53081. }
  53082. }
  53083. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53084. /**
  53085. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53086. */
  53087. export enum NodeMaterialBlockConnectionPointMode {
  53088. /** Value is an uniform */
  53089. Uniform = 0,
  53090. /** Value is a mesh attribute */
  53091. Attribute = 1,
  53092. /** Value is a varying between vertex and fragment shaders */
  53093. Varying = 2,
  53094. /** Mode is undefined */
  53095. Undefined = 3
  53096. }
  53097. }
  53098. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53101. /**
  53102. * Class used to store shared data between 2 NodeMaterialBuildState
  53103. */
  53104. export class NodeMaterialBuildStateSharedData {
  53105. /**
  53106. * Gets the list of emitted varyings
  53107. */
  53108. varyings: string[];
  53109. /**
  53110. * Gets the varying declaration string
  53111. */
  53112. varyingDeclaration: string;
  53113. /**
  53114. * Uniform connection points
  53115. */
  53116. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53117. /**
  53118. * Bindable blocks (Blocks that need to set data to the effect)
  53119. */
  53120. bindableBlocks: NodeMaterialBlock[];
  53121. /**
  53122. * List of blocks that can provide a compilation fallback
  53123. */
  53124. blocksWithFallbacks: NodeMaterialBlock[];
  53125. /**
  53126. * List of blocks that can provide a define update
  53127. */
  53128. blocksWithDefines: NodeMaterialBlock[];
  53129. /**
  53130. * List of blocks that can provide a repeatable content
  53131. */
  53132. repeatableContentBlocks: NodeMaterialBlock[];
  53133. /**
  53134. * List of blocks that can provide a dynamic list of uniforms
  53135. */
  53136. dynamicUniformBlocks: NodeMaterialBlock[];
  53137. /**
  53138. * List of blocks that can block the isReady function for the material
  53139. */
  53140. blockingBlocks: NodeMaterialBlock[];
  53141. /**
  53142. * Build Id used to avoid multiple recompilations
  53143. */
  53144. buildId: number;
  53145. /** List of emitted variables */
  53146. variableNames: {
  53147. [key: string]: number;
  53148. };
  53149. /** List of emitted defines */
  53150. defineNames: {
  53151. [key: string]: number;
  53152. };
  53153. /** Should emit comments? */
  53154. emitComments: boolean;
  53155. /** Emit build activity */
  53156. verbose: boolean;
  53157. /**
  53158. * Gets the compilation hints emitted at compilation time
  53159. */
  53160. hints: {
  53161. needWorldViewMatrix: boolean;
  53162. needWorldViewProjectionMatrix: boolean;
  53163. needAlphaBlending: boolean;
  53164. needAlphaTesting: boolean;
  53165. };
  53166. /**
  53167. * List of compilation checks
  53168. */
  53169. checks: {
  53170. emitVertex: boolean;
  53171. emitFragment: boolean;
  53172. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53173. };
  53174. /** Creates a new shared data */
  53175. constructor();
  53176. /**
  53177. * Emits console errors and exceptions if there is a failing check
  53178. */
  53179. emitErrors(): void;
  53180. }
  53181. }
  53182. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53184. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53185. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53186. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53187. import { Nullable } from "babylonjs/types";
  53188. /**
  53189. * Class used to store node based material build state
  53190. */
  53191. export class NodeMaterialBuildState {
  53192. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53193. supportUniformBuffers: boolean;
  53194. /**
  53195. * Gets the list of emitted attributes
  53196. */
  53197. attributes: string[];
  53198. /**
  53199. * Gets the list of emitted uniforms
  53200. */
  53201. uniforms: string[];
  53202. /**
  53203. * Gets the list of emitted uniform buffers
  53204. */
  53205. uniformBuffers: string[];
  53206. /**
  53207. * Gets the list of emitted samplers
  53208. */
  53209. samplers: string[];
  53210. /**
  53211. * Gets the list of emitted functions
  53212. */
  53213. functions: {
  53214. [key: string]: string;
  53215. };
  53216. /**
  53217. * Gets the target of the compilation state
  53218. */
  53219. target: NodeMaterialBlockTargets;
  53220. /**
  53221. * Gets the list of emitted counters
  53222. */
  53223. counters: {
  53224. [key: string]: number;
  53225. };
  53226. /**
  53227. * Shared data between multiple NodeMaterialBuildState instances
  53228. */
  53229. sharedData: NodeMaterialBuildStateSharedData;
  53230. /** @hidden */
  53231. _vertexState: NodeMaterialBuildState;
  53232. private _attributeDeclaration;
  53233. private _uniformDeclaration;
  53234. private _samplerDeclaration;
  53235. private _varyingTransfer;
  53236. private _repeatableContentAnchorIndex;
  53237. /** @hidden */
  53238. _builtCompilationString: string;
  53239. /**
  53240. * Gets the emitted compilation strings
  53241. */
  53242. compilationString: string;
  53243. /**
  53244. * Finalize the compilation strings
  53245. * @param state defines the current compilation state
  53246. */
  53247. finalize(state: NodeMaterialBuildState): void;
  53248. /** @hidden */
  53249. readonly _repeatableContentAnchor: string;
  53250. /** @hidden */
  53251. _getFreeVariableName(prefix: string): string;
  53252. /** @hidden */
  53253. _getFreeDefineName(prefix: string): string;
  53254. /** @hidden */
  53255. _excludeVariableName(name: string): void;
  53256. /** @hidden */
  53257. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53258. /** @hidden */
  53259. _emitFunction(name: string, code: string, comments: string): void;
  53260. /** @hidden */
  53261. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53262. replaceStrings?: {
  53263. search: RegExp;
  53264. replace: string;
  53265. }[];
  53266. repeatKey?: string;
  53267. }): string;
  53268. /** @hidden */
  53269. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53270. repeatKey?: string;
  53271. removeAttributes?: boolean;
  53272. removeUniforms?: boolean;
  53273. removeVaryings?: boolean;
  53274. removeIfDef?: boolean;
  53275. replaceStrings?: {
  53276. search: RegExp;
  53277. replace: string;
  53278. }[];
  53279. }, storeKey?: string): void;
  53280. /** @hidden */
  53281. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53282. private _emitDefine;
  53283. /** @hidden */
  53284. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53285. }
  53286. }
  53287. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53289. /**
  53290. * Root class for all node material optimizers
  53291. */
  53292. export class NodeMaterialOptimizer {
  53293. /**
  53294. * Function used to optimize a NodeMaterial graph
  53295. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53296. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53297. */
  53298. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53299. }
  53300. }
  53301. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53305. /**
  53306. * Block used to transform a vector4 with a matrix
  53307. */
  53308. export class Vector4TransformBlock extends NodeMaterialBlock {
  53309. /**
  53310. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53311. */
  53312. complementW: number;
  53313. /**
  53314. * Creates a new Vector4TransformBlock
  53315. * @param name defines the block name
  53316. */
  53317. constructor(name: string);
  53318. /**
  53319. * Gets the current class name
  53320. * @returns the class name
  53321. */
  53322. getClassName(): string;
  53323. /**
  53324. * Gets the vector input
  53325. */
  53326. readonly vector: NodeMaterialConnectionPoint;
  53327. /**
  53328. * Gets the output component
  53329. */
  53330. readonly output: NodeMaterialConnectionPoint;
  53331. /**
  53332. * Gets the matrix transform input
  53333. */
  53334. readonly transform: NodeMaterialConnectionPoint;
  53335. protected _buildBlock(state: NodeMaterialBuildState): this;
  53336. }
  53337. }
  53338. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53339. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53340. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53341. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53342. /**
  53343. * Block used to output the vertex position
  53344. */
  53345. export class VertexOutputBlock extends NodeMaterialBlock {
  53346. /**
  53347. * Creates a new VertexOutputBlock
  53348. * @param name defines the block name
  53349. */
  53350. constructor(name: string);
  53351. /**
  53352. * Gets the current class name
  53353. * @returns the class name
  53354. */
  53355. getClassName(): string;
  53356. /**
  53357. * Gets the vector input component
  53358. */
  53359. readonly vector: NodeMaterialConnectionPoint;
  53360. protected _buildBlock(state: NodeMaterialBuildState): this;
  53361. }
  53362. }
  53363. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53367. /**
  53368. * Block used to output the final color
  53369. */
  53370. export class FragmentOutputBlock extends NodeMaterialBlock {
  53371. /**
  53372. * Gets or sets a boolean indicating if this block will output an alpha value
  53373. */
  53374. alphaBlendingEnabled: boolean;
  53375. /**
  53376. * Create a new FragmentOutputBlock
  53377. * @param name defines the block name
  53378. */
  53379. constructor(name: string);
  53380. /**
  53381. * Gets the current class name
  53382. * @returns the class name
  53383. */
  53384. getClassName(): string;
  53385. /**
  53386. * Gets the color input component
  53387. */
  53388. readonly color: NodeMaterialConnectionPoint;
  53389. protected _buildBlock(state: NodeMaterialBuildState): this;
  53390. }
  53391. }
  53392. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53394. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53395. import { Scene } from "babylonjs/scene";
  53396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53397. import { Matrix } from "babylonjs/Maths/math";
  53398. import { Mesh } from "babylonjs/Meshes/mesh";
  53399. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53400. import { Observable } from "babylonjs/Misc/observable";
  53401. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53402. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53403. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53404. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53405. import { Nullable } from "babylonjs/types";
  53406. /**
  53407. * Interface used to configure the node material editor
  53408. */
  53409. export interface INodeMaterialEditorOptions {
  53410. /** Define the URl to load node editor script */
  53411. editorURL?: string;
  53412. }
  53413. /** @hidden */
  53414. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53415. /** BONES */
  53416. NUM_BONE_INFLUENCERS: number;
  53417. BonesPerMesh: number;
  53418. BONETEXTURE: boolean;
  53419. /** MORPH TARGETS */
  53420. MORPHTARGETS: boolean;
  53421. MORPHTARGETS_NORMAL: boolean;
  53422. MORPHTARGETS_TANGENT: boolean;
  53423. MORPHTARGETS_UV: boolean;
  53424. NUM_MORPH_INFLUENCERS: number;
  53425. /** IMAGE PROCESSING */
  53426. IMAGEPROCESSING: boolean;
  53427. VIGNETTE: boolean;
  53428. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53429. VIGNETTEBLENDMODEOPAQUE: boolean;
  53430. TONEMAPPING: boolean;
  53431. TONEMAPPING_ACES: boolean;
  53432. CONTRAST: boolean;
  53433. EXPOSURE: boolean;
  53434. COLORCURVES: boolean;
  53435. COLORGRADING: boolean;
  53436. COLORGRADING3D: boolean;
  53437. SAMPLER3DGREENDEPTH: boolean;
  53438. SAMPLER3DBGRMAP: boolean;
  53439. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53440. constructor();
  53441. setValue(name: string, value: boolean): void;
  53442. }
  53443. /**
  53444. * Class used to configure NodeMaterial
  53445. */
  53446. export interface INodeMaterialOptions {
  53447. /**
  53448. * Defines if blocks should emit comments
  53449. */
  53450. emitComments: boolean;
  53451. }
  53452. /**
  53453. * Class used to create a node based material built by assembling shader blocks
  53454. */
  53455. export class NodeMaterial extends PushMaterial {
  53456. private _options;
  53457. private _vertexCompilationState;
  53458. private _fragmentCompilationState;
  53459. private _sharedData;
  53460. private _buildId;
  53461. private _buildWasSuccessful;
  53462. private _cachedWorldViewMatrix;
  53463. private _cachedWorldViewProjectionMatrix;
  53464. private _textureConnectionPoints;
  53465. private _optimizers;
  53466. /** Define the URl to load node editor script */
  53467. static EditorURL: string;
  53468. private BJSNODEMATERIALEDITOR;
  53469. /** Get the inspector from bundle or global */
  53470. private _getGlobalNodeMaterialEditor;
  53471. /**
  53472. * Defines the maximum number of lights that can be used in the material
  53473. */
  53474. maxSimultaneousLights: number;
  53475. /**
  53476. * Observable raised when the material is built
  53477. */
  53478. onBuildObservable: Observable<NodeMaterial>;
  53479. /**
  53480. * Gets or sets the root nodes of the material vertex shader
  53481. */
  53482. _vertexOutputNodes: NodeMaterialBlock[];
  53483. /**
  53484. * Gets or sets the root nodes of the material fragment (pixel) shader
  53485. */
  53486. _fragmentOutputNodes: NodeMaterialBlock[];
  53487. /** Gets or sets options to control the node material overall behavior */
  53488. options: INodeMaterialOptions;
  53489. /**
  53490. * Default configuration related to image processing available in the standard Material.
  53491. */
  53492. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53493. /**
  53494. * Gets the image processing configuration used either in this material.
  53495. */
  53496. /**
  53497. * Sets the Default image processing configuration used either in the this material.
  53498. *
  53499. * If sets to null, the scene one is in use.
  53500. */
  53501. imageProcessingConfiguration: ImageProcessingConfiguration;
  53502. /**
  53503. * Create a new node based material
  53504. * @param name defines the material name
  53505. * @param scene defines the hosting scene
  53506. * @param options defines creation option
  53507. */
  53508. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53509. /**
  53510. * Gets the current class name of the material e.g. "NodeMaterial"
  53511. * @returns the class name
  53512. */
  53513. getClassName(): string;
  53514. /**
  53515. * Keep track of the image processing observer to allow dispose and replace.
  53516. */
  53517. private _imageProcessingObserver;
  53518. /**
  53519. * Attaches a new image processing configuration to the Standard Material.
  53520. * @param configuration
  53521. */
  53522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53523. /**
  53524. * Adds a new optimizer to the list of optimizers
  53525. * @param optimizer defines the optimizers to add
  53526. * @returns the current material
  53527. */
  53528. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53529. /**
  53530. * Remove an optimizer from the list of optimizers
  53531. * @param optimizer defines the optimizers to remove
  53532. * @returns the current material
  53533. */
  53534. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53535. /**
  53536. * Add a new block to the list of output nodes
  53537. * @param node defines the node to add
  53538. * @returns the current material
  53539. */
  53540. addOutputNode(node: NodeMaterialBlock): this;
  53541. /**
  53542. * Remove a block from the list of root nodes
  53543. * @param node defines the node to remove
  53544. * @returns the current material
  53545. */
  53546. removeOutputNode(node: NodeMaterialBlock): this;
  53547. private _addVertexOutputNode;
  53548. private _removeVertexOutputNode;
  53549. private _addFragmentOutputNode;
  53550. private _removeFragmentOutputNode;
  53551. /**
  53552. * Specifies if the material will require alpha blending
  53553. * @returns a boolean specifying if alpha blending is needed
  53554. */
  53555. needAlphaBlending(): boolean;
  53556. /**
  53557. * Specifies if this material should be rendered in alpha test mode
  53558. * @returns a boolean specifying if an alpha test is needed.
  53559. */
  53560. needAlphaTesting(): boolean;
  53561. private _initializeBlock;
  53562. private _resetDualBlocks;
  53563. /**
  53564. * Build the material and generates the inner effect
  53565. * @param verbose defines if the build should log activity
  53566. */
  53567. build(verbose?: boolean): void;
  53568. /**
  53569. * Runs an otpimization phase to try to improve the shader code
  53570. */
  53571. optimize(): void;
  53572. private _prepareDefinesForAttributes;
  53573. /**
  53574. * Get if the submesh is ready to be used and all its information available.
  53575. * Child classes can use it to update shaders
  53576. * @param mesh defines the mesh to check
  53577. * @param subMesh defines which submesh to check
  53578. * @param useInstances specifies that instances should be used
  53579. * @returns a boolean indicating that the submesh is ready or not
  53580. */
  53581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53582. /**
  53583. * Binds the world matrix to the material
  53584. * @param world defines the world transformation matrix
  53585. */
  53586. bindOnlyWorldMatrix(world: Matrix): void;
  53587. /**
  53588. * Binds the submesh to this material by preparing the effect and shader to draw
  53589. * @param world defines the world transformation matrix
  53590. * @param mesh defines the mesh containing the submesh
  53591. * @param subMesh defines the submesh to bind the material to
  53592. */
  53593. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53594. /**
  53595. * Gets the active textures from the material
  53596. * @returns an array of textures
  53597. */
  53598. getActiveTextures(): BaseTexture[];
  53599. /**
  53600. * Specifies if the material uses a texture
  53601. * @param texture defines the texture to check against the material
  53602. * @returns a boolean specifying if the material uses the texture
  53603. */
  53604. hasTexture(texture: BaseTexture): boolean;
  53605. /**
  53606. * Disposes the material
  53607. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53608. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53609. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53610. */
  53611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53612. /** Creates the node editor window. */
  53613. private _createNodeEditor;
  53614. /**
  53615. * Launch the node material editor
  53616. * @param config Define the configuration of the editor
  53617. * @return a promise fulfilled when the node editor is visible
  53618. */
  53619. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53620. /**
  53621. * Clear the current material
  53622. */
  53623. clear(): void;
  53624. /**
  53625. * Clear the current material and set it to a default state
  53626. */
  53627. setToDefault(): void;
  53628. }
  53629. }
  53630. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53631. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53633. import { Nullable } from "babylonjs/types";
  53634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53635. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53636. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53638. import { Mesh } from "babylonjs/Meshes/mesh";
  53639. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53640. /**
  53641. * Defines a block that can be used inside a node based material
  53642. */
  53643. export class NodeMaterialBlock {
  53644. private _buildId;
  53645. private _target;
  53646. private _isFinalMerger;
  53647. /** @hidden */
  53648. _inputs: NodeMaterialConnectionPoint[];
  53649. /** @hidden */
  53650. _outputs: NodeMaterialConnectionPoint[];
  53651. /**
  53652. * Gets or sets the name of the block
  53653. */
  53654. name: string;
  53655. /**
  53656. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53657. */
  53658. readonly isFinalMerger: boolean;
  53659. /**
  53660. * Gets or sets the build Id
  53661. */
  53662. buildId: number;
  53663. /**
  53664. * Gets or sets the target of the block
  53665. */
  53666. target: NodeMaterialBlockTargets;
  53667. /**
  53668. * Gets the list of input points
  53669. */
  53670. readonly inputs: NodeMaterialConnectionPoint[];
  53671. /** Gets the list of output points */
  53672. readonly outputs: NodeMaterialConnectionPoint[];
  53673. /**
  53674. * Find an input by its name
  53675. * @param name defines the name of the input to look for
  53676. * @returns the input or null if not found
  53677. */
  53678. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53679. /**
  53680. * Find an output by its name
  53681. * @param name defines the name of the outputto look for
  53682. * @returns the output or null if not found
  53683. */
  53684. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53685. /**
  53686. * Creates a new NodeMaterialBlock
  53687. * @param name defines the block name
  53688. * @param target defines the target of that block (Vertex by default)
  53689. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53690. */
  53691. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53692. /**
  53693. * Initialize the block and prepare the context for build
  53694. * @param state defines the state that will be used for the build
  53695. */
  53696. initialize(state: NodeMaterialBuildState): void;
  53697. /**
  53698. * Bind data to effect. Will only be called for blocks with isBindable === true
  53699. * @param effect defines the effect to bind data to
  53700. * @param nodeMaterial defines the hosting NodeMaterial
  53701. * @param mesh defines the mesh that will be rendered
  53702. */
  53703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53704. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53705. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53706. protected _writeFloat(value: number): string;
  53707. /**
  53708. * Gets the current class name e.g. "NodeMaterialBlock"
  53709. * @returns the class name
  53710. */
  53711. getClassName(): string;
  53712. /**
  53713. * Register a new input. Must be called inside a block constructor
  53714. * @param name defines the connection point name
  53715. * @param type defines the connection point type
  53716. * @param isOptional defines a boolean indicating that this input can be omitted
  53717. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53718. * @returns the current block
  53719. */
  53720. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53721. /**
  53722. * Register a new output. Must be called inside a block constructor
  53723. * @param name defines the connection point name
  53724. * @param type defines the connection point type
  53725. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53726. * @returns the current block
  53727. */
  53728. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53729. /**
  53730. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53731. * @param forOutput defines an optional connection point to check compatibility with
  53732. * @returns the first available input or null
  53733. */
  53734. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53735. /**
  53736. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53737. * @param forBlock defines an optional block to check compatibility with
  53738. * @returns the first available input or null
  53739. */
  53740. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53741. /**
  53742. * Connect current block with another block
  53743. * @param other defines the block to connect with
  53744. * @param options define the various options to help pick the right connections
  53745. * @returns the current block
  53746. */
  53747. connectTo(other: NodeMaterialBlock, options?: {
  53748. input?: string;
  53749. output?: string;
  53750. outputSwizzle?: string;
  53751. }): this | undefined;
  53752. protected _buildBlock(state: NodeMaterialBuildState): void;
  53753. /**
  53754. * Add uniforms, samplers and uniform buffers at compilation time
  53755. * @param state defines the state to update
  53756. * @param nodeMaterial defines the node material requesting the update
  53757. * @param defines defines the material defines to update
  53758. */
  53759. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53760. /**
  53761. * Add potential fallbacks if shader compilation fails
  53762. * @param mesh defines the mesh to be rendered
  53763. * @param fallbacks defines the current prioritized list of fallbacks
  53764. */
  53765. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53766. /**
  53767. * Update defines for shader compilation
  53768. * @param mesh defines the mesh to be rendered
  53769. * @param nodeMaterial defines the node material requesting the update
  53770. * @param defines defines the material defines to update
  53771. * @param useInstances specifies that instances should be used
  53772. */
  53773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53774. /**
  53775. * Lets the block try to connect some inputs automatically
  53776. */
  53777. autoConfigure(): void;
  53778. /**
  53779. * Function called when a block is declared as repeatable content generator
  53780. * @param vertexShaderState defines the current compilation state for the vertex shader
  53781. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53782. * @param mesh defines the mesh to be rendered
  53783. * @param defines defines the material defines to update
  53784. */
  53785. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53786. /**
  53787. * Checks if the block is ready
  53788. * @param mesh defines the mesh to be rendered
  53789. * @param nodeMaterial defines the node material requesting the update
  53790. * @param defines defines the material defines to update
  53791. * @param useInstances specifies that instances should be used
  53792. * @returns true if the block is ready
  53793. */
  53794. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53795. /**
  53796. * Compile the current node and generate the shader code
  53797. * @param state defines the current compilation state (uniforms, samplers, current string)
  53798. * @returns the current block
  53799. */
  53800. build(state: NodeMaterialBuildState): this | undefined;
  53801. }
  53802. }
  53803. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53804. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53805. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53806. import { Nullable } from "babylonjs/types";
  53807. import { Effect } from "babylonjs/Materials/effect";
  53808. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53809. import { Scene } from "babylonjs/scene";
  53810. import { Matrix } from "babylonjs/Maths/math";
  53811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53812. /**
  53813. * Defines a connection point for a block
  53814. */
  53815. export class NodeMaterialConnectionPoint {
  53816. /** @hidden */
  53817. _ownerBlock: NodeMaterialBlock;
  53818. /** @hidden */
  53819. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53820. private _associatedVariableName;
  53821. private _endpoints;
  53822. private _storedValue;
  53823. private _valueCallback;
  53824. private _mode;
  53825. /** @hidden */
  53826. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53827. /** @hidden */
  53828. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53829. /** @hidden */
  53830. _needToEmitVarying: boolean;
  53831. /** @hidden */
  53832. _forceUniformInVertexShaderOnly: boolean;
  53833. private _type;
  53834. /**
  53835. * Gets or sets the connection point type (default is float)
  53836. */
  53837. type: NodeMaterialBlockConnectionPointTypes;
  53838. /**
  53839. * Gets or sets the connection point name
  53840. */
  53841. name: string;
  53842. /**
  53843. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53844. */
  53845. swizzle: string;
  53846. /**
  53847. * Gets or sets a boolean indicating that this connection point can be omitted
  53848. */
  53849. isOptional: boolean;
  53850. /**
  53851. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53852. */
  53853. define: string;
  53854. /** Gets or sets the target of that connection point */
  53855. target: NodeMaterialBlockTargets;
  53856. /**
  53857. * Gets or sets the value of that point.
  53858. * Please note that this value will be ignored if valueCallback is defined
  53859. */
  53860. value: any;
  53861. /**
  53862. * Gets or sets a callback used to get the value of that point.
  53863. * Please note that setting this value will force the connection point to ignore the value property
  53864. */
  53865. valueCallback: () => any;
  53866. /**
  53867. * Gets or sets the associated variable name in the shader
  53868. */
  53869. associatedVariableName: string;
  53870. /**
  53871. * Gets a boolean indicating that this connection point not defined yet
  53872. */
  53873. readonly isUndefined: boolean;
  53874. /**
  53875. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53876. * In this case the connection point name must be the name of the uniform to use.
  53877. * Can only be set on inputs
  53878. */
  53879. isUniform: boolean;
  53880. /**
  53881. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53882. * In this case the connection point name must be the name of the attribute to use
  53883. * Can only be set on inputs
  53884. */
  53885. isAttribute: boolean;
  53886. /**
  53887. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53888. * Can only be set on exit points
  53889. */
  53890. isVarying: boolean;
  53891. /** Get the other side of the connection (if any) */
  53892. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53893. /** Get the block that owns this connection point */
  53894. readonly ownerBlock: NodeMaterialBlock;
  53895. /** Get the block connected on the other side of this connection (if any) */
  53896. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53897. /** Get the block connected on the endpoints of this connection (if any) */
  53898. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53899. /**
  53900. * Creates a new connection point
  53901. * @param name defines the connection point name
  53902. * @param ownerBlock defines the block hosting this connection point
  53903. */
  53904. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53905. /**
  53906. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53907. * @returns the class name
  53908. */
  53909. getClassName(): string;
  53910. /**
  53911. * Set the source of this connection point to a vertex attribute
  53912. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53913. * @returns the current connection point
  53914. */
  53915. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53916. /**
  53917. * Set the source of this connection point to a well known value
  53918. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53919. * @returns the current connection point
  53920. */
  53921. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53922. /**
  53923. * Gets a boolean indicating that the current connection point is a well known value
  53924. */
  53925. readonly isWellKnownValue: boolean;
  53926. /**
  53927. * Gets or sets the current well known value or null if not defined as well know value
  53928. */
  53929. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53930. private _getTypeLength;
  53931. /**
  53932. * Gets an boolean indicating if the current point can be connected to another point
  53933. * @param connectionPoint defines the other connection point
  53934. * @returns true if the connection is possible
  53935. */
  53936. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53937. /**
  53938. * Connect this point to another connection point
  53939. * @param connectionPoint defines the other connection point
  53940. * @returns the current connection point
  53941. */
  53942. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53943. /**
  53944. * Disconnect this point from one of his endpoint
  53945. * @param endpoint defines the other connection point
  53946. * @returns the current connection point
  53947. */
  53948. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53949. /**
  53950. * When connection point is an uniform, this function will send its value to the effect
  53951. * @param effect defines the effect to transmit value to
  53952. * @param world defines the world matrix
  53953. * @param worldView defines the worldxview matrix
  53954. * @param worldViewProjection defines the worldxviewxprojection matrix
  53955. */
  53956. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53957. /**
  53958. * When connection point is an uniform, this function will send its value to the effect
  53959. * @param effect defines the effect to transmit value to
  53960. * @param scene defines the hosting scene
  53961. */
  53962. transmit(effect: Effect, scene: Scene): void;
  53963. }
  53964. }
  53965. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53969. import { Mesh } from "babylonjs/Meshes/mesh";
  53970. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53972. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53973. /**
  53974. * Block used to add support for vertex skinning (bones)
  53975. */
  53976. export class BonesBlock extends NodeMaterialBlock {
  53977. /**
  53978. * Creates a new BonesBlock
  53979. * @param name defines the block name
  53980. */
  53981. constructor(name: string);
  53982. /**
  53983. * Initialize the block and prepare the context for build
  53984. * @param state defines the state that will be used for the build
  53985. */
  53986. initialize(state: NodeMaterialBuildState): void;
  53987. /**
  53988. * Gets the current class name
  53989. * @returns the class name
  53990. */
  53991. getClassName(): string;
  53992. /**
  53993. * Gets the matrix indices input component
  53994. */
  53995. readonly matricesIndices: NodeMaterialConnectionPoint;
  53996. /**
  53997. * Gets the matrix weights input component
  53998. */
  53999. readonly matricesWeights: NodeMaterialConnectionPoint;
  54000. /**
  54001. * Gets the extra matrix indices input component
  54002. */
  54003. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54004. /**
  54005. * Gets the extra matrix weights input component
  54006. */
  54007. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54008. /**
  54009. * Gets the world input component
  54010. */
  54011. readonly world: NodeMaterialConnectionPoint;
  54012. /**
  54013. * Gets the output component
  54014. */
  54015. readonly output: NodeMaterialConnectionPoint;
  54016. autoConfigure(): void;
  54017. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54020. protected _buildBlock(state: NodeMaterialBuildState): this;
  54021. }
  54022. }
  54023. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54028. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54029. /**
  54030. * Block used to add support for instances
  54031. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54032. */
  54033. export class InstancesBlock extends NodeMaterialBlock {
  54034. /**
  54035. * Creates a new InstancesBlock
  54036. * @param name defines the block name
  54037. */
  54038. constructor(name: string);
  54039. /**
  54040. * Gets the current class name
  54041. * @returns the class name
  54042. */
  54043. getClassName(): string;
  54044. /**
  54045. * Gets the first world row input component
  54046. */
  54047. readonly world0: NodeMaterialConnectionPoint;
  54048. /**
  54049. * Gets the second world row input component
  54050. */
  54051. readonly world1: NodeMaterialConnectionPoint;
  54052. /**
  54053. * Gets the third world row input component
  54054. */
  54055. readonly world2: NodeMaterialConnectionPoint;
  54056. /**
  54057. * Gets the forth world row input component
  54058. */
  54059. readonly world3: NodeMaterialConnectionPoint;
  54060. /**
  54061. * Gets the world input component
  54062. */
  54063. readonly world: NodeMaterialConnectionPoint;
  54064. /**
  54065. * Gets the output component
  54066. */
  54067. readonly output: NodeMaterialConnectionPoint;
  54068. autoConfigure(): void;
  54069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54070. protected _buildBlock(state: NodeMaterialBuildState): this;
  54071. }
  54072. }
  54073. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54078. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54079. import { Effect } from "babylonjs/Materials/effect";
  54080. import { Mesh } from "babylonjs/Meshes/mesh";
  54081. /**
  54082. * Block used to add morph targets support to vertex shader
  54083. */
  54084. export class MorphTargetsBlock extends NodeMaterialBlock {
  54085. private _repeatableContentAnchor;
  54086. private _repeatebleContentGenerated;
  54087. /**
  54088. * Create a new MorphTargetsBlock
  54089. * @param name defines the block name
  54090. */
  54091. constructor(name: string);
  54092. /**
  54093. * Gets the current class name
  54094. * @returns the class name
  54095. */
  54096. getClassName(): string;
  54097. /**
  54098. * Gets the position input component
  54099. */
  54100. readonly position: NodeMaterialConnectionPoint;
  54101. /**
  54102. * Gets the normal input component
  54103. */
  54104. readonly normal: NodeMaterialConnectionPoint;
  54105. /**
  54106. * Gets the tangent input component
  54107. */
  54108. readonly tangent: NodeMaterialConnectionPoint;
  54109. /**
  54110. * Gets the tangent input component
  54111. */
  54112. readonly uv: NodeMaterialConnectionPoint;
  54113. /**
  54114. * Gets the position output component
  54115. */
  54116. readonly positionOutput: NodeMaterialConnectionPoint;
  54117. /**
  54118. * Gets the normal output component
  54119. */
  54120. readonly normalOutput: NodeMaterialConnectionPoint;
  54121. /**
  54122. * Gets the tangent output component
  54123. */
  54124. readonly tangentOutput: NodeMaterialConnectionPoint;
  54125. /**
  54126. * Gets the tangent output component
  54127. */
  54128. readonly uvOutput: NodeMaterialConnectionPoint;
  54129. initialize(state: NodeMaterialBuildState): void;
  54130. autoConfigure(): void;
  54131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54132. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54133. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54134. protected _buildBlock(state: NodeMaterialBuildState): this;
  54135. }
  54136. }
  54137. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54138. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54139. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54140. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54141. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54142. }
  54143. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54147. /**
  54148. * Block used to add an alpha test in the fragment shader
  54149. */
  54150. export class AlphaTestBlock extends NodeMaterialBlock {
  54151. /**
  54152. * Gets or sets the alpha value where alpha testing happens
  54153. */
  54154. alphaCutOff: number;
  54155. /**
  54156. * Create a new AlphaTestBlock
  54157. * @param name defines the block name
  54158. */
  54159. constructor(name: string);
  54160. /**
  54161. * Gets the current class name
  54162. * @returns the class name
  54163. */
  54164. getClassName(): string;
  54165. /**
  54166. * Gets the color input component
  54167. */
  54168. readonly color: NodeMaterialConnectionPoint;
  54169. protected _buildBlock(state: NodeMaterialBuildState): this;
  54170. }
  54171. }
  54172. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54173. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54174. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54175. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54176. /**
  54177. * Block used to create a Color4 out of 4 inputs (one for each component)
  54178. */
  54179. export class RGBAMergerBlock extends NodeMaterialBlock {
  54180. /**
  54181. * Create a new RGBAMergerBlock
  54182. * @param name defines the block name
  54183. */
  54184. constructor(name: string);
  54185. /**
  54186. * Gets the current class name
  54187. * @returns the class name
  54188. */
  54189. getClassName(): string;
  54190. /**
  54191. * Gets the R input component
  54192. */
  54193. readonly r: NodeMaterialConnectionPoint;
  54194. /**
  54195. * Gets the G input component
  54196. */
  54197. readonly g: NodeMaterialConnectionPoint;
  54198. /**
  54199. * Gets the B input component
  54200. */
  54201. readonly b: NodeMaterialConnectionPoint;
  54202. /**
  54203. * Gets the RGB input component
  54204. */
  54205. readonly rgb: NodeMaterialConnectionPoint;
  54206. /**
  54207. * Gets the R input component
  54208. */
  54209. readonly a: NodeMaterialConnectionPoint;
  54210. /**
  54211. * Gets the output component
  54212. */
  54213. readonly output: NodeMaterialConnectionPoint;
  54214. protected _buildBlock(state: NodeMaterialBuildState): this;
  54215. }
  54216. }
  54217. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54219. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54221. /**
  54222. * Block used to create a Color3 out of 3 inputs (one for each component)
  54223. */
  54224. export class RGBMergerBlock extends NodeMaterialBlock {
  54225. /**
  54226. * Create a new RGBMergerBlock
  54227. * @param name defines the block name
  54228. */
  54229. constructor(name: string);
  54230. /**
  54231. * Gets the current class name
  54232. * @returns the class name
  54233. */
  54234. getClassName(): string;
  54235. /**
  54236. * Gets the R component input
  54237. */
  54238. readonly r: NodeMaterialConnectionPoint;
  54239. /**
  54240. * Gets the G component input
  54241. */
  54242. readonly g: NodeMaterialConnectionPoint;
  54243. /**
  54244. * Gets the B component input
  54245. */
  54246. readonly b: NodeMaterialConnectionPoint;
  54247. /**
  54248. * Gets the output component
  54249. */
  54250. readonly output: NodeMaterialConnectionPoint;
  54251. protected _buildBlock(state: NodeMaterialBuildState): this;
  54252. }
  54253. }
  54254. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54258. /**
  54259. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54260. */
  54261. export class RGBASplitterBlock extends NodeMaterialBlock {
  54262. /**
  54263. * Create a new RGBASplitterBlock
  54264. * @param name defines the block name
  54265. */
  54266. constructor(name: string);
  54267. /**
  54268. * Gets the current class name
  54269. * @returns the class name
  54270. */
  54271. getClassName(): string;
  54272. /**
  54273. * Gets the input component
  54274. */
  54275. readonly input: NodeMaterialConnectionPoint;
  54276. protected _buildBlock(state: NodeMaterialBuildState): this;
  54277. }
  54278. }
  54279. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54283. /**
  54284. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54285. */
  54286. export class RGBSplitterBlock extends NodeMaterialBlock {
  54287. /**
  54288. * Create a new RGBSplitterBlock
  54289. * @param name defines the block name
  54290. */
  54291. constructor(name: string);
  54292. /**
  54293. * Gets the current class name
  54294. * @returns the class name
  54295. */
  54296. getClassName(): string;
  54297. /**
  54298. * Gets the input component
  54299. */
  54300. readonly input: NodeMaterialConnectionPoint;
  54301. protected _buildBlock(state: NodeMaterialBuildState): this;
  54302. }
  54303. }
  54304. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54306. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54309. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54310. /**
  54311. * Block used to read a texture from a sampler
  54312. */
  54313. export class TextureBlock extends NodeMaterialBlock {
  54314. private _defineName;
  54315. /**
  54316. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54317. */
  54318. autoConnectTextureMatrix: boolean;
  54319. /**
  54320. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54321. */
  54322. autoSelectUV: boolean;
  54323. /**
  54324. * Create a new TextureBlock
  54325. * @param name defines the block name
  54326. */
  54327. constructor(name: string);
  54328. /**
  54329. * Gets the current class name
  54330. * @returns the class name
  54331. */
  54332. getClassName(): string;
  54333. /**
  54334. * Gets the uv input component
  54335. */
  54336. readonly uv: NodeMaterialConnectionPoint;
  54337. /**
  54338. * Gets the texture information input component
  54339. */
  54340. readonly textureInfo: NodeMaterialConnectionPoint;
  54341. /**
  54342. * Gets the transformed uv input component
  54343. */
  54344. readonly transformedUV: NodeMaterialConnectionPoint;
  54345. /**
  54346. * Gets the texture input component
  54347. */
  54348. readonly texture: NodeMaterialConnectionPoint;
  54349. /**
  54350. * Gets the texture transform input component
  54351. */
  54352. readonly textureTransform: NodeMaterialConnectionPoint;
  54353. /**
  54354. * Gets the output component
  54355. */
  54356. readonly output: NodeMaterialConnectionPoint;
  54357. autoConfigure(): void;
  54358. initialize(state: NodeMaterialBuildState): void;
  54359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54360. isReady(): boolean;
  54361. private _injectVertexCode;
  54362. protected _buildBlock(state: NodeMaterialBuildState): this;
  54363. }
  54364. }
  54365. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54370. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54371. import { Effect } from "babylonjs/Materials/effect";
  54372. import { Mesh } from "babylonjs/Meshes/mesh";
  54373. /**
  54374. * Block used to add image processing support to fragment shader
  54375. */
  54376. export class ImageProcessingBlock extends NodeMaterialBlock {
  54377. /**
  54378. * Create a new ImageProcessingBlock
  54379. * @param name defines the block name
  54380. */
  54381. constructor(name: string);
  54382. /**
  54383. * Gets the current class name
  54384. * @returns the class name
  54385. */
  54386. getClassName(): string;
  54387. /**
  54388. * Gets the color input component
  54389. */
  54390. readonly color: NodeMaterialConnectionPoint;
  54391. /**
  54392. * Gets the output component
  54393. */
  54394. readonly output: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Initialize the block and prepare the context for build
  54397. * @param state defines the state that will be used for the build
  54398. */
  54399. initialize(state: NodeMaterialBuildState): void;
  54400. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54403. protected _buildBlock(state: NodeMaterialBuildState): this;
  54404. }
  54405. }
  54406. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54407. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54408. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54409. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54410. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54411. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54412. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54413. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54414. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54415. }
  54416. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54419. import { Mesh } from "babylonjs/Meshes/mesh";
  54420. import { Effect } from "babylonjs/Materials/effect";
  54421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54423. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54424. /**
  54425. * Block used to add support for scene fog
  54426. */
  54427. export class FogBlock extends NodeMaterialBlock {
  54428. /**
  54429. * Create a new FogBlock
  54430. * @param name defines the block name
  54431. */
  54432. constructor(name: string);
  54433. /**
  54434. * Gets the current class name
  54435. * @returns the class name
  54436. */
  54437. getClassName(): string;
  54438. /**
  54439. * Gets the world position input component
  54440. */
  54441. readonly worldPosition: NodeMaterialConnectionPoint;
  54442. /**
  54443. * Gets the view input component
  54444. */
  54445. readonly view: NodeMaterialConnectionPoint;
  54446. /**
  54447. * Gets the color input component
  54448. */
  54449. readonly color: NodeMaterialConnectionPoint;
  54450. /**
  54451. * Gets the fog color input component
  54452. */
  54453. readonly fogColor: NodeMaterialConnectionPoint;
  54454. /**
  54455. * Gets the for parameter input component
  54456. */
  54457. readonly fogParameters: NodeMaterialConnectionPoint;
  54458. /**
  54459. * Gets the output component
  54460. */
  54461. readonly output: NodeMaterialConnectionPoint;
  54462. autoConfigure(): void;
  54463. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54465. protected _buildBlock(state: NodeMaterialBuildState): this;
  54466. }
  54467. }
  54468. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54474. import { Effect } from "babylonjs/Materials/effect";
  54475. import { Mesh } from "babylonjs/Meshes/mesh";
  54476. /**
  54477. * Block used to add light in the fragment shader
  54478. */
  54479. export class LightBlock extends NodeMaterialBlock {
  54480. private _lightId;
  54481. /**
  54482. * Create a new LightBlock
  54483. * @param name defines the block name
  54484. */
  54485. constructor(name: string);
  54486. /**
  54487. * Gets the current class name
  54488. * @returns the class name
  54489. */
  54490. getClassName(): string;
  54491. /**
  54492. * Gets the world position input component
  54493. */
  54494. readonly worldPosition: NodeMaterialConnectionPoint;
  54495. /**
  54496. * Gets the world normal input component
  54497. */
  54498. readonly worldNormal: NodeMaterialConnectionPoint;
  54499. /**
  54500. * Gets the light input component.
  54501. * If not defined, all lights will be considered
  54502. */
  54503. readonly light: NodeMaterialConnectionPoint;
  54504. /**
  54505. * Gets the camera (or eye) position component
  54506. */
  54507. readonly cameraPosition: NodeMaterialConnectionPoint;
  54508. /**
  54509. * Gets the diffuse output component
  54510. */
  54511. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54512. /**
  54513. * Gets the specular output component
  54514. */
  54515. readonly specularOutput: NodeMaterialConnectionPoint;
  54516. autoConfigure(): void;
  54517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54518. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54519. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54520. private _injectVertexCode;
  54521. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54522. }
  54523. }
  54524. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54525. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54526. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54527. }
  54528. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54532. /**
  54533. * Block used to multiply 2 values
  54534. */
  54535. export class MultiplyBlock extends NodeMaterialBlock {
  54536. /**
  54537. * Creates a new MultiplyBlock
  54538. * @param name defines the block name
  54539. */
  54540. constructor(name: string);
  54541. /**
  54542. * Gets the current class name
  54543. * @returns the class name
  54544. */
  54545. getClassName(): string;
  54546. /**
  54547. * Gets the left operand input component
  54548. */
  54549. readonly left: NodeMaterialConnectionPoint;
  54550. /**
  54551. * Gets the right operand input component
  54552. */
  54553. readonly right: NodeMaterialConnectionPoint;
  54554. /**
  54555. * Gets the output component
  54556. */
  54557. readonly output: NodeMaterialConnectionPoint;
  54558. protected _buildBlock(state: NodeMaterialBuildState): this;
  54559. }
  54560. }
  54561. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54565. /**
  54566. * Block used to add 2 vector4
  54567. */
  54568. export class AddBlock extends NodeMaterialBlock {
  54569. /**
  54570. * Creates a new AddBlock
  54571. * @param name defines the block name
  54572. */
  54573. constructor(name: string);
  54574. /**
  54575. * Gets the current class name
  54576. * @returns the class name
  54577. */
  54578. getClassName(): string;
  54579. /**
  54580. * Gets the left operand input component
  54581. */
  54582. readonly left: NodeMaterialConnectionPoint;
  54583. /**
  54584. * Gets the right operand input component
  54585. */
  54586. readonly right: NodeMaterialConnectionPoint;
  54587. /**
  54588. * Gets the output component
  54589. */
  54590. readonly output: NodeMaterialConnectionPoint;
  54591. protected _buildBlock(state: NodeMaterialBuildState): this;
  54592. }
  54593. }
  54594. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54598. /**
  54599. * Block used to clamp a float
  54600. */
  54601. export class ClampBlock extends NodeMaterialBlock {
  54602. /** Gets or sets the minimum range */
  54603. minimum: number;
  54604. /** Gets or sets the maximum range */
  54605. maximum: number;
  54606. /**
  54607. * Creates a new ClampBlock
  54608. * @param name defines the block name
  54609. */
  54610. constructor(name: string);
  54611. /**
  54612. * Gets the current class name
  54613. * @returns the class name
  54614. */
  54615. getClassName(): string;
  54616. /**
  54617. * Gets the value input component
  54618. */
  54619. readonly value: NodeMaterialConnectionPoint;
  54620. /**
  54621. * Gets the output component
  54622. */
  54623. readonly output: NodeMaterialConnectionPoint;
  54624. protected _buildBlock(state: NodeMaterialBuildState): this;
  54625. }
  54626. }
  54627. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54631. /**
  54632. * Block used to transform a vector2 with a matrix
  54633. */
  54634. export class Vector2TransformBlock extends NodeMaterialBlock {
  54635. /**
  54636. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54637. */
  54638. complementZ: number;
  54639. /**
  54640. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54641. */
  54642. complementW: number;
  54643. /**
  54644. * Creates a new Vector2TransformBlock
  54645. * @param name defines the block name
  54646. */
  54647. constructor(name: string);
  54648. /**
  54649. * Gets the vector input
  54650. */
  54651. readonly vector: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the matrix transform input
  54654. */
  54655. readonly transform: NodeMaterialConnectionPoint;
  54656. /**
  54657. * Gets the output component
  54658. */
  54659. readonly output: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the current class name
  54662. * @returns the class name
  54663. */
  54664. getClassName(): string;
  54665. protected _buildBlock(state: NodeMaterialBuildState): this;
  54666. }
  54667. }
  54668. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54672. /**
  54673. * Block used to transform a vector3 with a matrix
  54674. */
  54675. export class Vector3TransformBlock extends NodeMaterialBlock {
  54676. /**
  54677. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54678. */
  54679. complement: number;
  54680. /**
  54681. * Creates a new Vector3TransformBlock
  54682. * @param name defines the block name
  54683. */
  54684. constructor(name: string);
  54685. /**
  54686. * Gets the vector input
  54687. */
  54688. readonly vector: NodeMaterialConnectionPoint;
  54689. /**
  54690. * Gets the matrix transform input
  54691. */
  54692. readonly transform: NodeMaterialConnectionPoint;
  54693. /**
  54694. * Gets the output component
  54695. */
  54696. readonly output: NodeMaterialConnectionPoint;
  54697. /**
  54698. * Gets the current class name
  54699. * @returns the class name
  54700. */
  54701. getClassName(): string;
  54702. protected _buildBlock(state: NodeMaterialBuildState): this;
  54703. }
  54704. }
  54705. declare module "babylonjs/Materials/Node/Blocks/index" {
  54706. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54707. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54708. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54709. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54710. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54711. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54712. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54713. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54714. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54715. }
  54716. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54717. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54718. }
  54719. declare module "babylonjs/Materials/Node/index" {
  54720. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54721. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54722. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54723. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54724. export * from "babylonjs/Materials/Node/nodeMaterial";
  54725. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54726. export * from "babylonjs/Materials/Node/Blocks/index";
  54727. export * from "babylonjs/Materials/Node/Optimizers/index";
  54728. }
  54729. declare module "babylonjs/Materials/effectRenderer" {
  54730. import { Nullable } from "babylonjs/types";
  54731. import { Texture } from "babylonjs/Materials/Textures/texture";
  54732. import { Engine } from "babylonjs/Engines/engine";
  54733. import { Observable } from "babylonjs/Misc/observable";
  54734. import { Effect } from "babylonjs/Materials/effect";
  54735. /**
  54736. * Helper class to render one or more effects
  54737. */
  54738. export class EffectRenderer {
  54739. private engine;
  54740. private static _Vertices;
  54741. private static _Indices;
  54742. private _vertexBuffers;
  54743. private _indexBuffer;
  54744. private _ringBufferIndex;
  54745. private _ringScreenBuffer;
  54746. private _getNextFrameBuffer;
  54747. /**
  54748. * Creates an effect renderer
  54749. * @param engine the engine to use for rendering
  54750. */
  54751. constructor(engine: Engine);
  54752. /**
  54753. * renders one or more effects to a specified texture
  54754. * @param effectWrappers list of effects to renderer
  54755. * @param outputTexture texture to draw to, if null it will render to the screen
  54756. */
  54757. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54758. /**
  54759. * Disposes of the effect renderer
  54760. */
  54761. dispose(): void;
  54762. }
  54763. /**
  54764. * Options to create an EffectWrapper
  54765. */
  54766. interface EffectWrapperCreationOptions {
  54767. /**
  54768. * Engine to use to create the effect
  54769. */
  54770. engine: Engine;
  54771. /**
  54772. * Fragment shader for the effect
  54773. */
  54774. fragmentShader: string;
  54775. /**
  54776. * Attributes to use in the shader
  54777. */
  54778. attributeNames: Array<string>;
  54779. /**
  54780. * Uniforms to use in the shader
  54781. */
  54782. uniformNames: Array<string>;
  54783. /**
  54784. * Texture sampler names to use in the shader
  54785. */
  54786. samplerNames: Array<string>;
  54787. }
  54788. /**
  54789. * Wraps an effect to be used for rendering
  54790. */
  54791. export class EffectWrapper {
  54792. /**
  54793. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54794. */
  54795. onApplyObservable: Observable<{}>;
  54796. /**
  54797. * The underlying effect
  54798. */
  54799. effect: Effect;
  54800. /**
  54801. * Creates an effect to be renderer
  54802. * @param creationOptions options to create the effect
  54803. */
  54804. constructor(creationOptions: EffectWrapperCreationOptions);
  54805. /**
  54806. * Disposes of the effect wrapper
  54807. */
  54808. dispose(): void;
  54809. }
  54810. }
  54811. declare module "babylonjs/Materials/index" {
  54812. export * from "babylonjs/Materials/Background/index";
  54813. export * from "babylonjs/Materials/colorCurves";
  54814. export * from "babylonjs/Materials/effect";
  54815. export * from "babylonjs/Materials/fresnelParameters";
  54816. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54817. export * from "babylonjs/Materials/material";
  54818. export * from "babylonjs/Materials/materialDefines";
  54819. export * from "babylonjs/Materials/materialHelper";
  54820. export * from "babylonjs/Materials/multiMaterial";
  54821. export * from "babylonjs/Materials/PBR/index";
  54822. export * from "babylonjs/Materials/pushMaterial";
  54823. export * from "babylonjs/Materials/shaderMaterial";
  54824. export * from "babylonjs/Materials/standardMaterial";
  54825. export * from "babylonjs/Materials/Textures/index";
  54826. export * from "babylonjs/Materials/uniformBuffer";
  54827. export * from "babylonjs/Materials/materialFlags";
  54828. export * from "babylonjs/Materials/Node/index";
  54829. export * from "babylonjs/Materials/effectRenderer";
  54830. }
  54831. declare module "babylonjs/Maths/index" {
  54832. export * from "babylonjs/Maths/math.scalar";
  54833. export * from "babylonjs/Maths/math";
  54834. export * from "babylonjs/Maths/sphericalPolynomial";
  54835. }
  54836. declare module "babylonjs/Misc/workerPool" {
  54837. import { IDisposable } from "babylonjs/scene";
  54838. /**
  54839. * Helper class to push actions to a pool of workers.
  54840. */
  54841. export class WorkerPool implements IDisposable {
  54842. private _workerInfos;
  54843. private _pendingActions;
  54844. /**
  54845. * Constructor
  54846. * @param workers Array of workers to use for actions
  54847. */
  54848. constructor(workers: Array<Worker>);
  54849. /**
  54850. * Terminates all workers and clears any pending actions.
  54851. */
  54852. dispose(): void;
  54853. /**
  54854. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54855. * pended until a worker has completed its action.
  54856. * @param action The action to perform. Call onComplete when the action is complete.
  54857. */
  54858. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54859. private _execute;
  54860. }
  54861. }
  54862. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54863. import { IDisposable } from "babylonjs/scene";
  54864. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54865. /**
  54866. * Configuration for Draco compression
  54867. */
  54868. export interface IDracoCompressionConfiguration {
  54869. /**
  54870. * Configuration for the decoder.
  54871. */
  54872. decoder: {
  54873. /**
  54874. * The url to the WebAssembly module.
  54875. */
  54876. wasmUrl?: string;
  54877. /**
  54878. * The url to the WebAssembly binary.
  54879. */
  54880. wasmBinaryUrl?: string;
  54881. /**
  54882. * The url to the fallback JavaScript module.
  54883. */
  54884. fallbackUrl?: string;
  54885. };
  54886. }
  54887. /**
  54888. * Draco compression (https://google.github.io/draco/)
  54889. *
  54890. * This class wraps the Draco module.
  54891. *
  54892. * **Encoder**
  54893. *
  54894. * The encoder is not currently implemented.
  54895. *
  54896. * **Decoder**
  54897. *
  54898. * 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.
  54899. *
  54900. * To update the configuration, use the following code:
  54901. * ```javascript
  54902. * DracoCompression.Configuration = {
  54903. * decoder: {
  54904. * wasmUrl: "<url to the WebAssembly library>",
  54905. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54906. * fallbackUrl: "<url to the fallback JavaScript library>",
  54907. * }
  54908. * };
  54909. * ```
  54910. *
  54911. * 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.
  54912. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54913. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54914. *
  54915. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54916. * ```javascript
  54917. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54918. * ```
  54919. *
  54920. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54921. */
  54922. export class DracoCompression implements IDisposable {
  54923. private _workerPoolPromise?;
  54924. private _decoderModulePromise?;
  54925. /**
  54926. * The configuration. Defaults to the following urls:
  54927. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54928. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54929. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54930. */
  54931. static Configuration: IDracoCompressionConfiguration;
  54932. /**
  54933. * Returns true if the decoder configuration is available.
  54934. */
  54935. static readonly DecoderAvailable: boolean;
  54936. /**
  54937. * Default number of workers to create when creating the draco compression object.
  54938. */
  54939. static DefaultNumWorkers: number;
  54940. private static GetDefaultNumWorkers;
  54941. private static _Default;
  54942. /**
  54943. * Default instance for the draco compression object.
  54944. */
  54945. static readonly Default: DracoCompression;
  54946. /**
  54947. * Constructor
  54948. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54949. */
  54950. constructor(numWorkers?: number);
  54951. /**
  54952. * Stop all async operations and release resources.
  54953. */
  54954. dispose(): void;
  54955. /**
  54956. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54957. * @returns a promise that resolves when ready
  54958. */
  54959. whenReadyAsync(): Promise<void>;
  54960. /**
  54961. * Decode Draco compressed mesh data to vertex data.
  54962. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54963. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54964. * @returns A promise that resolves with the decoded vertex data
  54965. */
  54966. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54967. [kind: string]: number;
  54968. }): Promise<VertexData>;
  54969. }
  54970. }
  54971. declare module "babylonjs/Meshes/Compression/index" {
  54972. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54973. }
  54974. declare module "babylonjs/Meshes/csg" {
  54975. import { Nullable } from "babylonjs/types";
  54976. import { Scene } from "babylonjs/scene";
  54977. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54978. import { Mesh } from "babylonjs/Meshes/mesh";
  54979. import { Material } from "babylonjs/Materials/material";
  54980. /**
  54981. * Class for building Constructive Solid Geometry
  54982. */
  54983. export class CSG {
  54984. private polygons;
  54985. /**
  54986. * The world matrix
  54987. */
  54988. matrix: Matrix;
  54989. /**
  54990. * Stores the position
  54991. */
  54992. position: Vector3;
  54993. /**
  54994. * Stores the rotation
  54995. */
  54996. rotation: Vector3;
  54997. /**
  54998. * Stores the rotation quaternion
  54999. */
  55000. rotationQuaternion: Nullable<Quaternion>;
  55001. /**
  55002. * Stores the scaling vector
  55003. */
  55004. scaling: Vector3;
  55005. /**
  55006. * Convert the Mesh to CSG
  55007. * @param mesh The Mesh to convert to CSG
  55008. * @returns A new CSG from the Mesh
  55009. */
  55010. static FromMesh(mesh: Mesh): CSG;
  55011. /**
  55012. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55013. * @param polygons Polygons used to construct a CSG solid
  55014. */
  55015. private static FromPolygons;
  55016. /**
  55017. * Clones, or makes a deep copy, of the CSG
  55018. * @returns A new CSG
  55019. */
  55020. clone(): CSG;
  55021. /**
  55022. * Unions this CSG with another CSG
  55023. * @param csg The CSG to union against this CSG
  55024. * @returns The unioned CSG
  55025. */
  55026. union(csg: CSG): CSG;
  55027. /**
  55028. * Unions this CSG with another CSG in place
  55029. * @param csg The CSG to union against this CSG
  55030. */
  55031. unionInPlace(csg: CSG): void;
  55032. /**
  55033. * Subtracts this CSG with another CSG
  55034. * @param csg The CSG to subtract against this CSG
  55035. * @returns A new CSG
  55036. */
  55037. subtract(csg: CSG): CSG;
  55038. /**
  55039. * Subtracts this CSG with another CSG in place
  55040. * @param csg The CSG to subtact against this CSG
  55041. */
  55042. subtractInPlace(csg: CSG): void;
  55043. /**
  55044. * Intersect this CSG with another CSG
  55045. * @param csg The CSG to intersect against this CSG
  55046. * @returns A new CSG
  55047. */
  55048. intersect(csg: CSG): CSG;
  55049. /**
  55050. * Intersects this CSG with another CSG in place
  55051. * @param csg The CSG to intersect against this CSG
  55052. */
  55053. intersectInPlace(csg: CSG): void;
  55054. /**
  55055. * Return a new CSG solid with solid and empty space switched. This solid is
  55056. * not modified.
  55057. * @returns A new CSG solid with solid and empty space switched
  55058. */
  55059. inverse(): CSG;
  55060. /**
  55061. * Inverses the CSG in place
  55062. */
  55063. inverseInPlace(): void;
  55064. /**
  55065. * This is used to keep meshes transformations so they can be restored
  55066. * when we build back a Babylon Mesh
  55067. * NB : All CSG operations are performed in world coordinates
  55068. * @param csg The CSG to copy the transform attributes from
  55069. * @returns This CSG
  55070. */
  55071. copyTransformAttributes(csg: CSG): CSG;
  55072. /**
  55073. * Build Raw mesh from CSG
  55074. * Coordinates here are in world space
  55075. * @param name The name of the mesh geometry
  55076. * @param scene The Scene
  55077. * @param keepSubMeshes Specifies if the submeshes should be kept
  55078. * @returns A new Mesh
  55079. */
  55080. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55081. /**
  55082. * Build Mesh from CSG taking material and transforms into account
  55083. * @param name The name of the Mesh
  55084. * @param material The material of the Mesh
  55085. * @param scene The Scene
  55086. * @param keepSubMeshes Specifies if submeshes should be kept
  55087. * @returns The new Mesh
  55088. */
  55089. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55090. }
  55091. }
  55092. declare module "babylonjs/Meshes/trailMesh" {
  55093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55094. import { Mesh } from "babylonjs/Meshes/mesh";
  55095. import { Scene } from "babylonjs/scene";
  55096. /**
  55097. * Class used to create a trail following a mesh
  55098. */
  55099. export class TrailMesh extends Mesh {
  55100. private _generator;
  55101. private _autoStart;
  55102. private _running;
  55103. private _diameter;
  55104. private _length;
  55105. private _sectionPolygonPointsCount;
  55106. private _sectionVectors;
  55107. private _sectionNormalVectors;
  55108. private _beforeRenderObserver;
  55109. /**
  55110. * @constructor
  55111. * @param name The value used by scene.getMeshByName() to do a lookup.
  55112. * @param generator The mesh to generate a trail.
  55113. * @param scene The scene to add this mesh to.
  55114. * @param diameter Diameter of trailing mesh. Default is 1.
  55115. * @param length Length of trailing mesh. Default is 60.
  55116. * @param autoStart Automatically start trailing mesh. Default true.
  55117. */
  55118. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55119. /**
  55120. * "TrailMesh"
  55121. * @returns "TrailMesh"
  55122. */
  55123. getClassName(): string;
  55124. private _createMesh;
  55125. /**
  55126. * Start trailing mesh.
  55127. */
  55128. start(): void;
  55129. /**
  55130. * Stop trailing mesh.
  55131. */
  55132. stop(): void;
  55133. /**
  55134. * Update trailing mesh geometry.
  55135. */
  55136. update(): void;
  55137. /**
  55138. * Returns a new TrailMesh object.
  55139. * @param name is a string, the name given to the new mesh
  55140. * @param newGenerator use new generator object for cloned trail mesh
  55141. * @returns a new mesh
  55142. */
  55143. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55144. /**
  55145. * Serializes this trail mesh
  55146. * @param serializationObject object to write serialization to
  55147. */
  55148. serialize(serializationObject: any): void;
  55149. /**
  55150. * Parses a serialized trail mesh
  55151. * @param parsedMesh the serialized mesh
  55152. * @param scene the scene to create the trail mesh in
  55153. * @returns the created trail mesh
  55154. */
  55155. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55156. }
  55157. }
  55158. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55159. import { Nullable } from "babylonjs/types";
  55160. import { Scene } from "babylonjs/scene";
  55161. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55162. import { Mesh } from "babylonjs/Meshes/mesh";
  55163. /**
  55164. * Class containing static functions to help procedurally build meshes
  55165. */
  55166. export class TiledBoxBuilder {
  55167. /**
  55168. * Creates a box mesh
  55169. * 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)
  55170. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55174. * @param name defines the name of the mesh
  55175. * @param options defines the options used to create the mesh
  55176. * @param scene defines the hosting scene
  55177. * @returns the box mesh
  55178. */
  55179. static CreateTiledBox(name: string, options: {
  55180. pattern?: number;
  55181. width?: number;
  55182. height?: number;
  55183. depth?: number;
  55184. tileSize?: number;
  55185. tileWidth?: number;
  55186. tileHeight?: number;
  55187. alignHorizontal?: number;
  55188. alignVertical?: number;
  55189. faceUV?: Vector4[];
  55190. faceColors?: Color4[];
  55191. sideOrientation?: number;
  55192. updatable?: boolean;
  55193. }, scene?: Nullable<Scene>): Mesh;
  55194. }
  55195. }
  55196. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55197. import { Vector4 } from "babylonjs/Maths/math";
  55198. import { Mesh } from "babylonjs/Meshes/mesh";
  55199. /**
  55200. * Class containing static functions to help procedurally build meshes
  55201. */
  55202. export class TorusKnotBuilder {
  55203. /**
  55204. * Creates a torus knot mesh
  55205. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55206. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55207. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55208. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55212. * @param name defines the name of the mesh
  55213. * @param options defines the options used to create the mesh
  55214. * @param scene defines the hosting scene
  55215. * @returns the torus knot mesh
  55216. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55217. */
  55218. static CreateTorusKnot(name: string, options: {
  55219. radius?: number;
  55220. tube?: number;
  55221. radialSegments?: number;
  55222. tubularSegments?: number;
  55223. p?: number;
  55224. q?: number;
  55225. updatable?: boolean;
  55226. sideOrientation?: number;
  55227. frontUVs?: Vector4;
  55228. backUVs?: Vector4;
  55229. }, scene: any): Mesh;
  55230. }
  55231. }
  55232. declare module "babylonjs/Meshes/polygonMesh" {
  55233. import { Scene } from "babylonjs/scene";
  55234. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55235. import { Mesh } from "babylonjs/Meshes/mesh";
  55236. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55237. /**
  55238. * Polygon
  55239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55240. */
  55241. export class Polygon {
  55242. /**
  55243. * Creates a rectangle
  55244. * @param xmin bottom X coord
  55245. * @param ymin bottom Y coord
  55246. * @param xmax top X coord
  55247. * @param ymax top Y coord
  55248. * @returns points that make the resulting rectation
  55249. */
  55250. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55251. /**
  55252. * Creates a circle
  55253. * @param radius radius of circle
  55254. * @param cx scale in x
  55255. * @param cy scale in y
  55256. * @param numberOfSides number of sides that make up the circle
  55257. * @returns points that make the resulting circle
  55258. */
  55259. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55260. /**
  55261. * Creates a polygon from input string
  55262. * @param input Input polygon data
  55263. * @returns the parsed points
  55264. */
  55265. static Parse(input: string): Vector2[];
  55266. /**
  55267. * Starts building a polygon from x and y coordinates
  55268. * @param x x coordinate
  55269. * @param y y coordinate
  55270. * @returns the started path2
  55271. */
  55272. static StartingAt(x: number, y: number): Path2;
  55273. }
  55274. /**
  55275. * Builds a polygon
  55276. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55277. */
  55278. export class PolygonMeshBuilder {
  55279. private _points;
  55280. private _outlinepoints;
  55281. private _holes;
  55282. private _name;
  55283. private _scene;
  55284. private _epoints;
  55285. private _eholes;
  55286. private _addToepoint;
  55287. /**
  55288. * Babylon reference to the earcut plugin.
  55289. */
  55290. bjsEarcut: any;
  55291. /**
  55292. * Creates a PolygonMeshBuilder
  55293. * @param name name of the builder
  55294. * @param contours Path of the polygon
  55295. * @param scene scene to add to when creating the mesh
  55296. * @param earcutInjection can be used to inject your own earcut reference
  55297. */
  55298. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55299. /**
  55300. * Adds a whole within the polygon
  55301. * @param hole Array of points defining the hole
  55302. * @returns this
  55303. */
  55304. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55305. /**
  55306. * Creates the polygon
  55307. * @param updatable If the mesh should be updatable
  55308. * @param depth The depth of the mesh created
  55309. * @returns the created mesh
  55310. */
  55311. build(updatable?: boolean, depth?: number): Mesh;
  55312. /**
  55313. * Creates the polygon
  55314. * @param depth The depth of the mesh created
  55315. * @returns the created VertexData
  55316. */
  55317. buildVertexData(depth?: number): VertexData;
  55318. /**
  55319. * Adds a side to the polygon
  55320. * @param positions points that make the polygon
  55321. * @param normals normals of the polygon
  55322. * @param uvs uvs of the polygon
  55323. * @param indices indices of the polygon
  55324. * @param bounds bounds of the polygon
  55325. * @param points points of the polygon
  55326. * @param depth depth of the polygon
  55327. * @param flip flip of the polygon
  55328. */
  55329. private addSide;
  55330. }
  55331. }
  55332. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55333. import { Scene } from "babylonjs/scene";
  55334. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55335. import { Mesh } from "babylonjs/Meshes/mesh";
  55336. import { Nullable } from "babylonjs/types";
  55337. /**
  55338. * Class containing static functions to help procedurally build meshes
  55339. */
  55340. export class PolygonBuilder {
  55341. /**
  55342. * Creates a polygon mesh
  55343. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55344. * * 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
  55345. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55348. * * Remember you can only change the shape positions, not their number when updating a polygon
  55349. * @param name defines the name of the mesh
  55350. * @param options defines the options used to create the mesh
  55351. * @param scene defines the hosting scene
  55352. * @param earcutInjection can be used to inject your own earcut reference
  55353. * @returns the polygon mesh
  55354. */
  55355. static CreatePolygon(name: string, options: {
  55356. shape: Vector3[];
  55357. holes?: Vector3[][];
  55358. depth?: number;
  55359. faceUV?: Vector4[];
  55360. faceColors?: Color4[];
  55361. updatable?: boolean;
  55362. sideOrientation?: number;
  55363. frontUVs?: Vector4;
  55364. backUVs?: Vector4;
  55365. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55366. /**
  55367. * Creates an extruded polygon mesh, with depth in the Y direction.
  55368. * * 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)
  55369. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55370. * @param name defines the name of the mesh
  55371. * @param options defines the options used to create the mesh
  55372. * @param scene defines the hosting scene
  55373. * @param earcutInjection can be used to inject your own earcut reference
  55374. * @returns the polygon mesh
  55375. */
  55376. static ExtrudePolygon(name: string, options: {
  55377. shape: Vector3[];
  55378. holes?: Vector3[][];
  55379. depth?: number;
  55380. faceUV?: Vector4[];
  55381. faceColors?: Color4[];
  55382. updatable?: boolean;
  55383. sideOrientation?: number;
  55384. frontUVs?: Vector4;
  55385. backUVs?: Vector4;
  55386. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55387. }
  55388. }
  55389. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55390. import { Scene } from "babylonjs/scene";
  55391. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55392. import { Mesh } from "babylonjs/Meshes/mesh";
  55393. import { Nullable } from "babylonjs/types";
  55394. /**
  55395. * Class containing static functions to help procedurally build meshes
  55396. */
  55397. export class LatheBuilder {
  55398. /**
  55399. * Creates lathe mesh.
  55400. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55401. * * 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
  55402. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55403. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55404. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55405. * * 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
  55406. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55407. * * 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
  55408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55412. * @param name defines the name of the mesh
  55413. * @param options defines the options used to create the mesh
  55414. * @param scene defines the hosting scene
  55415. * @returns the lathe mesh
  55416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55417. */
  55418. static CreateLathe(name: string, options: {
  55419. shape: Vector3[];
  55420. radius?: number;
  55421. tessellation?: number;
  55422. clip?: number;
  55423. arc?: number;
  55424. closed?: boolean;
  55425. updatable?: boolean;
  55426. sideOrientation?: number;
  55427. frontUVs?: Vector4;
  55428. backUVs?: Vector4;
  55429. cap?: number;
  55430. invertUV?: boolean;
  55431. }, scene?: Nullable<Scene>): Mesh;
  55432. }
  55433. }
  55434. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55435. import { Nullable } from "babylonjs/types";
  55436. import { Scene } from "babylonjs/scene";
  55437. import { Vector4 } from "babylonjs/Maths/math";
  55438. import { Mesh } from "babylonjs/Meshes/mesh";
  55439. /**
  55440. * Class containing static functions to help procedurally build meshes
  55441. */
  55442. export class TiledPlaneBuilder {
  55443. /**
  55444. * Creates a tiled plane mesh
  55445. * * The parameter `pattern` will, depending on value, do nothing or
  55446. * * * flip (reflect about central vertical) alternate tiles across and up
  55447. * * * flip every tile on alternate rows
  55448. * * * rotate (180 degs) alternate tiles across and up
  55449. * * * rotate every tile on alternate rows
  55450. * * * flip and rotate alternate tiles across and up
  55451. * * * flip and rotate every tile on alternate rows
  55452. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55453. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55456. * * 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)
  55457. * * 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)
  55458. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55459. * @param name defines the name of the mesh
  55460. * @param options defines the options used to create the mesh
  55461. * @param scene defines the hosting scene
  55462. * @returns the box mesh
  55463. */
  55464. static CreateTiledPlane(name: string, options: {
  55465. pattern?: number;
  55466. tileSize?: number;
  55467. tileWidth?: number;
  55468. tileHeight?: number;
  55469. size?: number;
  55470. width?: number;
  55471. height?: number;
  55472. alignHorizontal?: number;
  55473. alignVertical?: number;
  55474. sideOrientation?: number;
  55475. frontUVs?: Vector4;
  55476. backUVs?: Vector4;
  55477. updatable?: boolean;
  55478. }, scene?: Nullable<Scene>): Mesh;
  55479. }
  55480. }
  55481. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55482. import { Nullable } from "babylonjs/types";
  55483. import { Scene } from "babylonjs/scene";
  55484. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55485. import { Mesh } from "babylonjs/Meshes/mesh";
  55486. /**
  55487. * Class containing static functions to help procedurally build meshes
  55488. */
  55489. export class TubeBuilder {
  55490. /**
  55491. * Creates a tube mesh.
  55492. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55493. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55494. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55495. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55496. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55497. * * 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)
  55498. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55499. * * 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
  55500. * * 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
  55501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55505. * @param name defines the name of the mesh
  55506. * @param options defines the options used to create the mesh
  55507. * @param scene defines the hosting scene
  55508. * @returns the tube mesh
  55509. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55510. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55511. */
  55512. static CreateTube(name: string, options: {
  55513. path: Vector3[];
  55514. radius?: number;
  55515. tessellation?: number;
  55516. radiusFunction?: {
  55517. (i: number, distance: number): number;
  55518. };
  55519. cap?: number;
  55520. arc?: number;
  55521. updatable?: boolean;
  55522. sideOrientation?: number;
  55523. frontUVs?: Vector4;
  55524. backUVs?: Vector4;
  55525. instance?: Mesh;
  55526. invertUV?: boolean;
  55527. }, scene?: Nullable<Scene>): Mesh;
  55528. }
  55529. }
  55530. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55531. import { Scene } from "babylonjs/scene";
  55532. import { Vector4 } from "babylonjs/Maths/math";
  55533. import { Mesh } from "babylonjs/Meshes/mesh";
  55534. import { Nullable } from "babylonjs/types";
  55535. /**
  55536. * Class containing static functions to help procedurally build meshes
  55537. */
  55538. export class IcoSphereBuilder {
  55539. /**
  55540. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55541. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55542. * * 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`)
  55543. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55544. * * 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
  55545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55548. * @param name defines the name of the mesh
  55549. * @param options defines the options used to create the mesh
  55550. * @param scene defines the hosting scene
  55551. * @returns the icosahedron mesh
  55552. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55553. */
  55554. static CreateIcoSphere(name: string, options: {
  55555. radius?: number;
  55556. radiusX?: number;
  55557. radiusY?: number;
  55558. radiusZ?: number;
  55559. flat?: boolean;
  55560. subdivisions?: number;
  55561. sideOrientation?: number;
  55562. frontUVs?: Vector4;
  55563. backUVs?: Vector4;
  55564. updatable?: boolean;
  55565. }, scene?: Nullable<Scene>): Mesh;
  55566. }
  55567. }
  55568. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55569. import { Vector3 } from "babylonjs/Maths/math";
  55570. import { Mesh } from "babylonjs/Meshes/mesh";
  55571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55572. /**
  55573. * Class containing static functions to help procedurally build meshes
  55574. */
  55575. export class DecalBuilder {
  55576. /**
  55577. * Creates a decal mesh.
  55578. * 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
  55579. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55580. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55581. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55582. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55583. * @param name defines the name of the mesh
  55584. * @param sourceMesh defines the mesh where the decal must be applied
  55585. * @param options defines the options used to create the mesh
  55586. * @param scene defines the hosting scene
  55587. * @returns the decal mesh
  55588. * @see https://doc.babylonjs.com/how_to/decals
  55589. */
  55590. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55591. position?: Vector3;
  55592. normal?: Vector3;
  55593. size?: Vector3;
  55594. angle?: number;
  55595. }): Mesh;
  55596. }
  55597. }
  55598. declare module "babylonjs/Meshes/meshBuilder" {
  55599. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55600. import { Nullable } from "babylonjs/types";
  55601. import { Scene } from "babylonjs/scene";
  55602. import { Mesh } from "babylonjs/Meshes/mesh";
  55603. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55604. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55606. /**
  55607. * Class containing static functions to help procedurally build meshes
  55608. */
  55609. export class MeshBuilder {
  55610. /**
  55611. * Creates a box mesh
  55612. * * The parameter `size` sets the size (float) of each box side (default 1)
  55613. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55614. * * 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)
  55615. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55619. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55620. * @param name defines the name of the mesh
  55621. * @param options defines the options used to create the mesh
  55622. * @param scene defines the hosting scene
  55623. * @returns the box mesh
  55624. */
  55625. static CreateBox(name: string, options: {
  55626. size?: number;
  55627. width?: number;
  55628. height?: number;
  55629. depth?: number;
  55630. faceUV?: Vector4[];
  55631. faceColors?: Color4[];
  55632. sideOrientation?: number;
  55633. frontUVs?: Vector4;
  55634. backUVs?: Vector4;
  55635. updatable?: boolean;
  55636. }, scene?: Nullable<Scene>): Mesh;
  55637. /**
  55638. * Creates a tiled box mesh
  55639. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55641. * @param name defines the name of the mesh
  55642. * @param options defines the options used to create the mesh
  55643. * @param scene defines the hosting scene
  55644. * @returns the tiled box mesh
  55645. */
  55646. static CreateTiledBox(name: string, options: {
  55647. pattern?: number;
  55648. size?: number;
  55649. width?: number;
  55650. height?: number;
  55651. depth: number;
  55652. tileSize?: number;
  55653. tileWidth?: number;
  55654. tileHeight?: number;
  55655. faceUV?: Vector4[];
  55656. faceColors?: Color4[];
  55657. alignHorizontal?: number;
  55658. alignVertical?: number;
  55659. sideOrientation?: number;
  55660. updatable?: boolean;
  55661. }, scene?: Nullable<Scene>): Mesh;
  55662. /**
  55663. * Creates a sphere mesh
  55664. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55665. * * 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`)
  55666. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55667. * * 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
  55668. * * 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)
  55669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55672. * @param name defines the name of the mesh
  55673. * @param options defines the options used to create the mesh
  55674. * @param scene defines the hosting scene
  55675. * @returns the sphere mesh
  55676. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55677. */
  55678. static CreateSphere(name: string, options: {
  55679. segments?: number;
  55680. diameter?: number;
  55681. diameterX?: number;
  55682. diameterY?: number;
  55683. diameterZ?: number;
  55684. arc?: number;
  55685. slice?: number;
  55686. sideOrientation?: number;
  55687. frontUVs?: Vector4;
  55688. backUVs?: Vector4;
  55689. updatable?: boolean;
  55690. }, scene?: Nullable<Scene>): Mesh;
  55691. /**
  55692. * Creates a plane polygonal mesh. By default, this is a disc
  55693. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55694. * * 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
  55695. * * 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
  55696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55699. * @param name defines the name of the mesh
  55700. * @param options defines the options used to create the mesh
  55701. * @param scene defines the hosting scene
  55702. * @returns the plane polygonal mesh
  55703. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55704. */
  55705. static CreateDisc(name: string, options: {
  55706. radius?: number;
  55707. tessellation?: number;
  55708. arc?: number;
  55709. updatable?: boolean;
  55710. sideOrientation?: number;
  55711. frontUVs?: Vector4;
  55712. backUVs?: Vector4;
  55713. }, scene?: Nullable<Scene>): Mesh;
  55714. /**
  55715. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55716. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55717. * * 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`)
  55718. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55719. * * 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
  55720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55723. * @param name defines the name of the mesh
  55724. * @param options defines the options used to create the mesh
  55725. * @param scene defines the hosting scene
  55726. * @returns the icosahedron mesh
  55727. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55728. */
  55729. static CreateIcoSphere(name: string, options: {
  55730. radius?: number;
  55731. radiusX?: number;
  55732. radiusY?: number;
  55733. radiusZ?: number;
  55734. flat?: boolean;
  55735. subdivisions?: number;
  55736. sideOrientation?: number;
  55737. frontUVs?: Vector4;
  55738. backUVs?: Vector4;
  55739. updatable?: boolean;
  55740. }, scene?: Nullable<Scene>): Mesh;
  55741. /**
  55742. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55743. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55744. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55745. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55746. * * 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
  55747. * * 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
  55748. * * 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
  55749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55752. * * 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
  55753. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55754. * * 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
  55755. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55757. * @param name defines the name of the mesh
  55758. * @param options defines the options used to create the mesh
  55759. * @param scene defines the hosting scene
  55760. * @returns the ribbon mesh
  55761. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55763. */
  55764. static CreateRibbon(name: string, options: {
  55765. pathArray: Vector3[][];
  55766. closeArray?: boolean;
  55767. closePath?: boolean;
  55768. offset?: number;
  55769. updatable?: boolean;
  55770. sideOrientation?: number;
  55771. frontUVs?: Vector4;
  55772. backUVs?: Vector4;
  55773. instance?: Mesh;
  55774. invertUV?: boolean;
  55775. uvs?: Vector2[];
  55776. colors?: Color4[];
  55777. }, scene?: Nullable<Scene>): Mesh;
  55778. /**
  55779. * Creates a cylinder or a cone mesh
  55780. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55781. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55782. * * 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.
  55783. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55784. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55785. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55786. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55787. * * 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).
  55788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55789. * * 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).
  55790. * * 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
  55791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55792. * * 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
  55793. * * 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.
  55794. * * If `enclose` is false, a ring surface is one element.
  55795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55796. * * 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
  55797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55800. * @param name defines the name of the mesh
  55801. * @param options defines the options used to create the mesh
  55802. * @param scene defines the hosting scene
  55803. * @returns the cylinder mesh
  55804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55805. */
  55806. static CreateCylinder(name: string, options: {
  55807. height?: number;
  55808. diameterTop?: number;
  55809. diameterBottom?: number;
  55810. diameter?: number;
  55811. tessellation?: number;
  55812. subdivisions?: number;
  55813. arc?: number;
  55814. faceColors?: Color4[];
  55815. faceUV?: Vector4[];
  55816. updatable?: boolean;
  55817. hasRings?: boolean;
  55818. enclose?: boolean;
  55819. cap?: number;
  55820. sideOrientation?: number;
  55821. frontUVs?: Vector4;
  55822. backUVs?: Vector4;
  55823. }, scene?: Nullable<Scene>): Mesh;
  55824. /**
  55825. * Creates a torus mesh
  55826. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55827. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55828. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55832. * @param name defines the name of the mesh
  55833. * @param options defines the options used to create the mesh
  55834. * @param scene defines the hosting scene
  55835. * @returns the torus mesh
  55836. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55837. */
  55838. static CreateTorus(name: string, options: {
  55839. diameter?: number;
  55840. thickness?: number;
  55841. tessellation?: number;
  55842. updatable?: boolean;
  55843. sideOrientation?: number;
  55844. frontUVs?: Vector4;
  55845. backUVs?: Vector4;
  55846. }, scene?: Nullable<Scene>): Mesh;
  55847. /**
  55848. * Creates a torus knot mesh
  55849. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55850. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55851. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55852. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55856. * @param name defines the name of the mesh
  55857. * @param options defines the options used to create the mesh
  55858. * @param scene defines the hosting scene
  55859. * @returns the torus knot mesh
  55860. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55861. */
  55862. static CreateTorusKnot(name: string, options: {
  55863. radius?: number;
  55864. tube?: number;
  55865. radialSegments?: number;
  55866. tubularSegments?: number;
  55867. p?: number;
  55868. q?: number;
  55869. updatable?: boolean;
  55870. sideOrientation?: number;
  55871. frontUVs?: Vector4;
  55872. backUVs?: Vector4;
  55873. }, scene?: Nullable<Scene>): Mesh;
  55874. /**
  55875. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55876. * * 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
  55877. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55878. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55879. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55880. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55881. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55882. * * 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
  55883. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55885. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55886. * @param name defines the name of the new line system
  55887. * @param options defines the options used to create the line system
  55888. * @param scene defines the hosting scene
  55889. * @returns a new line system mesh
  55890. */
  55891. static CreateLineSystem(name: string, options: {
  55892. lines: Vector3[][];
  55893. updatable?: boolean;
  55894. instance?: Nullable<LinesMesh>;
  55895. colors?: Nullable<Color4[][]>;
  55896. useVertexAlpha?: boolean;
  55897. }, scene: Nullable<Scene>): LinesMesh;
  55898. /**
  55899. * Creates a line mesh
  55900. * 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
  55901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55902. * * The parameter `points` is an array successive Vector3
  55903. * * 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
  55904. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55905. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55906. * * When updating an instance, remember that only point positions can change, not the number of points
  55907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55909. * @param name defines the name of the new line system
  55910. * @param options defines the options used to create the line system
  55911. * @param scene defines the hosting scene
  55912. * @returns a new line mesh
  55913. */
  55914. static CreateLines(name: string, options: {
  55915. points: Vector3[];
  55916. updatable?: boolean;
  55917. instance?: Nullable<LinesMesh>;
  55918. colors?: Color4[];
  55919. useVertexAlpha?: boolean;
  55920. }, scene?: Nullable<Scene>): LinesMesh;
  55921. /**
  55922. * Creates a dashed line mesh
  55923. * * 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
  55924. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55925. * * The parameter `points` is an array successive Vector3
  55926. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55927. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55928. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55929. * * 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
  55930. * * When updating an instance, remember that only point positions can change, not the number of points
  55931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55932. * @param name defines the name of the mesh
  55933. * @param options defines the options used to create the mesh
  55934. * @param scene defines the hosting scene
  55935. * @returns the dashed line mesh
  55936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55937. */
  55938. static CreateDashedLines(name: string, options: {
  55939. points: Vector3[];
  55940. dashSize?: number;
  55941. gapSize?: number;
  55942. dashNb?: number;
  55943. updatable?: boolean;
  55944. instance?: LinesMesh;
  55945. }, scene?: Nullable<Scene>): LinesMesh;
  55946. /**
  55947. * 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.
  55948. * * 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.
  55949. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55950. * * 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.
  55951. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55952. * * 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
  55953. * * 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
  55954. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55959. * @param name defines the name of the mesh
  55960. * @param options defines the options used to create the mesh
  55961. * @param scene defines the hosting scene
  55962. * @returns the extruded shape mesh
  55963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55965. */
  55966. static ExtrudeShape(name: string, options: {
  55967. shape: Vector3[];
  55968. path: Vector3[];
  55969. scale?: number;
  55970. rotation?: number;
  55971. cap?: number;
  55972. updatable?: boolean;
  55973. sideOrientation?: number;
  55974. frontUVs?: Vector4;
  55975. backUVs?: Vector4;
  55976. instance?: Mesh;
  55977. invertUV?: boolean;
  55978. }, scene?: Nullable<Scene>): Mesh;
  55979. /**
  55980. * Creates an custom extruded shape mesh.
  55981. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55982. * * 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.
  55983. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55984. * * 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
  55985. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55986. * * 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
  55987. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55988. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55989. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55990. * * 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
  55991. * * 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
  55992. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55997. * @param name defines the name of the mesh
  55998. * @param options defines the options used to create the mesh
  55999. * @param scene defines the hosting scene
  56000. * @returns the custom extruded shape mesh
  56001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56004. */
  56005. static ExtrudeShapeCustom(name: string, options: {
  56006. shape: Vector3[];
  56007. path: Vector3[];
  56008. scaleFunction?: any;
  56009. rotationFunction?: any;
  56010. ribbonCloseArray?: boolean;
  56011. ribbonClosePath?: boolean;
  56012. cap?: number;
  56013. updatable?: boolean;
  56014. sideOrientation?: number;
  56015. frontUVs?: Vector4;
  56016. backUVs?: Vector4;
  56017. instance?: Mesh;
  56018. invertUV?: boolean;
  56019. }, scene?: Nullable<Scene>): Mesh;
  56020. /**
  56021. * Creates lathe mesh.
  56022. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56023. * * 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
  56024. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56025. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56026. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56027. * * 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
  56028. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56029. * * 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
  56030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56034. * @param name defines the name of the mesh
  56035. * @param options defines the options used to create the mesh
  56036. * @param scene defines the hosting scene
  56037. * @returns the lathe mesh
  56038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56039. */
  56040. static CreateLathe(name: string, options: {
  56041. shape: Vector3[];
  56042. radius?: number;
  56043. tessellation?: number;
  56044. clip?: number;
  56045. arc?: number;
  56046. closed?: boolean;
  56047. updatable?: boolean;
  56048. sideOrientation?: number;
  56049. frontUVs?: Vector4;
  56050. backUVs?: Vector4;
  56051. cap?: number;
  56052. invertUV?: boolean;
  56053. }, scene?: Nullable<Scene>): Mesh;
  56054. /**
  56055. * Creates a tiled plane mesh
  56056. * * You can set a limited pattern arrangement with the tiles
  56057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56060. * @param name defines the name of the mesh
  56061. * @param options defines the options used to create the mesh
  56062. * @param scene defines the hosting scene
  56063. * @returns the plane mesh
  56064. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56065. */
  56066. static CreateTiledPlane(name: string, options: {
  56067. pattern?: number;
  56068. tileSize?: number;
  56069. tileWidth?: number;
  56070. tileHeight?: number;
  56071. size?: number;
  56072. width?: number;
  56073. height?: number;
  56074. alignHorizontal?: number;
  56075. alignVertical?: number;
  56076. sideOrientation?: number;
  56077. frontUVs?: Vector4;
  56078. backUVs?: Vector4;
  56079. updatable?: boolean;
  56080. }, scene?: Nullable<Scene>): Mesh;
  56081. /**
  56082. * Creates a plane mesh
  56083. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56084. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56085. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56089. * @param name defines the name of the mesh
  56090. * @param options defines the options used to create the mesh
  56091. * @param scene defines the hosting scene
  56092. * @returns the plane mesh
  56093. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56094. */
  56095. static CreatePlane(name: string, options: {
  56096. size?: number;
  56097. width?: number;
  56098. height?: number;
  56099. sideOrientation?: number;
  56100. frontUVs?: Vector4;
  56101. backUVs?: Vector4;
  56102. updatable?: boolean;
  56103. sourcePlane?: Plane;
  56104. }, scene?: Nullable<Scene>): Mesh;
  56105. /**
  56106. * Creates a ground mesh
  56107. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56108. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56110. * @param name defines the name of the mesh
  56111. * @param options defines the options used to create the mesh
  56112. * @param scene defines the hosting scene
  56113. * @returns the ground mesh
  56114. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56115. */
  56116. static CreateGround(name: string, options: {
  56117. width?: number;
  56118. height?: number;
  56119. subdivisions?: number;
  56120. subdivisionsX?: number;
  56121. subdivisionsY?: number;
  56122. updatable?: boolean;
  56123. }, scene?: Nullable<Scene>): Mesh;
  56124. /**
  56125. * Creates a tiled ground mesh
  56126. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56127. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56128. * * 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
  56129. * * 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
  56130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56131. * @param name defines the name of the mesh
  56132. * @param options defines the options used to create the mesh
  56133. * @param scene defines the hosting scene
  56134. * @returns the tiled ground mesh
  56135. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56136. */
  56137. static CreateTiledGround(name: string, options: {
  56138. xmin: number;
  56139. zmin: number;
  56140. xmax: number;
  56141. zmax: number;
  56142. subdivisions?: {
  56143. w: number;
  56144. h: number;
  56145. };
  56146. precision?: {
  56147. w: number;
  56148. h: number;
  56149. };
  56150. updatable?: boolean;
  56151. }, scene?: Nullable<Scene>): Mesh;
  56152. /**
  56153. * Creates a ground mesh from a height map
  56154. * * The parameter `url` sets the URL of the height map image resource.
  56155. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56156. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56157. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56158. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56159. * * 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.
  56160. * * 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).
  56161. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56163. * @param name defines the name of the mesh
  56164. * @param url defines the url to the height map
  56165. * @param options defines the options used to create the mesh
  56166. * @param scene defines the hosting scene
  56167. * @returns the ground mesh
  56168. * @see https://doc.babylonjs.com/babylon101/height_map
  56169. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56170. */
  56171. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56172. width?: number;
  56173. height?: number;
  56174. subdivisions?: number;
  56175. minHeight?: number;
  56176. maxHeight?: number;
  56177. colorFilter?: Color3;
  56178. alphaFilter?: number;
  56179. updatable?: boolean;
  56180. onReady?: (mesh: GroundMesh) => void;
  56181. }, scene?: Nullable<Scene>): GroundMesh;
  56182. /**
  56183. * Creates a polygon mesh
  56184. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56185. * * 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
  56186. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56189. * * Remember you can only change the shape positions, not their number when updating a polygon
  56190. * @param name defines the name of the mesh
  56191. * @param options defines the options used to create the mesh
  56192. * @param scene defines the hosting scene
  56193. * @param earcutInjection can be used to inject your own earcut reference
  56194. * @returns the polygon mesh
  56195. */
  56196. static CreatePolygon(name: string, options: {
  56197. shape: Vector3[];
  56198. holes?: Vector3[][];
  56199. depth?: number;
  56200. faceUV?: Vector4[];
  56201. faceColors?: Color4[];
  56202. updatable?: boolean;
  56203. sideOrientation?: number;
  56204. frontUVs?: Vector4;
  56205. backUVs?: Vector4;
  56206. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56207. /**
  56208. * Creates an extruded polygon mesh, with depth in the Y direction.
  56209. * * 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)
  56210. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56211. * @param name defines the name of the mesh
  56212. * @param options defines the options used to create the mesh
  56213. * @param scene defines the hosting scene
  56214. * @param earcutInjection can be used to inject your own earcut reference
  56215. * @returns the polygon mesh
  56216. */
  56217. static ExtrudePolygon(name: string, options: {
  56218. shape: Vector3[];
  56219. holes?: Vector3[][];
  56220. depth?: number;
  56221. faceUV?: Vector4[];
  56222. faceColors?: Color4[];
  56223. updatable?: boolean;
  56224. sideOrientation?: number;
  56225. frontUVs?: Vector4;
  56226. backUVs?: Vector4;
  56227. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56228. /**
  56229. * Creates a tube mesh.
  56230. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56231. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56232. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56233. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56234. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56235. * * 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)
  56236. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56237. * * 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
  56238. * * 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
  56239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56243. * @param name defines the name of the mesh
  56244. * @param options defines the options used to create the mesh
  56245. * @param scene defines the hosting scene
  56246. * @returns the tube mesh
  56247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56248. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56249. */
  56250. static CreateTube(name: string, options: {
  56251. path: Vector3[];
  56252. radius?: number;
  56253. tessellation?: number;
  56254. radiusFunction?: {
  56255. (i: number, distance: number): number;
  56256. };
  56257. cap?: number;
  56258. arc?: number;
  56259. updatable?: boolean;
  56260. sideOrientation?: number;
  56261. frontUVs?: Vector4;
  56262. backUVs?: Vector4;
  56263. instance?: Mesh;
  56264. invertUV?: boolean;
  56265. }, scene?: Nullable<Scene>): Mesh;
  56266. /**
  56267. * Creates a polyhedron mesh
  56268. * * 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
  56269. * * The parameter `size` (positive float, default 1) sets the polygon size
  56270. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56271. * * 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`
  56272. * * 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
  56273. * * 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)`)
  56274. * * 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
  56275. * * 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
  56276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56279. * @param name defines the name of the mesh
  56280. * @param options defines the options used to create the mesh
  56281. * @param scene defines the hosting scene
  56282. * @returns the polyhedron mesh
  56283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56284. */
  56285. static CreatePolyhedron(name: string, options: {
  56286. type?: number;
  56287. size?: number;
  56288. sizeX?: number;
  56289. sizeY?: number;
  56290. sizeZ?: number;
  56291. custom?: any;
  56292. faceUV?: Vector4[];
  56293. faceColors?: Color4[];
  56294. flat?: boolean;
  56295. updatable?: boolean;
  56296. sideOrientation?: number;
  56297. frontUVs?: Vector4;
  56298. backUVs?: Vector4;
  56299. }, scene?: Nullable<Scene>): Mesh;
  56300. /**
  56301. * Creates a decal mesh.
  56302. * 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
  56303. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56304. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56305. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56306. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56307. * @param name defines the name of the mesh
  56308. * @param sourceMesh defines the mesh where the decal must be applied
  56309. * @param options defines the options used to create the mesh
  56310. * @param scene defines the hosting scene
  56311. * @returns the decal mesh
  56312. * @see https://doc.babylonjs.com/how_to/decals
  56313. */
  56314. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56315. position?: Vector3;
  56316. normal?: Vector3;
  56317. size?: Vector3;
  56318. angle?: number;
  56319. }): Mesh;
  56320. }
  56321. }
  56322. declare module "babylonjs/Meshes/meshSimplification" {
  56323. import { Mesh } from "babylonjs/Meshes/mesh";
  56324. /**
  56325. * A simplifier interface for future simplification implementations
  56326. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56327. */
  56328. export interface ISimplifier {
  56329. /**
  56330. * Simplification of a given mesh according to the given settings.
  56331. * Since this requires computation, it is assumed that the function runs async.
  56332. * @param settings The settings of the simplification, including quality and distance
  56333. * @param successCallback A callback that will be called after the mesh was simplified.
  56334. * @param errorCallback in case of an error, this callback will be called. optional.
  56335. */
  56336. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56337. }
  56338. /**
  56339. * Expected simplification settings.
  56340. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56341. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56342. */
  56343. export interface ISimplificationSettings {
  56344. /**
  56345. * Gets or sets the expected quality
  56346. */
  56347. quality: number;
  56348. /**
  56349. * Gets or sets the distance when this optimized version should be used
  56350. */
  56351. distance: number;
  56352. /**
  56353. * Gets an already optimized mesh
  56354. */
  56355. optimizeMesh?: boolean;
  56356. }
  56357. /**
  56358. * Class used to specify simplification options
  56359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56360. */
  56361. export class SimplificationSettings implements ISimplificationSettings {
  56362. /** expected quality */
  56363. quality: number;
  56364. /** distance when this optimized version should be used */
  56365. distance: number;
  56366. /** already optimized mesh */
  56367. optimizeMesh?: boolean | undefined;
  56368. /**
  56369. * Creates a SimplificationSettings
  56370. * @param quality expected quality
  56371. * @param distance distance when this optimized version should be used
  56372. * @param optimizeMesh already optimized mesh
  56373. */
  56374. constructor(
  56375. /** expected quality */
  56376. quality: number,
  56377. /** distance when this optimized version should be used */
  56378. distance: number,
  56379. /** already optimized mesh */
  56380. optimizeMesh?: boolean | undefined);
  56381. }
  56382. /**
  56383. * Interface used to define a simplification task
  56384. */
  56385. export interface ISimplificationTask {
  56386. /**
  56387. * Array of settings
  56388. */
  56389. settings: Array<ISimplificationSettings>;
  56390. /**
  56391. * Simplification type
  56392. */
  56393. simplificationType: SimplificationType;
  56394. /**
  56395. * Mesh to simplify
  56396. */
  56397. mesh: Mesh;
  56398. /**
  56399. * Callback called on success
  56400. */
  56401. successCallback?: () => void;
  56402. /**
  56403. * Defines if parallel processing can be used
  56404. */
  56405. parallelProcessing: boolean;
  56406. }
  56407. /**
  56408. * Queue used to order the simplification tasks
  56409. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56410. */
  56411. export class SimplificationQueue {
  56412. private _simplificationArray;
  56413. /**
  56414. * Gets a boolean indicating that the process is still running
  56415. */
  56416. running: boolean;
  56417. /**
  56418. * Creates a new queue
  56419. */
  56420. constructor();
  56421. /**
  56422. * Adds a new simplification task
  56423. * @param task defines a task to add
  56424. */
  56425. addTask(task: ISimplificationTask): void;
  56426. /**
  56427. * Execute next task
  56428. */
  56429. executeNext(): void;
  56430. /**
  56431. * Execute a simplification task
  56432. * @param task defines the task to run
  56433. */
  56434. runSimplification(task: ISimplificationTask): void;
  56435. private getSimplifier;
  56436. }
  56437. /**
  56438. * The implemented types of simplification
  56439. * At the moment only Quadratic Error Decimation is implemented
  56440. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56441. */
  56442. export enum SimplificationType {
  56443. /** Quadratic error decimation */
  56444. QUADRATIC = 0
  56445. }
  56446. }
  56447. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56448. import { Scene } from "babylonjs/scene";
  56449. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56450. import { ISceneComponent } from "babylonjs/sceneComponent";
  56451. module "babylonjs/scene" {
  56452. interface Scene {
  56453. /** @hidden (Backing field) */
  56454. _simplificationQueue: SimplificationQueue;
  56455. /**
  56456. * Gets or sets the simplification queue attached to the scene
  56457. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56458. */
  56459. simplificationQueue: SimplificationQueue;
  56460. }
  56461. }
  56462. module "babylonjs/Meshes/mesh" {
  56463. interface Mesh {
  56464. /**
  56465. * Simplify the mesh according to the given array of settings.
  56466. * Function will return immediately and will simplify async
  56467. * @param settings a collection of simplification settings
  56468. * @param parallelProcessing should all levels calculate parallel or one after the other
  56469. * @param simplificationType the type of simplification to run
  56470. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56471. * @returns the current mesh
  56472. */
  56473. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56474. }
  56475. }
  56476. /**
  56477. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56478. * created in a scene
  56479. */
  56480. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56481. /**
  56482. * The component name helpfull to identify the component in the list of scene components.
  56483. */
  56484. readonly name: string;
  56485. /**
  56486. * The scene the component belongs to.
  56487. */
  56488. scene: Scene;
  56489. /**
  56490. * Creates a new instance of the component for the given scene
  56491. * @param scene Defines the scene to register the component in
  56492. */
  56493. constructor(scene: Scene);
  56494. /**
  56495. * Registers the component in a given scene
  56496. */
  56497. register(): void;
  56498. /**
  56499. * Rebuilds the elements related to this component in case of
  56500. * context lost for instance.
  56501. */
  56502. rebuild(): void;
  56503. /**
  56504. * Disposes the component and the associated ressources
  56505. */
  56506. dispose(): void;
  56507. private _beforeCameraUpdate;
  56508. }
  56509. }
  56510. declare module "babylonjs/Meshes/Builders/index" {
  56511. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56512. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56513. export * from "babylonjs/Meshes/Builders/discBuilder";
  56514. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56515. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56516. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56517. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56518. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56519. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56520. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56521. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56522. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56523. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56524. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56525. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56526. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56527. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56528. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56529. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56530. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56531. }
  56532. declare module "babylonjs/Meshes/index" {
  56533. export * from "babylonjs/Meshes/abstractMesh";
  56534. export * from "babylonjs/Meshes/buffer";
  56535. export * from "babylonjs/Meshes/Compression/index";
  56536. export * from "babylonjs/Meshes/csg";
  56537. export * from "babylonjs/Meshes/geometry";
  56538. export * from "babylonjs/Meshes/groundMesh";
  56539. export * from "babylonjs/Meshes/trailMesh";
  56540. export * from "babylonjs/Meshes/instancedMesh";
  56541. export * from "babylonjs/Meshes/linesMesh";
  56542. export * from "babylonjs/Meshes/mesh";
  56543. export * from "babylonjs/Meshes/mesh.vertexData";
  56544. export * from "babylonjs/Meshes/meshBuilder";
  56545. export * from "babylonjs/Meshes/meshSimplification";
  56546. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56547. export * from "babylonjs/Meshes/polygonMesh";
  56548. export * from "babylonjs/Meshes/subMesh";
  56549. export * from "babylonjs/Meshes/meshLODLevel";
  56550. export * from "babylonjs/Meshes/transformNode";
  56551. export * from "babylonjs/Meshes/Builders/index";
  56552. export * from "babylonjs/Meshes/dataBuffer";
  56553. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56554. }
  56555. declare module "babylonjs/Morph/index" {
  56556. export * from "babylonjs/Morph/morphTarget";
  56557. export * from "babylonjs/Morph/morphTargetManager";
  56558. }
  56559. declare module "babylonjs/Offline/database" {
  56560. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56561. /**
  56562. * Class used to enable access to IndexedDB
  56563. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56564. */
  56565. export class Database implements IOfflineProvider {
  56566. private _callbackManifestChecked;
  56567. private _currentSceneUrl;
  56568. private _db;
  56569. private _enableSceneOffline;
  56570. private _enableTexturesOffline;
  56571. private _manifestVersionFound;
  56572. private _mustUpdateRessources;
  56573. private _hasReachedQuota;
  56574. private _isSupported;
  56575. private _idbFactory;
  56576. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56577. private static IsUASupportingBlobStorage;
  56578. /**
  56579. * Gets a boolean indicating if Database storate is enabled (off by default)
  56580. */
  56581. static IDBStorageEnabled: boolean;
  56582. /**
  56583. * Gets a boolean indicating if scene must be saved in the database
  56584. */
  56585. readonly enableSceneOffline: boolean;
  56586. /**
  56587. * Gets a boolean indicating if textures must be saved in the database
  56588. */
  56589. readonly enableTexturesOffline: boolean;
  56590. /**
  56591. * Creates a new Database
  56592. * @param urlToScene defines the url to load the scene
  56593. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56594. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56595. */
  56596. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56597. private static _ParseURL;
  56598. private static _ReturnFullUrlLocation;
  56599. private _checkManifestFile;
  56600. /**
  56601. * Open the database and make it available
  56602. * @param successCallback defines the callback to call on success
  56603. * @param errorCallback defines the callback to call on error
  56604. */
  56605. open(successCallback: () => void, errorCallback: () => void): void;
  56606. /**
  56607. * Loads an image from the database
  56608. * @param url defines the url to load from
  56609. * @param image defines the target DOM image
  56610. */
  56611. loadImage(url: string, image: HTMLImageElement): void;
  56612. private _loadImageFromDBAsync;
  56613. private _saveImageIntoDBAsync;
  56614. private _checkVersionFromDB;
  56615. private _loadVersionFromDBAsync;
  56616. private _saveVersionIntoDBAsync;
  56617. /**
  56618. * Loads a file from database
  56619. * @param url defines the URL to load from
  56620. * @param sceneLoaded defines a callback to call on success
  56621. * @param progressCallBack defines a callback to call when progress changed
  56622. * @param errorCallback defines a callback to call on error
  56623. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56624. */
  56625. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56626. private _loadFileAsync;
  56627. private _saveFileAsync;
  56628. /**
  56629. * Validates if xhr data is correct
  56630. * @param xhr defines the request to validate
  56631. * @param dataType defines the expected data type
  56632. * @returns true if data is correct
  56633. */
  56634. private static _ValidateXHRData;
  56635. }
  56636. }
  56637. declare module "babylonjs/Offline/index" {
  56638. export * from "babylonjs/Offline/database";
  56639. export * from "babylonjs/Offline/IOfflineProvider";
  56640. }
  56641. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56642. /** @hidden */
  56643. export var gpuUpdateParticlesPixelShader: {
  56644. name: string;
  56645. shader: string;
  56646. };
  56647. }
  56648. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56649. /** @hidden */
  56650. export var gpuUpdateParticlesVertexShader: {
  56651. name: string;
  56652. shader: string;
  56653. };
  56654. }
  56655. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56656. /** @hidden */
  56657. export var clipPlaneFragmentDeclaration2: {
  56658. name: string;
  56659. shader: string;
  56660. };
  56661. }
  56662. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56663. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56664. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56665. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56666. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56667. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56668. /** @hidden */
  56669. export var gpuRenderParticlesPixelShader: {
  56670. name: string;
  56671. shader: string;
  56672. };
  56673. }
  56674. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56675. /** @hidden */
  56676. export var clipPlaneVertexDeclaration2: {
  56677. name: string;
  56678. shader: string;
  56679. };
  56680. }
  56681. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56682. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56683. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56684. /** @hidden */
  56685. export var gpuRenderParticlesVertexShader: {
  56686. name: string;
  56687. shader: string;
  56688. };
  56689. }
  56690. declare module "babylonjs/Particles/gpuParticleSystem" {
  56691. import { Nullable } from "babylonjs/types";
  56692. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56693. import { Observable } from "babylonjs/Misc/observable";
  56694. import { Color4, Color3 } from "babylonjs/Maths/math";
  56695. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56696. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56697. import { Scene, IDisposable } from "babylonjs/scene";
  56698. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56699. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56700. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56701. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56702. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56703. /**
  56704. * This represents a GPU particle system in Babylon
  56705. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56706. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56707. */
  56708. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56709. /**
  56710. * The layer mask we are rendering the particles through.
  56711. */
  56712. layerMask: number;
  56713. private _capacity;
  56714. private _activeCount;
  56715. private _currentActiveCount;
  56716. private _accumulatedCount;
  56717. private _renderEffect;
  56718. private _updateEffect;
  56719. private _buffer0;
  56720. private _buffer1;
  56721. private _spriteBuffer;
  56722. private _updateVAO;
  56723. private _renderVAO;
  56724. private _targetIndex;
  56725. private _sourceBuffer;
  56726. private _targetBuffer;
  56727. private _engine;
  56728. private _currentRenderId;
  56729. private _started;
  56730. private _stopped;
  56731. private _timeDelta;
  56732. private _randomTexture;
  56733. private _randomTexture2;
  56734. private _attributesStrideSize;
  56735. private _updateEffectOptions;
  56736. private _randomTextureSize;
  56737. private _actualFrame;
  56738. private readonly _rawTextureWidth;
  56739. /**
  56740. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56741. */
  56742. static readonly IsSupported: boolean;
  56743. /**
  56744. * An event triggered when the system is disposed.
  56745. */
  56746. onDisposeObservable: Observable<GPUParticleSystem>;
  56747. /**
  56748. * Gets the maximum number of particles active at the same time.
  56749. * @returns The max number of active particles.
  56750. */
  56751. getCapacity(): number;
  56752. /**
  56753. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56754. * to override the particles.
  56755. */
  56756. forceDepthWrite: boolean;
  56757. /**
  56758. * Gets or set the number of active particles
  56759. */
  56760. activeParticleCount: number;
  56761. private _preWarmDone;
  56762. /**
  56763. * Is this system ready to be used/rendered
  56764. * @return true if the system is ready
  56765. */
  56766. isReady(): boolean;
  56767. /**
  56768. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56769. * @returns True if it has been started, otherwise false.
  56770. */
  56771. isStarted(): boolean;
  56772. /**
  56773. * Starts the particle system and begins to emit
  56774. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56775. */
  56776. start(delay?: number): void;
  56777. /**
  56778. * Stops the particle system.
  56779. */
  56780. stop(): void;
  56781. /**
  56782. * Remove all active particles
  56783. */
  56784. reset(): void;
  56785. /**
  56786. * Returns the string "GPUParticleSystem"
  56787. * @returns a string containing the class name
  56788. */
  56789. getClassName(): string;
  56790. private _colorGradientsTexture;
  56791. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56792. /**
  56793. * Adds a new color gradient
  56794. * @param gradient defines the gradient to use (between 0 and 1)
  56795. * @param color1 defines the color to affect to the specified gradient
  56796. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56797. * @returns the current particle system
  56798. */
  56799. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56800. /**
  56801. * Remove a specific color gradient
  56802. * @param gradient defines the gradient to remove
  56803. * @returns the current particle system
  56804. */
  56805. removeColorGradient(gradient: number): GPUParticleSystem;
  56806. private _angularSpeedGradientsTexture;
  56807. private _sizeGradientsTexture;
  56808. private _velocityGradientsTexture;
  56809. private _limitVelocityGradientsTexture;
  56810. private _dragGradientsTexture;
  56811. private _addFactorGradient;
  56812. /**
  56813. * Adds a new size gradient
  56814. * @param gradient defines the gradient to use (between 0 and 1)
  56815. * @param factor defines the size factor to affect to the specified gradient
  56816. * @returns the current particle system
  56817. */
  56818. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56819. /**
  56820. * Remove a specific size gradient
  56821. * @param gradient defines the gradient to remove
  56822. * @returns the current particle system
  56823. */
  56824. removeSizeGradient(gradient: number): GPUParticleSystem;
  56825. /**
  56826. * Adds a new angular speed gradient
  56827. * @param gradient defines the gradient to use (between 0 and 1)
  56828. * @param factor defines the angular speed to affect to the specified gradient
  56829. * @returns the current particle system
  56830. */
  56831. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56832. /**
  56833. * Remove a specific angular speed gradient
  56834. * @param gradient defines the gradient to remove
  56835. * @returns the current particle system
  56836. */
  56837. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56838. /**
  56839. * Adds a new velocity gradient
  56840. * @param gradient defines the gradient to use (between 0 and 1)
  56841. * @param factor defines the velocity to affect to the specified gradient
  56842. * @returns the current particle system
  56843. */
  56844. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56845. /**
  56846. * Remove a specific velocity gradient
  56847. * @param gradient defines the gradient to remove
  56848. * @returns the current particle system
  56849. */
  56850. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56851. /**
  56852. * Adds a new limit velocity gradient
  56853. * @param gradient defines the gradient to use (between 0 and 1)
  56854. * @param factor defines the limit velocity value to affect to the specified gradient
  56855. * @returns the current particle system
  56856. */
  56857. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56858. /**
  56859. * Remove a specific limit velocity gradient
  56860. * @param gradient defines the gradient to remove
  56861. * @returns the current particle system
  56862. */
  56863. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56864. /**
  56865. * Adds a new drag gradient
  56866. * @param gradient defines the gradient to use (between 0 and 1)
  56867. * @param factor defines the drag value to affect to the specified gradient
  56868. * @returns the current particle system
  56869. */
  56870. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56871. /**
  56872. * Remove a specific drag gradient
  56873. * @param gradient defines the gradient to remove
  56874. * @returns the current particle system
  56875. */
  56876. removeDragGradient(gradient: number): GPUParticleSystem;
  56877. /**
  56878. * Not supported by GPUParticleSystem
  56879. * @param gradient defines the gradient to use (between 0 and 1)
  56880. * @param factor defines the emit rate value to affect to the specified gradient
  56881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56882. * @returns the current particle system
  56883. */
  56884. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56885. /**
  56886. * Not supported by GPUParticleSystem
  56887. * @param gradient defines the gradient to remove
  56888. * @returns the current particle system
  56889. */
  56890. removeEmitRateGradient(gradient: number): IParticleSystem;
  56891. /**
  56892. * Not supported by GPUParticleSystem
  56893. * @param gradient defines the gradient to use (between 0 and 1)
  56894. * @param factor defines the start size value to affect to the specified gradient
  56895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56896. * @returns the current particle system
  56897. */
  56898. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56899. /**
  56900. * Not supported by GPUParticleSystem
  56901. * @param gradient defines the gradient to remove
  56902. * @returns the current particle system
  56903. */
  56904. removeStartSizeGradient(gradient: number): IParticleSystem;
  56905. /**
  56906. * Not supported by GPUParticleSystem
  56907. * @param gradient defines the gradient to use (between 0 and 1)
  56908. * @param min defines the color remap minimal range
  56909. * @param max defines the color remap maximal range
  56910. * @returns the current particle system
  56911. */
  56912. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56913. /**
  56914. * Not supported by GPUParticleSystem
  56915. * @param gradient defines the gradient to remove
  56916. * @returns the current particle system
  56917. */
  56918. removeColorRemapGradient(): IParticleSystem;
  56919. /**
  56920. * Not supported by GPUParticleSystem
  56921. * @param gradient defines the gradient to use (between 0 and 1)
  56922. * @param min defines the alpha remap minimal range
  56923. * @param max defines the alpha remap maximal range
  56924. * @returns the current particle system
  56925. */
  56926. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56927. /**
  56928. * Not supported by GPUParticleSystem
  56929. * @param gradient defines the gradient to remove
  56930. * @returns the current particle system
  56931. */
  56932. removeAlphaRemapGradient(): IParticleSystem;
  56933. /**
  56934. * Not supported by GPUParticleSystem
  56935. * @param gradient defines the gradient to use (between 0 and 1)
  56936. * @param color defines the color to affect to the specified gradient
  56937. * @returns the current particle system
  56938. */
  56939. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56940. /**
  56941. * Not supported by GPUParticleSystem
  56942. * @param gradient defines the gradient to remove
  56943. * @returns the current particle system
  56944. */
  56945. removeRampGradient(): IParticleSystem;
  56946. /**
  56947. * Not supported by GPUParticleSystem
  56948. * @returns the list of ramp gradients
  56949. */
  56950. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56951. /**
  56952. * Not supported by GPUParticleSystem
  56953. * Gets or sets a boolean indicating that ramp gradients must be used
  56954. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56955. */
  56956. useRampGradients: boolean;
  56957. /**
  56958. * Not supported by GPUParticleSystem
  56959. * @param gradient defines the gradient to use (between 0 and 1)
  56960. * @param factor defines the life time factor to affect to the specified gradient
  56961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56962. * @returns the current particle system
  56963. */
  56964. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56965. /**
  56966. * Not supported by GPUParticleSystem
  56967. * @param gradient defines the gradient to remove
  56968. * @returns the current particle system
  56969. */
  56970. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56971. /**
  56972. * Instantiates a GPU particle system.
  56973. * 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.
  56974. * @param name The name of the particle system
  56975. * @param options The options used to create the system
  56976. * @param scene The scene the particle system belongs to
  56977. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56978. */
  56979. constructor(name: string, options: Partial<{
  56980. capacity: number;
  56981. randomTextureSize: number;
  56982. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56983. protected _reset(): void;
  56984. private _createUpdateVAO;
  56985. private _createRenderVAO;
  56986. private _initialize;
  56987. /** @hidden */
  56988. _recreateUpdateEffect(): void;
  56989. /** @hidden */
  56990. _recreateRenderEffect(): void;
  56991. /**
  56992. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56993. * @param preWarm defines if we are in the pre-warmimg phase
  56994. */
  56995. animate(preWarm?: boolean): void;
  56996. private _createFactorGradientTexture;
  56997. private _createSizeGradientTexture;
  56998. private _createAngularSpeedGradientTexture;
  56999. private _createVelocityGradientTexture;
  57000. private _createLimitVelocityGradientTexture;
  57001. private _createDragGradientTexture;
  57002. private _createColorGradientTexture;
  57003. /**
  57004. * Renders the particle system in its current state
  57005. * @param preWarm defines if the system should only update the particles but not render them
  57006. * @returns the current number of particles
  57007. */
  57008. render(preWarm?: boolean): number;
  57009. /**
  57010. * Rebuilds the particle system
  57011. */
  57012. rebuild(): void;
  57013. private _releaseBuffers;
  57014. private _releaseVAOs;
  57015. /**
  57016. * Disposes the particle system and free the associated resources
  57017. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57018. */
  57019. dispose(disposeTexture?: boolean): void;
  57020. /**
  57021. * Clones the particle system.
  57022. * @param name The name of the cloned object
  57023. * @param newEmitter The new emitter to use
  57024. * @returns the cloned particle system
  57025. */
  57026. clone(name: string, newEmitter: any): GPUParticleSystem;
  57027. /**
  57028. * Serializes the particle system to a JSON object.
  57029. * @returns the JSON object
  57030. */
  57031. serialize(): any;
  57032. /**
  57033. * Parses a JSON object to create a GPU particle system.
  57034. * @param parsedParticleSystem The JSON object to parse
  57035. * @param scene The scene to create the particle system in
  57036. * @param rootUrl The root url to use to load external dependencies like texture
  57037. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57038. * @returns the parsed GPU particle system
  57039. */
  57040. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57041. }
  57042. }
  57043. declare module "babylonjs/Particles/particleSystemSet" {
  57044. import { Nullable } from "babylonjs/types";
  57045. import { Color3 } from "babylonjs/Maths/math";
  57046. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57048. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57049. import { Scene, IDisposable } from "babylonjs/scene";
  57050. /**
  57051. * Represents a set of particle systems working together to create a specific effect
  57052. */
  57053. export class ParticleSystemSet implements IDisposable {
  57054. private _emitterCreationOptions;
  57055. private _emitterNode;
  57056. /**
  57057. * Gets the particle system list
  57058. */
  57059. systems: IParticleSystem[];
  57060. /**
  57061. * Gets the emitter node used with this set
  57062. */
  57063. readonly emitterNode: Nullable<TransformNode>;
  57064. /**
  57065. * Creates a new emitter mesh as a sphere
  57066. * @param options defines the options used to create the sphere
  57067. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57068. * @param scene defines the hosting scene
  57069. */
  57070. setEmitterAsSphere(options: {
  57071. diameter: number;
  57072. segments: number;
  57073. color: Color3;
  57074. }, renderingGroupId: number, scene: Scene): void;
  57075. /**
  57076. * Starts all particle systems of the set
  57077. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57078. */
  57079. start(emitter?: AbstractMesh): void;
  57080. /**
  57081. * Release all associated resources
  57082. */
  57083. dispose(): void;
  57084. /**
  57085. * Serialize the set into a JSON compatible object
  57086. * @returns a JSON compatible representation of the set
  57087. */
  57088. serialize(): any;
  57089. /**
  57090. * Parse a new ParticleSystemSet from a serialized source
  57091. * @param data defines a JSON compatible representation of the set
  57092. * @param scene defines the hosting scene
  57093. * @param gpu defines if we want GPU particles or CPU particles
  57094. * @returns a new ParticleSystemSet
  57095. */
  57096. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57097. }
  57098. }
  57099. declare module "babylonjs/Particles/particleHelper" {
  57100. import { Nullable } from "babylonjs/types";
  57101. import { Scene } from "babylonjs/scene";
  57102. import { Vector3 } from "babylonjs/Maths/math";
  57103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57104. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57105. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57106. /**
  57107. * This class is made for on one-liner static method to help creating particle system set.
  57108. */
  57109. export class ParticleHelper {
  57110. /**
  57111. * Gets or sets base Assets URL
  57112. */
  57113. static BaseAssetsUrl: string;
  57114. /**
  57115. * Create a default particle system that you can tweak
  57116. * @param emitter defines the emitter to use
  57117. * @param capacity defines the system capacity (default is 500 particles)
  57118. * @param scene defines the hosting scene
  57119. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57120. * @returns the new Particle system
  57121. */
  57122. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57123. /**
  57124. * This is the main static method (one-liner) of this helper to create different particle systems
  57125. * @param type This string represents the type to the particle system to create
  57126. * @param scene The scene where the particle system should live
  57127. * @param gpu If the system will use gpu
  57128. * @returns the ParticleSystemSet created
  57129. */
  57130. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57131. /**
  57132. * Static function used to export a particle system to a ParticleSystemSet variable.
  57133. * Please note that the emitter shape is not exported
  57134. * @param systems defines the particle systems to export
  57135. * @returns the created particle system set
  57136. */
  57137. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57138. }
  57139. }
  57140. declare module "babylonjs/Particles/particleSystemComponent" {
  57141. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57142. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57143. import "babylonjs/Shaders/particles.vertex";
  57144. module "babylonjs/Engines/engine" {
  57145. interface Engine {
  57146. /**
  57147. * Create an effect to use with particle systems.
  57148. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57149. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57150. * @param uniformsNames defines a list of attribute names
  57151. * @param samplers defines an array of string used to represent textures
  57152. * @param defines defines the string containing the defines to use to compile the shaders
  57153. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57154. * @param onCompiled defines a function to call when the effect creation is successful
  57155. * @param onError defines a function to call when the effect creation has failed
  57156. * @returns the new Effect
  57157. */
  57158. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57159. }
  57160. }
  57161. module "babylonjs/Meshes/mesh" {
  57162. interface Mesh {
  57163. /**
  57164. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57165. * @returns an array of IParticleSystem
  57166. */
  57167. getEmittedParticleSystems(): IParticleSystem[];
  57168. /**
  57169. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57170. * @returns an array of IParticleSystem
  57171. */
  57172. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57173. }
  57174. }
  57175. /**
  57176. * @hidden
  57177. */
  57178. export var _IDoNeedToBeInTheBuild: number;
  57179. }
  57180. declare module "babylonjs/Particles/index" {
  57181. export * from "babylonjs/Particles/baseParticleSystem";
  57182. export * from "babylonjs/Particles/EmitterTypes/index";
  57183. export * from "babylonjs/Particles/gpuParticleSystem";
  57184. export * from "babylonjs/Particles/IParticleSystem";
  57185. export * from "babylonjs/Particles/particle";
  57186. export * from "babylonjs/Particles/particleHelper";
  57187. export * from "babylonjs/Particles/particleSystem";
  57188. export * from "babylonjs/Particles/particleSystemComponent";
  57189. export * from "babylonjs/Particles/particleSystemSet";
  57190. export * from "babylonjs/Particles/solidParticle";
  57191. export * from "babylonjs/Particles/solidParticleSystem";
  57192. export * from "babylonjs/Particles/subEmitter";
  57193. }
  57194. declare module "babylonjs/Physics/physicsEngineComponent" {
  57195. import { Nullable } from "babylonjs/types";
  57196. import { Observable, Observer } from "babylonjs/Misc/observable";
  57197. import { Vector3 } from "babylonjs/Maths/math";
  57198. import { Mesh } from "babylonjs/Meshes/mesh";
  57199. import { ISceneComponent } from "babylonjs/sceneComponent";
  57200. import { Scene } from "babylonjs/scene";
  57201. import { Node } from "babylonjs/node";
  57202. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57203. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57204. module "babylonjs/scene" {
  57205. interface Scene {
  57206. /** @hidden (Backing field) */
  57207. _physicsEngine: Nullable<IPhysicsEngine>;
  57208. /**
  57209. * Gets the current physics engine
  57210. * @returns a IPhysicsEngine or null if none attached
  57211. */
  57212. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57213. /**
  57214. * Enables physics to the current scene
  57215. * @param gravity defines the scene's gravity for the physics engine
  57216. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57217. * @return a boolean indicating if the physics engine was initialized
  57218. */
  57219. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57220. /**
  57221. * Disables and disposes the physics engine associated with the scene
  57222. */
  57223. disablePhysicsEngine(): void;
  57224. /**
  57225. * Gets a boolean indicating if there is an active physics engine
  57226. * @returns a boolean indicating if there is an active physics engine
  57227. */
  57228. isPhysicsEnabled(): boolean;
  57229. /**
  57230. * Deletes a physics compound impostor
  57231. * @param compound defines the compound to delete
  57232. */
  57233. deleteCompoundImpostor(compound: any): void;
  57234. /**
  57235. * An event triggered when physic simulation is about to be run
  57236. */
  57237. onBeforePhysicsObservable: Observable<Scene>;
  57238. /**
  57239. * An event triggered when physic simulation has been done
  57240. */
  57241. onAfterPhysicsObservable: Observable<Scene>;
  57242. }
  57243. }
  57244. module "babylonjs/Meshes/abstractMesh" {
  57245. interface AbstractMesh {
  57246. /** @hidden */
  57247. _physicsImpostor: Nullable<PhysicsImpostor>;
  57248. /**
  57249. * Gets or sets impostor used for physic simulation
  57250. * @see http://doc.babylonjs.com/features/physics_engine
  57251. */
  57252. physicsImpostor: Nullable<PhysicsImpostor>;
  57253. /**
  57254. * Gets the current physics impostor
  57255. * @see http://doc.babylonjs.com/features/physics_engine
  57256. * @returns a physics impostor or null
  57257. */
  57258. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57259. /** Apply a physic impulse to the mesh
  57260. * @param force defines the force to apply
  57261. * @param contactPoint defines where to apply the force
  57262. * @returns the current mesh
  57263. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57264. */
  57265. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57266. /**
  57267. * Creates a physic joint between two meshes
  57268. * @param otherMesh defines the other mesh to use
  57269. * @param pivot1 defines the pivot to use on this mesh
  57270. * @param pivot2 defines the pivot to use on the other mesh
  57271. * @param options defines additional options (can be plugin dependent)
  57272. * @returns the current mesh
  57273. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57274. */
  57275. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57276. /** @hidden */
  57277. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57278. }
  57279. }
  57280. /**
  57281. * Defines the physics engine scene component responsible to manage a physics engine
  57282. */
  57283. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57284. /**
  57285. * The component name helpful to identify the component in the list of scene components.
  57286. */
  57287. readonly name: string;
  57288. /**
  57289. * The scene the component belongs to.
  57290. */
  57291. scene: Scene;
  57292. /**
  57293. * Creates a new instance of the component for the given scene
  57294. * @param scene Defines the scene to register the component in
  57295. */
  57296. constructor(scene: Scene);
  57297. /**
  57298. * Registers the component in a given scene
  57299. */
  57300. register(): void;
  57301. /**
  57302. * Rebuilds the elements related to this component in case of
  57303. * context lost for instance.
  57304. */
  57305. rebuild(): void;
  57306. /**
  57307. * Disposes the component and the associated ressources
  57308. */
  57309. dispose(): void;
  57310. }
  57311. }
  57312. declare module "babylonjs/Physics/physicsHelper" {
  57313. import { Nullable } from "babylonjs/types";
  57314. import { Vector3 } from "babylonjs/Maths/math";
  57315. import { Mesh } from "babylonjs/Meshes/mesh";
  57316. import { Scene } from "babylonjs/scene";
  57317. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57318. /**
  57319. * A helper for physics simulations
  57320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57321. */
  57322. export class PhysicsHelper {
  57323. private _scene;
  57324. private _physicsEngine;
  57325. /**
  57326. * Initializes the Physics helper
  57327. * @param scene Babylon.js scene
  57328. */
  57329. constructor(scene: Scene);
  57330. /**
  57331. * Applies a radial explosion impulse
  57332. * @param origin the origin of the explosion
  57333. * @param radiusOrEventOptions the radius or the options of radial explosion
  57334. * @param strength the explosion strength
  57335. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57336. * @returns A physics radial explosion event, or null
  57337. */
  57338. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57339. /**
  57340. * Applies a radial explosion force
  57341. * @param origin the origin of the explosion
  57342. * @param radiusOrEventOptions the radius or the options of radial explosion
  57343. * @param strength the explosion strength
  57344. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57345. * @returns A physics radial explosion event, or null
  57346. */
  57347. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57348. /**
  57349. * Creates a gravitational field
  57350. * @param origin the origin of the explosion
  57351. * @param radiusOrEventOptions the radius or the options of radial explosion
  57352. * @param strength the explosion strength
  57353. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57354. * @returns A physics gravitational field event, or null
  57355. */
  57356. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57357. /**
  57358. * Creates a physics updraft event
  57359. * @param origin the origin of the updraft
  57360. * @param radiusOrEventOptions the radius or the options of the updraft
  57361. * @param strength the strength of the updraft
  57362. * @param height the height of the updraft
  57363. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57364. * @returns A physics updraft event, or null
  57365. */
  57366. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57367. /**
  57368. * Creates a physics vortex event
  57369. * @param origin the of the vortex
  57370. * @param radiusOrEventOptions the radius or the options of the vortex
  57371. * @param strength the strength of the vortex
  57372. * @param height the height of the vortex
  57373. * @returns a Physics vortex event, or null
  57374. * A physics vortex event or null
  57375. */
  57376. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57377. }
  57378. /**
  57379. * Represents a physics radial explosion event
  57380. */
  57381. class PhysicsRadialExplosionEvent {
  57382. private _scene;
  57383. private _options;
  57384. private _sphere;
  57385. private _dataFetched;
  57386. /**
  57387. * Initializes a radial explosioin event
  57388. * @param _scene BabylonJS scene
  57389. * @param _options The options for the vortex event
  57390. */
  57391. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57392. /**
  57393. * Returns the data related to the radial explosion event (sphere).
  57394. * @returns The radial explosion event data
  57395. */
  57396. getData(): PhysicsRadialExplosionEventData;
  57397. /**
  57398. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57399. * @param impostor A physics imposter
  57400. * @param origin the origin of the explosion
  57401. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57402. */
  57403. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57404. /**
  57405. * Triggers affecterd impostors callbacks
  57406. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57407. */
  57408. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57409. /**
  57410. * Disposes the sphere.
  57411. * @param force Specifies if the sphere should be disposed by force
  57412. */
  57413. dispose(force?: boolean): void;
  57414. /*** Helpers ***/
  57415. private _prepareSphere;
  57416. private _intersectsWithSphere;
  57417. }
  57418. /**
  57419. * Represents a gravitational field event
  57420. */
  57421. class PhysicsGravitationalFieldEvent {
  57422. private _physicsHelper;
  57423. private _scene;
  57424. private _origin;
  57425. private _options;
  57426. private _tickCallback;
  57427. private _sphere;
  57428. private _dataFetched;
  57429. /**
  57430. * Initializes the physics gravitational field event
  57431. * @param _physicsHelper A physics helper
  57432. * @param _scene BabylonJS scene
  57433. * @param _origin The origin position of the gravitational field event
  57434. * @param _options The options for the vortex event
  57435. */
  57436. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57437. /**
  57438. * Returns the data related to the gravitational field event (sphere).
  57439. * @returns A gravitational field event
  57440. */
  57441. getData(): PhysicsGravitationalFieldEventData;
  57442. /**
  57443. * Enables the gravitational field.
  57444. */
  57445. enable(): void;
  57446. /**
  57447. * Disables the gravitational field.
  57448. */
  57449. disable(): void;
  57450. /**
  57451. * Disposes the sphere.
  57452. * @param force The force to dispose from the gravitational field event
  57453. */
  57454. dispose(force?: boolean): void;
  57455. private _tick;
  57456. }
  57457. /**
  57458. * Represents a physics updraft event
  57459. */
  57460. class PhysicsUpdraftEvent {
  57461. private _scene;
  57462. private _origin;
  57463. private _options;
  57464. private _physicsEngine;
  57465. private _originTop;
  57466. private _originDirection;
  57467. private _tickCallback;
  57468. private _cylinder;
  57469. private _cylinderPosition;
  57470. private _dataFetched;
  57471. /**
  57472. * Initializes the physics updraft event
  57473. * @param _scene BabylonJS scene
  57474. * @param _origin The origin position of the updraft
  57475. * @param _options The options for the updraft event
  57476. */
  57477. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57478. /**
  57479. * Returns the data related to the updraft event (cylinder).
  57480. * @returns A physics updraft event
  57481. */
  57482. getData(): PhysicsUpdraftEventData;
  57483. /**
  57484. * Enables the updraft.
  57485. */
  57486. enable(): void;
  57487. /**
  57488. * Disables the updraft.
  57489. */
  57490. disable(): void;
  57491. /**
  57492. * Disposes the cylinder.
  57493. * @param force Specifies if the updraft should be disposed by force
  57494. */
  57495. dispose(force?: boolean): void;
  57496. private getImpostorHitData;
  57497. private _tick;
  57498. /*** Helpers ***/
  57499. private _prepareCylinder;
  57500. private _intersectsWithCylinder;
  57501. }
  57502. /**
  57503. * Represents a physics vortex event
  57504. */
  57505. class PhysicsVortexEvent {
  57506. private _scene;
  57507. private _origin;
  57508. private _options;
  57509. private _physicsEngine;
  57510. private _originTop;
  57511. private _tickCallback;
  57512. private _cylinder;
  57513. private _cylinderPosition;
  57514. private _dataFetched;
  57515. /**
  57516. * Initializes the physics vortex event
  57517. * @param _scene The BabylonJS scene
  57518. * @param _origin The origin position of the vortex
  57519. * @param _options The options for the vortex event
  57520. */
  57521. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57522. /**
  57523. * Returns the data related to the vortex event (cylinder).
  57524. * @returns The physics vortex event data
  57525. */
  57526. getData(): PhysicsVortexEventData;
  57527. /**
  57528. * Enables the vortex.
  57529. */
  57530. enable(): void;
  57531. /**
  57532. * Disables the cortex.
  57533. */
  57534. disable(): void;
  57535. /**
  57536. * Disposes the sphere.
  57537. * @param force
  57538. */
  57539. dispose(force?: boolean): void;
  57540. private getImpostorHitData;
  57541. private _tick;
  57542. /*** Helpers ***/
  57543. private _prepareCylinder;
  57544. private _intersectsWithCylinder;
  57545. }
  57546. /**
  57547. * Options fot the radial explosion event
  57548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57549. */
  57550. export class PhysicsRadialExplosionEventOptions {
  57551. /**
  57552. * The radius of the sphere for the radial explosion.
  57553. */
  57554. radius: number;
  57555. /**
  57556. * The strenth of the explosion.
  57557. */
  57558. strength: number;
  57559. /**
  57560. * The strenght of the force in correspondence to the distance of the affected object
  57561. */
  57562. falloff: PhysicsRadialImpulseFalloff;
  57563. /**
  57564. * Sphere options for the radial explosion.
  57565. */
  57566. sphere: {
  57567. segments: number;
  57568. diameter: number;
  57569. };
  57570. /**
  57571. * Sphere options for the radial explosion.
  57572. */
  57573. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57574. }
  57575. /**
  57576. * Options fot the updraft event
  57577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57578. */
  57579. export class PhysicsUpdraftEventOptions {
  57580. /**
  57581. * The radius of the cylinder for the vortex
  57582. */
  57583. radius: number;
  57584. /**
  57585. * The strenth of the updraft.
  57586. */
  57587. strength: number;
  57588. /**
  57589. * The height of the cylinder for the updraft.
  57590. */
  57591. height: number;
  57592. /**
  57593. * The mode for the the updraft.
  57594. */
  57595. updraftMode: PhysicsUpdraftMode;
  57596. }
  57597. /**
  57598. * Options fot the vortex event
  57599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57600. */
  57601. export class PhysicsVortexEventOptions {
  57602. /**
  57603. * The radius of the cylinder for the vortex
  57604. */
  57605. radius: number;
  57606. /**
  57607. * The strenth of the vortex.
  57608. */
  57609. strength: number;
  57610. /**
  57611. * The height of the cylinder for the vortex.
  57612. */
  57613. height: number;
  57614. /**
  57615. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57616. */
  57617. centripetalForceThreshold: number;
  57618. /**
  57619. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57620. */
  57621. centripetalForceMultiplier: number;
  57622. /**
  57623. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57624. */
  57625. centrifugalForceMultiplier: number;
  57626. /**
  57627. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57628. */
  57629. updraftForceMultiplier: number;
  57630. }
  57631. /**
  57632. * The strenght of the force in correspondence to the distance of the affected object
  57633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57634. */
  57635. export enum PhysicsRadialImpulseFalloff {
  57636. /** Defines that impulse is constant in strength across it's whole radius */
  57637. Constant = 0,
  57638. /** Defines that impulse gets weaker if it's further from the origin */
  57639. Linear = 1
  57640. }
  57641. /**
  57642. * The strength of the force in correspondence to the distance of the affected object
  57643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57644. */
  57645. export enum PhysicsUpdraftMode {
  57646. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57647. Center = 0,
  57648. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57649. Perpendicular = 1
  57650. }
  57651. /**
  57652. * Interface for a physics hit data
  57653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57654. */
  57655. export interface PhysicsHitData {
  57656. /**
  57657. * The force applied at the contact point
  57658. */
  57659. force: Vector3;
  57660. /**
  57661. * The contact point
  57662. */
  57663. contactPoint: Vector3;
  57664. /**
  57665. * The distance from the origin to the contact point
  57666. */
  57667. distanceFromOrigin: number;
  57668. }
  57669. /**
  57670. * Interface for radial explosion event data
  57671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57672. */
  57673. export interface PhysicsRadialExplosionEventData {
  57674. /**
  57675. * A sphere used for the radial explosion event
  57676. */
  57677. sphere: Mesh;
  57678. }
  57679. /**
  57680. * Interface for gravitational field event data
  57681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57682. */
  57683. export interface PhysicsGravitationalFieldEventData {
  57684. /**
  57685. * A sphere mesh used for the gravitational field event
  57686. */
  57687. sphere: Mesh;
  57688. }
  57689. /**
  57690. * Interface for updraft event data
  57691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57692. */
  57693. export interface PhysicsUpdraftEventData {
  57694. /**
  57695. * A cylinder used for the updraft event
  57696. */
  57697. cylinder: Mesh;
  57698. }
  57699. /**
  57700. * Interface for vortex event data
  57701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57702. */
  57703. export interface PhysicsVortexEventData {
  57704. /**
  57705. * A cylinder used for the vortex event
  57706. */
  57707. cylinder: Mesh;
  57708. }
  57709. /**
  57710. * Interface for an affected physics impostor
  57711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57712. */
  57713. export interface PhysicsAffectedImpostorWithData {
  57714. /**
  57715. * The impostor affected by the effect
  57716. */
  57717. impostor: PhysicsImpostor;
  57718. /**
  57719. * The data about the hit/horce from the explosion
  57720. */
  57721. hitData: PhysicsHitData;
  57722. }
  57723. }
  57724. declare module "babylonjs/Physics/Plugins/index" {
  57725. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57726. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57727. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57728. }
  57729. declare module "babylonjs/Physics/index" {
  57730. export * from "babylonjs/Physics/IPhysicsEngine";
  57731. export * from "babylonjs/Physics/physicsEngine";
  57732. export * from "babylonjs/Physics/physicsEngineComponent";
  57733. export * from "babylonjs/Physics/physicsHelper";
  57734. export * from "babylonjs/Physics/physicsImpostor";
  57735. export * from "babylonjs/Physics/physicsJoint";
  57736. export * from "babylonjs/Physics/Plugins/index";
  57737. }
  57738. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57739. /** @hidden */
  57740. export var blackAndWhitePixelShader: {
  57741. name: string;
  57742. shader: string;
  57743. };
  57744. }
  57745. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57747. import { Camera } from "babylonjs/Cameras/camera";
  57748. import { Engine } from "babylonjs/Engines/engine";
  57749. import "babylonjs/Shaders/blackAndWhite.fragment";
  57750. /**
  57751. * Post process used to render in black and white
  57752. */
  57753. export class BlackAndWhitePostProcess extends PostProcess {
  57754. /**
  57755. * Linear about to convert he result to black and white (default: 1)
  57756. */
  57757. degree: number;
  57758. /**
  57759. * Creates a black and white post process
  57760. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57761. * @param name The name of the effect.
  57762. * @param options The required width/height ratio to downsize to before computing the render pass.
  57763. * @param camera The camera to apply the render pass to.
  57764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57765. * @param engine The engine which the post process will be applied. (default: current engine)
  57766. * @param reusable If the post process can be reused on the same frame. (default: false)
  57767. */
  57768. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57769. }
  57770. }
  57771. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57772. import { Nullable } from "babylonjs/types";
  57773. import { Camera } from "babylonjs/Cameras/camera";
  57774. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57775. import { Engine } from "babylonjs/Engines/engine";
  57776. /**
  57777. * This represents a set of one or more post processes in Babylon.
  57778. * A post process can be used to apply a shader to a texture after it is rendered.
  57779. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57780. */
  57781. export class PostProcessRenderEffect {
  57782. private _postProcesses;
  57783. private _getPostProcesses;
  57784. private _singleInstance;
  57785. private _cameras;
  57786. private _indicesForCamera;
  57787. /**
  57788. * Name of the effect
  57789. * @hidden
  57790. */
  57791. _name: string;
  57792. /**
  57793. * Instantiates a post process render effect.
  57794. * A post process can be used to apply a shader to a texture after it is rendered.
  57795. * @param engine The engine the effect is tied to
  57796. * @param name The name of the effect
  57797. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57798. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57799. */
  57800. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57801. /**
  57802. * Checks if all the post processes in the effect are supported.
  57803. */
  57804. readonly isSupported: boolean;
  57805. /**
  57806. * Updates the current state of the effect
  57807. * @hidden
  57808. */
  57809. _update(): void;
  57810. /**
  57811. * Attaches the effect on cameras
  57812. * @param cameras The camera to attach to.
  57813. * @hidden
  57814. */
  57815. _attachCameras(cameras: Camera): void;
  57816. /**
  57817. * Attaches the effect on cameras
  57818. * @param cameras The camera to attach to.
  57819. * @hidden
  57820. */
  57821. _attachCameras(cameras: Camera[]): void;
  57822. /**
  57823. * Detaches the effect on cameras
  57824. * @param cameras The camera to detatch from.
  57825. * @hidden
  57826. */
  57827. _detachCameras(cameras: Camera): void;
  57828. /**
  57829. * Detatches the effect on cameras
  57830. * @param cameras The camera to detatch from.
  57831. * @hidden
  57832. */
  57833. _detachCameras(cameras: Camera[]): void;
  57834. /**
  57835. * Enables the effect on given cameras
  57836. * @param cameras The camera to enable.
  57837. * @hidden
  57838. */
  57839. _enable(cameras: Camera): void;
  57840. /**
  57841. * Enables the effect on given cameras
  57842. * @param cameras The camera to enable.
  57843. * @hidden
  57844. */
  57845. _enable(cameras: Nullable<Camera[]>): void;
  57846. /**
  57847. * Disables the effect on the given cameras
  57848. * @param cameras The camera to disable.
  57849. * @hidden
  57850. */
  57851. _disable(cameras: Camera): void;
  57852. /**
  57853. * Disables the effect on the given cameras
  57854. * @param cameras The camera to disable.
  57855. * @hidden
  57856. */
  57857. _disable(cameras: Nullable<Camera[]>): void;
  57858. /**
  57859. * Gets a list of the post processes contained in the effect.
  57860. * @param camera The camera to get the post processes on.
  57861. * @returns The list of the post processes in the effect.
  57862. */
  57863. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57864. }
  57865. }
  57866. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57867. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57868. /** @hidden */
  57869. export var extractHighlightsPixelShader: {
  57870. name: string;
  57871. shader: string;
  57872. };
  57873. }
  57874. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57875. import { Nullable } from "babylonjs/types";
  57876. import { Camera } from "babylonjs/Cameras/camera";
  57877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57878. import { Engine } from "babylonjs/Engines/engine";
  57879. import "babylonjs/Shaders/extractHighlights.fragment";
  57880. /**
  57881. * 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.
  57882. */
  57883. export class ExtractHighlightsPostProcess extends PostProcess {
  57884. /**
  57885. * The luminance threshold, pixels below this value will be set to black.
  57886. */
  57887. threshold: number;
  57888. /** @hidden */
  57889. _exposure: number;
  57890. /**
  57891. * Post process which has the input texture to be used when performing highlight extraction
  57892. * @hidden
  57893. */
  57894. _inputPostProcess: Nullable<PostProcess>;
  57895. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57896. }
  57897. }
  57898. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57899. /** @hidden */
  57900. export var bloomMergePixelShader: {
  57901. name: string;
  57902. shader: string;
  57903. };
  57904. }
  57905. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57906. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57907. import { Nullable } from "babylonjs/types";
  57908. import { Engine } from "babylonjs/Engines/engine";
  57909. import { Camera } from "babylonjs/Cameras/camera";
  57910. import "babylonjs/Shaders/bloomMerge.fragment";
  57911. /**
  57912. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57913. */
  57914. export class BloomMergePostProcess extends PostProcess {
  57915. /** Weight of the bloom to be added to the original input. */
  57916. weight: number;
  57917. /**
  57918. * Creates a new instance of @see BloomMergePostProcess
  57919. * @param name The name of the effect.
  57920. * @param originalFromInput Post process which's input will be used for the merge.
  57921. * @param blurred Blurred highlights post process which's output will be used.
  57922. * @param weight Weight of the bloom to be added to the original input.
  57923. * @param options The required width/height ratio to downsize to before computing the render pass.
  57924. * @param camera The camera to apply the render pass to.
  57925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57926. * @param engine The engine which the post process will be applied. (default: current engine)
  57927. * @param reusable If the post process can be reused on the same frame. (default: false)
  57928. * @param textureType Type of textures used when performing the post process. (default: 0)
  57929. * @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)
  57930. */
  57931. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57932. /** Weight of the bloom to be added to the original input. */
  57933. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57934. }
  57935. }
  57936. declare module "babylonjs/PostProcesses/bloomEffect" {
  57937. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57938. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57939. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57940. import { Camera } from "babylonjs/Cameras/camera";
  57941. import { Scene } from "babylonjs/scene";
  57942. /**
  57943. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57944. */
  57945. export class BloomEffect extends PostProcessRenderEffect {
  57946. private bloomScale;
  57947. /**
  57948. * @hidden Internal
  57949. */
  57950. _effects: Array<PostProcess>;
  57951. /**
  57952. * @hidden Internal
  57953. */
  57954. _downscale: ExtractHighlightsPostProcess;
  57955. private _blurX;
  57956. private _blurY;
  57957. private _merge;
  57958. /**
  57959. * The luminance threshold to find bright areas of the image to bloom.
  57960. */
  57961. threshold: number;
  57962. /**
  57963. * The strength of the bloom.
  57964. */
  57965. weight: number;
  57966. /**
  57967. * Specifies the size of the bloom blur kernel, relative to the final output size
  57968. */
  57969. kernel: number;
  57970. /**
  57971. * Creates a new instance of @see BloomEffect
  57972. * @param scene The scene the effect belongs to.
  57973. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57974. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57975. * @param bloomWeight The the strength of bloom.
  57976. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57977. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  57978. */
  57979. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57980. /**
  57981. * Disposes each of the internal effects for a given camera.
  57982. * @param camera The camera to dispose the effect on.
  57983. */
  57984. disposeEffects(camera: Camera): void;
  57985. /**
  57986. * @hidden Internal
  57987. */
  57988. _updateEffects(): void;
  57989. /**
  57990. * Internal
  57991. * @returns if all the contained post processes are ready.
  57992. * @hidden
  57993. */
  57994. _isReady(): boolean;
  57995. }
  57996. }
  57997. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57998. /** @hidden */
  57999. export var chromaticAberrationPixelShader: {
  58000. name: string;
  58001. shader: string;
  58002. };
  58003. }
  58004. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  58005. import { Vector2 } from "babylonjs/Maths/math";
  58006. import { Nullable } from "babylonjs/types";
  58007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58008. import { Camera } from "babylonjs/Cameras/camera";
  58009. import { Engine } from "babylonjs/Engines/engine";
  58010. import "babylonjs/Shaders/chromaticAberration.fragment";
  58011. /**
  58012. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58013. */
  58014. export class ChromaticAberrationPostProcess extends PostProcess {
  58015. /**
  58016. * The amount of seperation of rgb channels (default: 30)
  58017. */
  58018. aberrationAmount: number;
  58019. /**
  58020. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58021. */
  58022. radialIntensity: number;
  58023. /**
  58024. * 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))
  58025. */
  58026. direction: Vector2;
  58027. /**
  58028. * 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))
  58029. */
  58030. centerPosition: Vector2;
  58031. /**
  58032. * Creates a new instance ChromaticAberrationPostProcess
  58033. * @param name The name of the effect.
  58034. * @param screenWidth The width of the screen to apply the effect on.
  58035. * @param screenHeight The height of the screen to apply the effect on.
  58036. * @param options The required width/height ratio to downsize to before computing the render pass.
  58037. * @param camera The camera to apply the render pass to.
  58038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58039. * @param engine The engine which the post process will be applied. (default: current engine)
  58040. * @param reusable If the post process can be reused on the same frame. (default: false)
  58041. * @param textureType Type of textures used when performing the post process. (default: 0)
  58042. * @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)
  58043. */
  58044. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58045. }
  58046. }
  58047. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  58048. /** @hidden */
  58049. export var circleOfConfusionPixelShader: {
  58050. name: string;
  58051. shader: string;
  58052. };
  58053. }
  58054. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  58055. import { Nullable } from "babylonjs/types";
  58056. import { Engine } from "babylonjs/Engines/engine";
  58057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58058. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58059. import { Camera } from "babylonjs/Cameras/camera";
  58060. import "babylonjs/Shaders/circleOfConfusion.fragment";
  58061. /**
  58062. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58063. */
  58064. export class CircleOfConfusionPostProcess extends PostProcess {
  58065. /**
  58066. * 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.
  58067. */
  58068. lensSize: number;
  58069. /**
  58070. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58071. */
  58072. fStop: number;
  58073. /**
  58074. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58075. */
  58076. focusDistance: number;
  58077. /**
  58078. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58079. */
  58080. focalLength: number;
  58081. private _depthTexture;
  58082. /**
  58083. * Creates a new instance CircleOfConfusionPostProcess
  58084. * @param name The name of the effect.
  58085. * @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.
  58086. * @param options The required width/height ratio to downsize to before computing the render pass.
  58087. * @param camera The camera to apply the render pass to.
  58088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58089. * @param engine The engine which the post process will be applied. (default: current engine)
  58090. * @param reusable If the post process can be reused on the same frame. (default: false)
  58091. * @param textureType Type of textures used when performing the post process. (default: 0)
  58092. * @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)
  58093. */
  58094. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58095. /**
  58096. * 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.
  58097. */
  58098. depthTexture: RenderTargetTexture;
  58099. }
  58100. }
  58101. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58102. /** @hidden */
  58103. export var colorCorrectionPixelShader: {
  58104. name: string;
  58105. shader: string;
  58106. };
  58107. }
  58108. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58110. import { Engine } from "babylonjs/Engines/engine";
  58111. import { Camera } from "babylonjs/Cameras/camera";
  58112. import "babylonjs/Shaders/colorCorrection.fragment";
  58113. /**
  58114. *
  58115. * This post-process allows the modification of rendered colors by using
  58116. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58117. *
  58118. * The object needs to be provided an url to a texture containing the color
  58119. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58120. * Use an image editing software to tweak the LUT to match your needs.
  58121. *
  58122. * For an example of a color LUT, see here:
  58123. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58124. * For explanations on color grading, see here:
  58125. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58126. *
  58127. */
  58128. export class ColorCorrectionPostProcess extends PostProcess {
  58129. private _colorTableTexture;
  58130. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58131. }
  58132. }
  58133. declare module "babylonjs/Shaders/convolution.fragment" {
  58134. /** @hidden */
  58135. export var convolutionPixelShader: {
  58136. name: string;
  58137. shader: string;
  58138. };
  58139. }
  58140. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58142. import { Nullable } from "babylonjs/types";
  58143. import { Camera } from "babylonjs/Cameras/camera";
  58144. import { Engine } from "babylonjs/Engines/engine";
  58145. import "babylonjs/Shaders/convolution.fragment";
  58146. /**
  58147. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58148. * input texture to perform effects such as edge detection or sharpening
  58149. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58150. */
  58151. export class ConvolutionPostProcess extends PostProcess {
  58152. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58153. kernel: number[];
  58154. /**
  58155. * Creates a new instance ConvolutionPostProcess
  58156. * @param name The name of the effect.
  58157. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58158. * @param options The required width/height ratio to downsize to before computing the render pass.
  58159. * @param camera The camera to apply the render pass to.
  58160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58161. * @param engine The engine which the post process will be applied. (default: current engine)
  58162. * @param reusable If the post process can be reused on the same frame. (default: false)
  58163. * @param textureType Type of textures used when performing the post process. (default: 0)
  58164. */
  58165. constructor(name: string,
  58166. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58167. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58168. /**
  58169. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58170. */
  58171. static EdgeDetect0Kernel: number[];
  58172. /**
  58173. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58174. */
  58175. static EdgeDetect1Kernel: number[];
  58176. /**
  58177. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58178. */
  58179. static EdgeDetect2Kernel: number[];
  58180. /**
  58181. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58182. */
  58183. static SharpenKernel: number[];
  58184. /**
  58185. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58186. */
  58187. static EmbossKernel: number[];
  58188. /**
  58189. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58190. */
  58191. static GaussianKernel: number[];
  58192. }
  58193. }
  58194. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58195. import { Nullable } from "babylonjs/types";
  58196. import { Vector2 } from "babylonjs/Maths/math";
  58197. import { Camera } from "babylonjs/Cameras/camera";
  58198. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58199. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58200. import { Engine } from "babylonjs/Engines/engine";
  58201. import { Scene } from "babylonjs/scene";
  58202. /**
  58203. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58204. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58205. * based on samples that have a large difference in distance than the center pixel.
  58206. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58207. */
  58208. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58209. direction: Vector2;
  58210. /**
  58211. * Creates a new instance CircleOfConfusionPostProcess
  58212. * @param name The name of the effect.
  58213. * @param scene The scene the effect belongs to.
  58214. * @param direction The direction the blur should be applied.
  58215. * @param kernel The size of the kernel used to blur.
  58216. * @param options The required width/height ratio to downsize to before computing the render pass.
  58217. * @param camera The camera to apply the render pass to.
  58218. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58219. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58221. * @param engine The engine which the post process will be applied. (default: current engine)
  58222. * @param reusable If the post process can be reused on the same frame. (default: false)
  58223. * @param textureType Type of textures used when performing the post process. (default: 0)
  58224. * @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)
  58225. */
  58226. 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);
  58227. }
  58228. }
  58229. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58230. /** @hidden */
  58231. export var depthOfFieldMergePixelShader: {
  58232. name: string;
  58233. shader: string;
  58234. };
  58235. }
  58236. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58237. import { Nullable } from "babylonjs/types";
  58238. import { Camera } from "babylonjs/Cameras/camera";
  58239. import { Effect } from "babylonjs/Materials/effect";
  58240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58241. import { Engine } from "babylonjs/Engines/engine";
  58242. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58243. /**
  58244. * Options to be set when merging outputs from the default pipeline.
  58245. */
  58246. export class DepthOfFieldMergePostProcessOptions {
  58247. /**
  58248. * The original image to merge on top of
  58249. */
  58250. originalFromInput: PostProcess;
  58251. /**
  58252. * Parameters to perform the merge of the depth of field effect
  58253. */
  58254. depthOfField?: {
  58255. circleOfConfusion: PostProcess;
  58256. blurSteps: Array<PostProcess>;
  58257. };
  58258. /**
  58259. * Parameters to perform the merge of bloom effect
  58260. */
  58261. bloom?: {
  58262. blurred: PostProcess;
  58263. weight: number;
  58264. };
  58265. }
  58266. /**
  58267. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58268. */
  58269. export class DepthOfFieldMergePostProcess extends PostProcess {
  58270. private blurSteps;
  58271. /**
  58272. * Creates a new instance of DepthOfFieldMergePostProcess
  58273. * @param name The name of the effect.
  58274. * @param originalFromInput Post process which's input will be used for the merge.
  58275. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58276. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58277. * @param options The required width/height ratio to downsize to before computing the render pass.
  58278. * @param camera The camera to apply the render pass to.
  58279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58280. * @param engine The engine which the post process will be applied. (default: current engine)
  58281. * @param reusable If the post process can be reused on the same frame. (default: false)
  58282. * @param textureType Type of textures used when performing the post process. (default: 0)
  58283. * @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)
  58284. */
  58285. 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);
  58286. /**
  58287. * Updates the effect with the current post process compile time values and recompiles the shader.
  58288. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58289. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58290. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58291. * @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
  58292. * @param onCompiled Called when the shader has been compiled.
  58293. * @param onError Called if there is an error when compiling a shader.
  58294. */
  58295. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58296. }
  58297. }
  58298. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58299. import { Nullable } from "babylonjs/types";
  58300. import { Camera } from "babylonjs/Cameras/camera";
  58301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58302. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58303. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58304. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58305. import { Scene } from "babylonjs/scene";
  58306. /**
  58307. * Specifies the level of max blur that should be applied when using the depth of field effect
  58308. */
  58309. export enum DepthOfFieldEffectBlurLevel {
  58310. /**
  58311. * Subtle blur
  58312. */
  58313. Low = 0,
  58314. /**
  58315. * Medium blur
  58316. */
  58317. Medium = 1,
  58318. /**
  58319. * Large blur
  58320. */
  58321. High = 2
  58322. }
  58323. /**
  58324. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58325. */
  58326. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58327. private _circleOfConfusion;
  58328. /**
  58329. * @hidden Internal, blurs from high to low
  58330. */
  58331. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58332. private _depthOfFieldBlurY;
  58333. private _dofMerge;
  58334. /**
  58335. * @hidden Internal post processes in depth of field effect
  58336. */
  58337. _effects: Array<PostProcess>;
  58338. /**
  58339. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58340. */
  58341. focalLength: number;
  58342. /**
  58343. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58344. */
  58345. fStop: number;
  58346. /**
  58347. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58348. */
  58349. focusDistance: number;
  58350. /**
  58351. * 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.
  58352. */
  58353. lensSize: number;
  58354. /**
  58355. * Creates a new instance DepthOfFieldEffect
  58356. * @param scene The scene the effect belongs to.
  58357. * @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.
  58358. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58359. * @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)
  58360. */
  58361. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58362. /**
  58363. * Get the current class name of the current effet
  58364. * @returns "DepthOfFieldEffect"
  58365. */
  58366. getClassName(): string;
  58367. /**
  58368. * 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.
  58369. */
  58370. depthTexture: RenderTargetTexture;
  58371. /**
  58372. * Disposes each of the internal effects for a given camera.
  58373. * @param camera The camera to dispose the effect on.
  58374. */
  58375. disposeEffects(camera: Camera): void;
  58376. /**
  58377. * @hidden Internal
  58378. */
  58379. _updateEffects(): void;
  58380. /**
  58381. * Internal
  58382. * @returns if all the contained post processes are ready.
  58383. * @hidden
  58384. */
  58385. _isReady(): boolean;
  58386. }
  58387. }
  58388. declare module "babylonjs/Shaders/displayPass.fragment" {
  58389. /** @hidden */
  58390. export var displayPassPixelShader: {
  58391. name: string;
  58392. shader: string;
  58393. };
  58394. }
  58395. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58396. import { Nullable } from "babylonjs/types";
  58397. import { Camera } from "babylonjs/Cameras/camera";
  58398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58399. import { Engine } from "babylonjs/Engines/engine";
  58400. import "babylonjs/Shaders/displayPass.fragment";
  58401. /**
  58402. * DisplayPassPostProcess which produces an output the same as it's input
  58403. */
  58404. export class DisplayPassPostProcess extends PostProcess {
  58405. /**
  58406. * Creates the DisplayPassPostProcess
  58407. * @param name The name of the effect.
  58408. * @param options The required width/height ratio to downsize to before computing the render pass.
  58409. * @param camera The camera to apply the render pass to.
  58410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58411. * @param engine The engine which the post process will be applied. (default: current engine)
  58412. * @param reusable If the post process can be reused on the same frame. (default: false)
  58413. */
  58414. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58415. }
  58416. }
  58417. declare module "babylonjs/Shaders/filter.fragment" {
  58418. /** @hidden */
  58419. export var filterPixelShader: {
  58420. name: string;
  58421. shader: string;
  58422. };
  58423. }
  58424. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58425. import { Nullable } from "babylonjs/types";
  58426. import { Matrix } from "babylonjs/Maths/math";
  58427. import { Camera } from "babylonjs/Cameras/camera";
  58428. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58429. import { Engine } from "babylonjs/Engines/engine";
  58430. import "babylonjs/Shaders/filter.fragment";
  58431. /**
  58432. * Applies a kernel filter to the image
  58433. */
  58434. export class FilterPostProcess extends PostProcess {
  58435. /** The matrix to be applied to the image */
  58436. kernelMatrix: Matrix;
  58437. /**
  58438. *
  58439. * @param name The name of the effect.
  58440. * @param kernelMatrix The matrix to be applied to the image
  58441. * @param options The required width/height ratio to downsize to before computing the render pass.
  58442. * @param camera The camera to apply the render pass to.
  58443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58444. * @param engine The engine which the post process will be applied. (default: current engine)
  58445. * @param reusable If the post process can be reused on the same frame. (default: false)
  58446. */
  58447. constructor(name: string,
  58448. /** The matrix to be applied to the image */
  58449. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58450. }
  58451. }
  58452. declare module "babylonjs/Shaders/fxaa.fragment" {
  58453. /** @hidden */
  58454. export var fxaaPixelShader: {
  58455. name: string;
  58456. shader: string;
  58457. };
  58458. }
  58459. declare module "babylonjs/Shaders/fxaa.vertex" {
  58460. /** @hidden */
  58461. export var fxaaVertexShader: {
  58462. name: string;
  58463. shader: string;
  58464. };
  58465. }
  58466. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58467. import { Nullable } from "babylonjs/types";
  58468. import { Camera } from "babylonjs/Cameras/camera";
  58469. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58470. import { Engine } from "babylonjs/Engines/engine";
  58471. import "babylonjs/Shaders/fxaa.fragment";
  58472. import "babylonjs/Shaders/fxaa.vertex";
  58473. /**
  58474. * Fxaa post process
  58475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58476. */
  58477. export class FxaaPostProcess extends PostProcess {
  58478. /** @hidden */
  58479. texelWidth: number;
  58480. /** @hidden */
  58481. texelHeight: number;
  58482. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58483. private _getDefines;
  58484. }
  58485. }
  58486. declare module "babylonjs/Shaders/grain.fragment" {
  58487. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58488. /** @hidden */
  58489. export var grainPixelShader: {
  58490. name: string;
  58491. shader: string;
  58492. };
  58493. }
  58494. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58495. import { Nullable } from "babylonjs/types";
  58496. import { Camera } from "babylonjs/Cameras/camera";
  58497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58498. import { Engine } from "babylonjs/Engines/engine";
  58499. import "babylonjs/Shaders/grain.fragment";
  58500. /**
  58501. * The GrainPostProcess adds noise to the image at mid luminance levels
  58502. */
  58503. export class GrainPostProcess extends PostProcess {
  58504. /**
  58505. * The intensity of the grain added (default: 30)
  58506. */
  58507. intensity: number;
  58508. /**
  58509. * If the grain should be randomized on every frame
  58510. */
  58511. animated: boolean;
  58512. /**
  58513. * Creates a new instance of @see GrainPostProcess
  58514. * @param name The name of the effect.
  58515. * @param options The required width/height ratio to downsize to before computing the render pass.
  58516. * @param camera The camera to apply the render pass to.
  58517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58518. * @param engine The engine which the post process will be applied. (default: current engine)
  58519. * @param reusable If the post process can be reused on the same frame. (default: false)
  58520. * @param textureType Type of textures used when performing the post process. (default: 0)
  58521. * @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)
  58522. */
  58523. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58524. }
  58525. }
  58526. declare module "babylonjs/Shaders/highlights.fragment" {
  58527. /** @hidden */
  58528. export var highlightsPixelShader: {
  58529. name: string;
  58530. shader: string;
  58531. };
  58532. }
  58533. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58534. import { Nullable } from "babylonjs/types";
  58535. import { Camera } from "babylonjs/Cameras/camera";
  58536. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58537. import { Engine } from "babylonjs/Engines/engine";
  58538. import "babylonjs/Shaders/highlights.fragment";
  58539. /**
  58540. * Extracts highlights from the image
  58541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58542. */
  58543. export class HighlightsPostProcess extends PostProcess {
  58544. /**
  58545. * Extracts highlights from the image
  58546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58547. * @param name The name of the effect.
  58548. * @param options The required width/height ratio to downsize to before computing the render pass.
  58549. * @param camera The camera to apply the render pass to.
  58550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58551. * @param engine The engine which the post process will be applied. (default: current engine)
  58552. * @param reusable If the post process can be reused on the same frame. (default: false)
  58553. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58554. */
  58555. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58556. }
  58557. }
  58558. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58559. /** @hidden */
  58560. export var mrtFragmentDeclaration: {
  58561. name: string;
  58562. shader: string;
  58563. };
  58564. }
  58565. declare module "babylonjs/Shaders/geometry.fragment" {
  58566. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58567. /** @hidden */
  58568. export var geometryPixelShader: {
  58569. name: string;
  58570. shader: string;
  58571. };
  58572. }
  58573. declare module "babylonjs/Shaders/geometry.vertex" {
  58574. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58576. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58577. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58579. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58580. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58581. /** @hidden */
  58582. export var geometryVertexShader: {
  58583. name: string;
  58584. shader: string;
  58585. };
  58586. }
  58587. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58588. import { Matrix } from "babylonjs/Maths/math";
  58589. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58590. import { Mesh } from "babylonjs/Meshes/mesh";
  58591. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58592. import { Effect } from "babylonjs/Materials/effect";
  58593. import { Scene } from "babylonjs/scene";
  58594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58595. import "babylonjs/Shaders/geometry.fragment";
  58596. import "babylonjs/Shaders/geometry.vertex";
  58597. /** @hidden */
  58598. interface ISavedTransformationMatrix {
  58599. world: Matrix;
  58600. viewProjection: Matrix;
  58601. }
  58602. /**
  58603. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58604. */
  58605. export class GeometryBufferRenderer {
  58606. /**
  58607. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58608. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58609. */
  58610. static readonly POSITION_TEXTURE_TYPE: number;
  58611. /**
  58612. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58613. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58614. */
  58615. static readonly VELOCITY_TEXTURE_TYPE: number;
  58616. /**
  58617. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58618. * in order to compute objects velocities when enableVelocity is set to "true"
  58619. * @hidden
  58620. */
  58621. _previousTransformationMatrices: {
  58622. [index: number]: ISavedTransformationMatrix;
  58623. };
  58624. /**
  58625. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58626. * in order to compute objects velocities when enableVelocity is set to "true"
  58627. * @hidden
  58628. */
  58629. _previousBonesTransformationMatrices: {
  58630. [index: number]: Float32Array;
  58631. };
  58632. /**
  58633. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58634. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58635. */
  58636. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58637. private _scene;
  58638. private _multiRenderTarget;
  58639. private _ratio;
  58640. private _enablePosition;
  58641. private _enableVelocity;
  58642. private _positionIndex;
  58643. private _velocityIndex;
  58644. protected _effect: Effect;
  58645. protected _cachedDefines: string;
  58646. /**
  58647. * Set the render list (meshes to be rendered) used in the G buffer.
  58648. */
  58649. renderList: Mesh[];
  58650. /**
  58651. * Gets wether or not G buffer are supported by the running hardware.
  58652. * This requires draw buffer supports
  58653. */
  58654. readonly isSupported: boolean;
  58655. /**
  58656. * Returns the index of the given texture type in the G-Buffer textures array
  58657. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58658. * @returns the index of the given texture type in the G-Buffer textures array
  58659. */
  58660. getTextureIndex(textureType: number): number;
  58661. /**
  58662. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58663. */
  58664. /**
  58665. * Sets whether or not objects positions are enabled for the G buffer.
  58666. */
  58667. enablePosition: boolean;
  58668. /**
  58669. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58670. */
  58671. /**
  58672. * Sets wether or not objects velocities are enabled for the G buffer.
  58673. */
  58674. enableVelocity: boolean;
  58675. /**
  58676. * Gets the scene associated with the buffer.
  58677. */
  58678. readonly scene: Scene;
  58679. /**
  58680. * Gets the ratio used by the buffer during its creation.
  58681. * How big is the buffer related to the main canvas.
  58682. */
  58683. readonly ratio: number;
  58684. /** @hidden */
  58685. static _SceneComponentInitialization: (scene: Scene) => void;
  58686. /**
  58687. * Creates a new G Buffer for the scene
  58688. * @param scene The scene the buffer belongs to
  58689. * @param ratio How big is the buffer related to the main canvas.
  58690. */
  58691. constructor(scene: Scene, ratio?: number);
  58692. /**
  58693. * Checks wether everything is ready to render a submesh to the G buffer.
  58694. * @param subMesh the submesh to check readiness for
  58695. * @param useInstances is the mesh drawn using instance or not
  58696. * @returns true if ready otherwise false
  58697. */
  58698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58699. /**
  58700. * Gets the current underlying G Buffer.
  58701. * @returns the buffer
  58702. */
  58703. getGBuffer(): MultiRenderTarget;
  58704. /**
  58705. * Gets the number of samples used to render the buffer (anti aliasing).
  58706. */
  58707. /**
  58708. * Sets the number of samples used to render the buffer (anti aliasing).
  58709. */
  58710. samples: number;
  58711. /**
  58712. * Disposes the renderer and frees up associated resources.
  58713. */
  58714. dispose(): void;
  58715. protected _createRenderTargets(): void;
  58716. private _copyBonesTransformationMatrices;
  58717. }
  58718. }
  58719. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58720. import { Nullable } from "babylonjs/types";
  58721. import { Scene } from "babylonjs/scene";
  58722. import { ISceneComponent } from "babylonjs/sceneComponent";
  58723. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58724. module "babylonjs/scene" {
  58725. interface Scene {
  58726. /** @hidden (Backing field) */
  58727. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58728. /**
  58729. * Gets or Sets the current geometry buffer associated to the scene.
  58730. */
  58731. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58732. /**
  58733. * Enables a GeometryBufferRender and associates it with the scene
  58734. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58735. * @returns the GeometryBufferRenderer
  58736. */
  58737. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58738. /**
  58739. * Disables the GeometryBufferRender associated with the scene
  58740. */
  58741. disableGeometryBufferRenderer(): void;
  58742. }
  58743. }
  58744. /**
  58745. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58746. * in several rendering techniques.
  58747. */
  58748. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58749. /**
  58750. * The component name helpful to identify the component in the list of scene components.
  58751. */
  58752. readonly name: string;
  58753. /**
  58754. * The scene the component belongs to.
  58755. */
  58756. scene: Scene;
  58757. /**
  58758. * Creates a new instance of the component for the given scene
  58759. * @param scene Defines the scene to register the component in
  58760. */
  58761. constructor(scene: Scene);
  58762. /**
  58763. * Registers the component in a given scene
  58764. */
  58765. register(): void;
  58766. /**
  58767. * Rebuilds the elements related to this component in case of
  58768. * context lost for instance.
  58769. */
  58770. rebuild(): void;
  58771. /**
  58772. * Disposes the component and the associated ressources
  58773. */
  58774. dispose(): void;
  58775. private _gatherRenderTargets;
  58776. }
  58777. }
  58778. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58779. /** @hidden */
  58780. export var motionBlurPixelShader: {
  58781. name: string;
  58782. shader: string;
  58783. };
  58784. }
  58785. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58786. import { Nullable } from "babylonjs/types";
  58787. import { Camera } from "babylonjs/Cameras/camera";
  58788. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58789. import { Scene } from "babylonjs/scene";
  58790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58791. import "babylonjs/Animations/animatable";
  58792. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58793. import "babylonjs/Shaders/motionBlur.fragment";
  58794. import { Engine } from "babylonjs/Engines/engine";
  58795. /**
  58796. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58797. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58798. * As an example, all you have to do is to create the post-process:
  58799. * var mb = new BABYLON.MotionBlurPostProcess(
  58800. * 'mb', // The name of the effect.
  58801. * scene, // The scene containing the objects to blur according to their velocity.
  58802. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58803. * camera // The camera to apply the render pass to.
  58804. * );
  58805. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58806. */
  58807. export class MotionBlurPostProcess extends PostProcess {
  58808. /**
  58809. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58810. */
  58811. motionStrength: number;
  58812. /**
  58813. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58814. */
  58815. /**
  58816. * Sets the number of iterations to be used for motion blur quality
  58817. */
  58818. motionBlurSamples: number;
  58819. private _motionBlurSamples;
  58820. private _geometryBufferRenderer;
  58821. /**
  58822. * Creates a new instance MotionBlurPostProcess
  58823. * @param name The name of the effect.
  58824. * @param scene The scene containing the objects to blur according to their velocity.
  58825. * @param options The required width/height ratio to downsize to before computing the render pass.
  58826. * @param camera The camera to apply the render pass to.
  58827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58828. * @param engine The engine which the post process will be applied. (default: current engine)
  58829. * @param reusable If the post process can be reused on the same frame. (default: false)
  58830. * @param textureType Type of textures used when performing the post process. (default: 0)
  58831. * @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)
  58832. */
  58833. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58834. /**
  58835. * Excludes the given skinned mesh from computing bones velocities.
  58836. * 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.
  58837. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58838. */
  58839. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58840. /**
  58841. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58842. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58843. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58844. */
  58845. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58846. /**
  58847. * Disposes the post process.
  58848. * @param camera The camera to dispose the post process on.
  58849. */
  58850. dispose(camera?: Camera): void;
  58851. }
  58852. }
  58853. declare module "babylonjs/Shaders/refraction.fragment" {
  58854. /** @hidden */
  58855. export var refractionPixelShader: {
  58856. name: string;
  58857. shader: string;
  58858. };
  58859. }
  58860. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58861. import { Color3 } from "babylonjs/Maths/math";
  58862. import { Camera } from "babylonjs/Cameras/camera";
  58863. import { Texture } from "babylonjs/Materials/Textures/texture";
  58864. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58865. import { Engine } from "babylonjs/Engines/engine";
  58866. import "babylonjs/Shaders/refraction.fragment";
  58867. /**
  58868. * Post process which applies a refractin texture
  58869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58870. */
  58871. export class RefractionPostProcess extends PostProcess {
  58872. /** the base color of the refraction (used to taint the rendering) */
  58873. color: Color3;
  58874. /** simulated refraction depth */
  58875. depth: number;
  58876. /** the coefficient of the base color (0 to remove base color tainting) */
  58877. colorLevel: number;
  58878. private _refTexture;
  58879. private _ownRefractionTexture;
  58880. /**
  58881. * Gets or sets the refraction texture
  58882. * Please note that you are responsible for disposing the texture if you set it manually
  58883. */
  58884. refractionTexture: Texture;
  58885. /**
  58886. * Initializes the RefractionPostProcess
  58887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58888. * @param name The name of the effect.
  58889. * @param refractionTextureUrl Url of the refraction texture to use
  58890. * @param color the base color of the refraction (used to taint the rendering)
  58891. * @param depth simulated refraction depth
  58892. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58893. * @param camera The camera to apply the render pass to.
  58894. * @param options The required width/height ratio to downsize to before computing the render pass.
  58895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58896. * @param engine The engine which the post process will be applied. (default: current engine)
  58897. * @param reusable If the post process can be reused on the same frame. (default: false)
  58898. */
  58899. constructor(name: string, refractionTextureUrl: string,
  58900. /** the base color of the refraction (used to taint the rendering) */
  58901. color: Color3,
  58902. /** simulated refraction depth */
  58903. depth: number,
  58904. /** the coefficient of the base color (0 to remove base color tainting) */
  58905. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58906. /**
  58907. * Disposes of the post process
  58908. * @param camera Camera to dispose post process on
  58909. */
  58910. dispose(camera: Camera): void;
  58911. }
  58912. }
  58913. declare module "babylonjs/Shaders/sharpen.fragment" {
  58914. /** @hidden */
  58915. export var sharpenPixelShader: {
  58916. name: string;
  58917. shader: string;
  58918. };
  58919. }
  58920. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58921. import { Nullable } from "babylonjs/types";
  58922. import { Camera } from "babylonjs/Cameras/camera";
  58923. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58924. import "babylonjs/Shaders/sharpen.fragment";
  58925. import { Engine } from "babylonjs/Engines/engine";
  58926. /**
  58927. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58928. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58929. */
  58930. export class SharpenPostProcess extends PostProcess {
  58931. /**
  58932. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58933. */
  58934. colorAmount: number;
  58935. /**
  58936. * How much sharpness should be applied (default: 0.3)
  58937. */
  58938. edgeAmount: number;
  58939. /**
  58940. * Creates a new instance ConvolutionPostProcess
  58941. * @param name The name of the effect.
  58942. * @param options The required width/height ratio to downsize to before computing the render pass.
  58943. * @param camera The camera to apply the render pass to.
  58944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58945. * @param engine The engine which the post process will be applied. (default: current engine)
  58946. * @param reusable If the post process can be reused on the same frame. (default: false)
  58947. * @param textureType Type of textures used when performing the post process. (default: 0)
  58948. * @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)
  58949. */
  58950. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58951. }
  58952. }
  58953. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58954. import { Nullable } from "babylonjs/types";
  58955. import { Camera } from "babylonjs/Cameras/camera";
  58956. import { Engine } from "babylonjs/Engines/engine";
  58957. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58958. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58959. /**
  58960. * PostProcessRenderPipeline
  58961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58962. */
  58963. export class PostProcessRenderPipeline {
  58964. private engine;
  58965. private _renderEffects;
  58966. private _renderEffectsForIsolatedPass;
  58967. /**
  58968. * List of inspectable custom properties (used by the Inspector)
  58969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58970. */
  58971. inspectableCustomProperties: IInspectable[];
  58972. /**
  58973. * @hidden
  58974. */
  58975. protected _cameras: Camera[];
  58976. /** @hidden */
  58977. _name: string;
  58978. /**
  58979. * Gets pipeline name
  58980. */
  58981. readonly name: string;
  58982. /**
  58983. * Initializes a PostProcessRenderPipeline
  58984. * @param engine engine to add the pipeline to
  58985. * @param name name of the pipeline
  58986. */
  58987. constructor(engine: Engine, name: string);
  58988. /**
  58989. * Gets the class name
  58990. * @returns "PostProcessRenderPipeline"
  58991. */
  58992. getClassName(): string;
  58993. /**
  58994. * If all the render effects in the pipeline are supported
  58995. */
  58996. readonly isSupported: boolean;
  58997. /**
  58998. * Adds an effect to the pipeline
  58999. * @param renderEffect the effect to add
  59000. */
  59001. addEffect(renderEffect: PostProcessRenderEffect): void;
  59002. /** @hidden */
  59003. _rebuild(): void;
  59004. /** @hidden */
  59005. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59006. /** @hidden */
  59007. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59008. /** @hidden */
  59009. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59010. /** @hidden */
  59011. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59012. /** @hidden */
  59013. _attachCameras(cameras: Camera, unique: boolean): void;
  59014. /** @hidden */
  59015. _attachCameras(cameras: Camera[], unique: boolean): void;
  59016. /** @hidden */
  59017. _detachCameras(cameras: Camera): void;
  59018. /** @hidden */
  59019. _detachCameras(cameras: Nullable<Camera[]>): void;
  59020. /** @hidden */
  59021. _update(): void;
  59022. /** @hidden */
  59023. _reset(): void;
  59024. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59025. /**
  59026. * Disposes of the pipeline
  59027. */
  59028. dispose(): void;
  59029. }
  59030. }
  59031. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  59032. import { Camera } from "babylonjs/Cameras/camera";
  59033. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59034. /**
  59035. * PostProcessRenderPipelineManager class
  59036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59037. */
  59038. export class PostProcessRenderPipelineManager {
  59039. private _renderPipelines;
  59040. /**
  59041. * Initializes a PostProcessRenderPipelineManager
  59042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59043. */
  59044. constructor();
  59045. /**
  59046. * Gets the list of supported render pipelines
  59047. */
  59048. readonly supportedPipelines: PostProcessRenderPipeline[];
  59049. /**
  59050. * Adds a pipeline to the manager
  59051. * @param renderPipeline The pipeline to add
  59052. */
  59053. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59054. /**
  59055. * Attaches a camera to the pipeline
  59056. * @param renderPipelineName The name of the pipeline to attach to
  59057. * @param cameras the camera to attach
  59058. * @param unique if the camera can be attached multiple times to the pipeline
  59059. */
  59060. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59061. /**
  59062. * Detaches a camera from the pipeline
  59063. * @param renderPipelineName The name of the pipeline to detach from
  59064. * @param cameras the camera to detach
  59065. */
  59066. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59067. /**
  59068. * Enables an effect by name on a pipeline
  59069. * @param renderPipelineName the name of the pipeline to enable the effect in
  59070. * @param renderEffectName the name of the effect to enable
  59071. * @param cameras the cameras that the effect should be enabled on
  59072. */
  59073. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59074. /**
  59075. * Disables an effect by name on a pipeline
  59076. * @param renderPipelineName the name of the pipeline to disable the effect in
  59077. * @param renderEffectName the name of the effect to disable
  59078. * @param cameras the cameras that the effect should be disabled on
  59079. */
  59080. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59081. /**
  59082. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59083. */
  59084. update(): void;
  59085. /** @hidden */
  59086. _rebuild(): void;
  59087. /**
  59088. * Disposes of the manager and pipelines
  59089. */
  59090. dispose(): void;
  59091. }
  59092. }
  59093. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59094. import { ISceneComponent } from "babylonjs/sceneComponent";
  59095. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59096. import { Scene } from "babylonjs/scene";
  59097. module "babylonjs/scene" {
  59098. interface Scene {
  59099. /** @hidden (Backing field) */
  59100. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59101. /**
  59102. * Gets the postprocess render pipeline manager
  59103. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59104. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59105. */
  59106. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59107. }
  59108. }
  59109. /**
  59110. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59111. */
  59112. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59113. /**
  59114. * The component name helpfull to identify the component in the list of scene components.
  59115. */
  59116. readonly name: string;
  59117. /**
  59118. * The scene the component belongs to.
  59119. */
  59120. scene: Scene;
  59121. /**
  59122. * Creates a new instance of the component for the given scene
  59123. * @param scene Defines the scene to register the component in
  59124. */
  59125. constructor(scene: Scene);
  59126. /**
  59127. * Registers the component in a given scene
  59128. */
  59129. register(): void;
  59130. /**
  59131. * Rebuilds the elements related to this component in case of
  59132. * context lost for instance.
  59133. */
  59134. rebuild(): void;
  59135. /**
  59136. * Disposes the component and the associated ressources
  59137. */
  59138. dispose(): void;
  59139. private _gatherRenderTargets;
  59140. }
  59141. }
  59142. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59143. import { Nullable } from "babylonjs/types";
  59144. import { IAnimatable } from "babylonjs/Misc/tools";
  59145. import { Camera } from "babylonjs/Cameras/camera";
  59146. import { IDisposable } from "babylonjs/scene";
  59147. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59148. import { Scene } from "babylonjs/scene";
  59149. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59150. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59151. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59152. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59153. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59154. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59155. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59156. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59157. import { Animation } from "babylonjs/Animations/animation";
  59158. /**
  59159. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59160. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59161. */
  59162. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59163. private _scene;
  59164. private _camerasToBeAttached;
  59165. /**
  59166. * ID of the sharpen post process,
  59167. */
  59168. private readonly SharpenPostProcessId;
  59169. /**
  59170. * @ignore
  59171. * ID of the image processing post process;
  59172. */
  59173. readonly ImageProcessingPostProcessId: string;
  59174. /**
  59175. * @ignore
  59176. * ID of the Fast Approximate Anti-Aliasing post process;
  59177. */
  59178. readonly FxaaPostProcessId: string;
  59179. /**
  59180. * ID of the chromatic aberration post process,
  59181. */
  59182. private readonly ChromaticAberrationPostProcessId;
  59183. /**
  59184. * ID of the grain post process
  59185. */
  59186. private readonly GrainPostProcessId;
  59187. /**
  59188. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59189. */
  59190. sharpen: SharpenPostProcess;
  59191. private _sharpenEffect;
  59192. private bloom;
  59193. /**
  59194. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59195. */
  59196. depthOfField: DepthOfFieldEffect;
  59197. /**
  59198. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59199. */
  59200. fxaa: FxaaPostProcess;
  59201. /**
  59202. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59203. */
  59204. imageProcessing: ImageProcessingPostProcess;
  59205. /**
  59206. * Chromatic aberration post process which will shift rgb colors in the image
  59207. */
  59208. chromaticAberration: ChromaticAberrationPostProcess;
  59209. private _chromaticAberrationEffect;
  59210. /**
  59211. * Grain post process which add noise to the image
  59212. */
  59213. grain: GrainPostProcess;
  59214. private _grainEffect;
  59215. /**
  59216. * Glow post process which adds a glow to emissive areas of the image
  59217. */
  59218. private _glowLayer;
  59219. /**
  59220. * Animations which can be used to tweak settings over a period of time
  59221. */
  59222. animations: Animation[];
  59223. private _imageProcessingConfigurationObserver;
  59224. private _sharpenEnabled;
  59225. private _bloomEnabled;
  59226. private _depthOfFieldEnabled;
  59227. private _depthOfFieldBlurLevel;
  59228. private _fxaaEnabled;
  59229. private _imageProcessingEnabled;
  59230. private _defaultPipelineTextureType;
  59231. private _bloomScale;
  59232. private _chromaticAberrationEnabled;
  59233. private _grainEnabled;
  59234. private _buildAllowed;
  59235. /**
  59236. * Gets active scene
  59237. */
  59238. readonly scene: Scene;
  59239. /**
  59240. * Enable or disable the sharpen process from the pipeline
  59241. */
  59242. sharpenEnabled: boolean;
  59243. private _resizeObserver;
  59244. private _hardwareScaleLevel;
  59245. private _bloomKernel;
  59246. /**
  59247. * Specifies the size of the bloom blur kernel, relative to the final output size
  59248. */
  59249. bloomKernel: number;
  59250. /**
  59251. * Specifies the weight of the bloom in the final rendering
  59252. */
  59253. private _bloomWeight;
  59254. /**
  59255. * Specifies the luma threshold for the area that will be blurred by the bloom
  59256. */
  59257. private _bloomThreshold;
  59258. private _hdr;
  59259. /**
  59260. * The strength of the bloom.
  59261. */
  59262. bloomWeight: number;
  59263. /**
  59264. * The strength of the bloom.
  59265. */
  59266. bloomThreshold: number;
  59267. /**
  59268. * The scale of the bloom, lower value will provide better performance.
  59269. */
  59270. bloomScale: number;
  59271. /**
  59272. * Enable or disable the bloom from the pipeline
  59273. */
  59274. bloomEnabled: boolean;
  59275. private _rebuildBloom;
  59276. /**
  59277. * If the depth of field is enabled.
  59278. */
  59279. depthOfFieldEnabled: boolean;
  59280. /**
  59281. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59282. */
  59283. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59284. /**
  59285. * If the anti aliasing is enabled.
  59286. */
  59287. fxaaEnabled: boolean;
  59288. private _samples;
  59289. /**
  59290. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59291. */
  59292. samples: number;
  59293. /**
  59294. * If image processing is enabled.
  59295. */
  59296. imageProcessingEnabled: boolean;
  59297. /**
  59298. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59299. */
  59300. glowLayerEnabled: boolean;
  59301. /**
  59302. * Gets the glow layer (or null if not defined)
  59303. */
  59304. readonly glowLayer: Nullable<GlowLayer>;
  59305. /**
  59306. * Enable or disable the chromaticAberration process from the pipeline
  59307. */
  59308. chromaticAberrationEnabled: boolean;
  59309. /**
  59310. * Enable or disable the grain process from the pipeline
  59311. */
  59312. grainEnabled: boolean;
  59313. /**
  59314. * @constructor
  59315. * @param name - The rendering pipeline name (default: "")
  59316. * @param hdr - If high dynamic range textures should be used (default: true)
  59317. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59318. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59319. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59320. */
  59321. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59322. /**
  59323. * Get the class name
  59324. * @returns "DefaultRenderingPipeline"
  59325. */
  59326. getClassName(): string;
  59327. /**
  59328. * Force the compilation of the entire pipeline.
  59329. */
  59330. prepare(): void;
  59331. private _hasCleared;
  59332. private _prevPostProcess;
  59333. private _prevPrevPostProcess;
  59334. private _setAutoClearAndTextureSharing;
  59335. private _depthOfFieldSceneObserver;
  59336. private _buildPipeline;
  59337. private _disposePostProcesses;
  59338. /**
  59339. * Adds a camera to the pipeline
  59340. * @param camera the camera to be added
  59341. */
  59342. addCamera(camera: Camera): void;
  59343. /**
  59344. * Removes a camera from the pipeline
  59345. * @param camera the camera to remove
  59346. */
  59347. removeCamera(camera: Camera): void;
  59348. /**
  59349. * Dispose of the pipeline and stop all post processes
  59350. */
  59351. dispose(): void;
  59352. /**
  59353. * Serialize the rendering pipeline (Used when exporting)
  59354. * @returns the serialized object
  59355. */
  59356. serialize(): any;
  59357. /**
  59358. * Parse the serialized pipeline
  59359. * @param source Source pipeline.
  59360. * @param scene The scene to load the pipeline to.
  59361. * @param rootUrl The URL of the serialized pipeline.
  59362. * @returns An instantiated pipeline from the serialized object.
  59363. */
  59364. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59365. }
  59366. }
  59367. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59368. /** @hidden */
  59369. export var lensHighlightsPixelShader: {
  59370. name: string;
  59371. shader: string;
  59372. };
  59373. }
  59374. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59375. /** @hidden */
  59376. export var depthOfFieldPixelShader: {
  59377. name: string;
  59378. shader: string;
  59379. };
  59380. }
  59381. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59382. import { Camera } from "babylonjs/Cameras/camera";
  59383. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59384. import { Scene } from "babylonjs/scene";
  59385. import "babylonjs/Shaders/chromaticAberration.fragment";
  59386. import "babylonjs/Shaders/lensHighlights.fragment";
  59387. import "babylonjs/Shaders/depthOfField.fragment";
  59388. /**
  59389. * BABYLON.JS Chromatic Aberration GLSL Shader
  59390. * Author: Olivier Guyot
  59391. * Separates very slightly R, G and B colors on the edges of the screen
  59392. * Inspired by Francois Tarlier & Martins Upitis
  59393. */
  59394. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59395. /**
  59396. * @ignore
  59397. * The chromatic aberration PostProcess id in the pipeline
  59398. */
  59399. LensChromaticAberrationEffect: string;
  59400. /**
  59401. * @ignore
  59402. * The highlights enhancing PostProcess id in the pipeline
  59403. */
  59404. HighlightsEnhancingEffect: string;
  59405. /**
  59406. * @ignore
  59407. * The depth-of-field PostProcess id in the pipeline
  59408. */
  59409. LensDepthOfFieldEffect: string;
  59410. private _scene;
  59411. private _depthTexture;
  59412. private _grainTexture;
  59413. private _chromaticAberrationPostProcess;
  59414. private _highlightsPostProcess;
  59415. private _depthOfFieldPostProcess;
  59416. private _edgeBlur;
  59417. private _grainAmount;
  59418. private _chromaticAberration;
  59419. private _distortion;
  59420. private _highlightsGain;
  59421. private _highlightsThreshold;
  59422. private _dofDistance;
  59423. private _dofAperture;
  59424. private _dofDarken;
  59425. private _dofPentagon;
  59426. private _blurNoise;
  59427. /**
  59428. * @constructor
  59429. *
  59430. * Effect parameters are as follow:
  59431. * {
  59432. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59433. * edge_blur: number; // from 0 to x (1 for realism)
  59434. * distortion: number; // from 0 to x (1 for realism)
  59435. * grain_amount: number; // from 0 to 1
  59436. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59437. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59438. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59439. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59440. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59441. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59442. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59443. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59444. * }
  59445. * Note: if an effect parameter is unset, effect is disabled
  59446. *
  59447. * @param name The rendering pipeline name
  59448. * @param parameters - An object containing all parameters (see above)
  59449. * @param scene The scene linked to this pipeline
  59450. * @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)
  59451. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59452. */
  59453. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59454. /**
  59455. * Get the class name
  59456. * @returns "LensRenderingPipeline"
  59457. */
  59458. getClassName(): string;
  59459. /**
  59460. * Gets associated scene
  59461. */
  59462. readonly scene: Scene;
  59463. /**
  59464. * Gets or sets the edge blur
  59465. */
  59466. edgeBlur: number;
  59467. /**
  59468. * Gets or sets the grain amount
  59469. */
  59470. grainAmount: number;
  59471. /**
  59472. * Gets or sets the chromatic aberration amount
  59473. */
  59474. chromaticAberration: number;
  59475. /**
  59476. * Gets or sets the depth of field aperture
  59477. */
  59478. dofAperture: number;
  59479. /**
  59480. * Gets or sets the edge distortion
  59481. */
  59482. edgeDistortion: number;
  59483. /**
  59484. * Gets or sets the depth of field distortion
  59485. */
  59486. dofDistortion: number;
  59487. /**
  59488. * Gets or sets the darken out of focus amount
  59489. */
  59490. darkenOutOfFocus: number;
  59491. /**
  59492. * Gets or sets a boolean indicating if blur noise is enabled
  59493. */
  59494. blurNoise: boolean;
  59495. /**
  59496. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59497. */
  59498. pentagonBokeh: boolean;
  59499. /**
  59500. * Gets or sets the highlight grain amount
  59501. */
  59502. highlightsGain: number;
  59503. /**
  59504. * Gets or sets the highlight threshold
  59505. */
  59506. highlightsThreshold: number;
  59507. /**
  59508. * Sets the amount of blur at the edges
  59509. * @param amount blur amount
  59510. */
  59511. setEdgeBlur(amount: number): void;
  59512. /**
  59513. * Sets edge blur to 0
  59514. */
  59515. disableEdgeBlur(): void;
  59516. /**
  59517. * Sets the amout of grain
  59518. * @param amount Amount of grain
  59519. */
  59520. setGrainAmount(amount: number): void;
  59521. /**
  59522. * Set grain amount to 0
  59523. */
  59524. disableGrain(): void;
  59525. /**
  59526. * Sets the chromatic aberration amount
  59527. * @param amount amount of chromatic aberration
  59528. */
  59529. setChromaticAberration(amount: number): void;
  59530. /**
  59531. * Sets chromatic aberration amount to 0
  59532. */
  59533. disableChromaticAberration(): void;
  59534. /**
  59535. * Sets the EdgeDistortion amount
  59536. * @param amount amount of EdgeDistortion
  59537. */
  59538. setEdgeDistortion(amount: number): void;
  59539. /**
  59540. * Sets edge distortion to 0
  59541. */
  59542. disableEdgeDistortion(): void;
  59543. /**
  59544. * Sets the FocusDistance amount
  59545. * @param amount amount of FocusDistance
  59546. */
  59547. setFocusDistance(amount: number): void;
  59548. /**
  59549. * Disables depth of field
  59550. */
  59551. disableDepthOfField(): void;
  59552. /**
  59553. * Sets the Aperture amount
  59554. * @param amount amount of Aperture
  59555. */
  59556. setAperture(amount: number): void;
  59557. /**
  59558. * Sets the DarkenOutOfFocus amount
  59559. * @param amount amount of DarkenOutOfFocus
  59560. */
  59561. setDarkenOutOfFocus(amount: number): void;
  59562. private _pentagonBokehIsEnabled;
  59563. /**
  59564. * Creates a pentagon bokeh effect
  59565. */
  59566. enablePentagonBokeh(): void;
  59567. /**
  59568. * Disables the pentagon bokeh effect
  59569. */
  59570. disablePentagonBokeh(): void;
  59571. /**
  59572. * Enables noise blur
  59573. */
  59574. enableNoiseBlur(): void;
  59575. /**
  59576. * Disables noise blur
  59577. */
  59578. disableNoiseBlur(): void;
  59579. /**
  59580. * Sets the HighlightsGain amount
  59581. * @param amount amount of HighlightsGain
  59582. */
  59583. setHighlightsGain(amount: number): void;
  59584. /**
  59585. * Sets the HighlightsThreshold amount
  59586. * @param amount amount of HighlightsThreshold
  59587. */
  59588. setHighlightsThreshold(amount: number): void;
  59589. /**
  59590. * Disables highlights
  59591. */
  59592. disableHighlights(): void;
  59593. /**
  59594. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59595. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59596. */
  59597. dispose(disableDepthRender?: boolean): void;
  59598. private _createChromaticAberrationPostProcess;
  59599. private _createHighlightsPostProcess;
  59600. private _createDepthOfFieldPostProcess;
  59601. private _createGrainTexture;
  59602. }
  59603. }
  59604. declare module "babylonjs/Shaders/ssao2.fragment" {
  59605. /** @hidden */
  59606. export var ssao2PixelShader: {
  59607. name: string;
  59608. shader: string;
  59609. };
  59610. }
  59611. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59612. /** @hidden */
  59613. export var ssaoCombinePixelShader: {
  59614. name: string;
  59615. shader: string;
  59616. };
  59617. }
  59618. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59619. import { Camera } from "babylonjs/Cameras/camera";
  59620. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59621. import { Scene } from "babylonjs/scene";
  59622. import "babylonjs/Shaders/ssao2.fragment";
  59623. import "babylonjs/Shaders/ssaoCombine.fragment";
  59624. /**
  59625. * Render pipeline to produce ssao effect
  59626. */
  59627. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59628. /**
  59629. * @ignore
  59630. * The PassPostProcess id in the pipeline that contains the original scene color
  59631. */
  59632. SSAOOriginalSceneColorEffect: string;
  59633. /**
  59634. * @ignore
  59635. * The SSAO PostProcess id in the pipeline
  59636. */
  59637. SSAORenderEffect: string;
  59638. /**
  59639. * @ignore
  59640. * The horizontal blur PostProcess id in the pipeline
  59641. */
  59642. SSAOBlurHRenderEffect: string;
  59643. /**
  59644. * @ignore
  59645. * The vertical blur PostProcess id in the pipeline
  59646. */
  59647. SSAOBlurVRenderEffect: string;
  59648. /**
  59649. * @ignore
  59650. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59651. */
  59652. SSAOCombineRenderEffect: string;
  59653. /**
  59654. * The output strength of the SSAO post-process. Default value is 1.0.
  59655. */
  59656. totalStrength: number;
  59657. /**
  59658. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59659. */
  59660. maxZ: number;
  59661. /**
  59662. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59663. */
  59664. minZAspect: number;
  59665. private _samples;
  59666. /**
  59667. * Number of samples used for the SSAO calculations. Default value is 8
  59668. */
  59669. samples: number;
  59670. private _textureSamples;
  59671. /**
  59672. * Number of samples to use for antialiasing
  59673. */
  59674. textureSamples: number;
  59675. /**
  59676. * Ratio object used for SSAO ratio and blur ratio
  59677. */
  59678. private _ratio;
  59679. /**
  59680. * Dynamically generated sphere sampler.
  59681. */
  59682. private _sampleSphere;
  59683. /**
  59684. * Blur filter offsets
  59685. */
  59686. private _samplerOffsets;
  59687. private _expensiveBlur;
  59688. /**
  59689. * If bilateral blur should be used
  59690. */
  59691. expensiveBlur: boolean;
  59692. /**
  59693. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59694. */
  59695. radius: number;
  59696. /**
  59697. * The base color of the SSAO post-process
  59698. * The final result is "base + ssao" between [0, 1]
  59699. */
  59700. base: number;
  59701. /**
  59702. * Support test.
  59703. */
  59704. static readonly IsSupported: boolean;
  59705. private _scene;
  59706. private _depthTexture;
  59707. private _normalTexture;
  59708. private _randomTexture;
  59709. private _originalColorPostProcess;
  59710. private _ssaoPostProcess;
  59711. private _blurHPostProcess;
  59712. private _blurVPostProcess;
  59713. private _ssaoCombinePostProcess;
  59714. private _firstUpdate;
  59715. /**
  59716. * Gets active scene
  59717. */
  59718. readonly scene: Scene;
  59719. /**
  59720. * @constructor
  59721. * @param name The rendering pipeline name
  59722. * @param scene The scene linked to this pipeline
  59723. * @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 }
  59724. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59725. */
  59726. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59727. /**
  59728. * Get the class name
  59729. * @returns "SSAO2RenderingPipeline"
  59730. */
  59731. getClassName(): string;
  59732. /**
  59733. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59734. */
  59735. dispose(disableGeometryBufferRenderer?: boolean): void;
  59736. private _createBlurPostProcess;
  59737. /** @hidden */
  59738. _rebuild(): void;
  59739. private _bits;
  59740. private _radicalInverse_VdC;
  59741. private _hammersley;
  59742. private _hemisphereSample_uniform;
  59743. private _generateHemisphere;
  59744. private _createSSAOPostProcess;
  59745. private _createSSAOCombinePostProcess;
  59746. private _createRandomTexture;
  59747. /**
  59748. * Serialize the rendering pipeline (Used when exporting)
  59749. * @returns the serialized object
  59750. */
  59751. serialize(): any;
  59752. /**
  59753. * Parse the serialized pipeline
  59754. * @param source Source pipeline.
  59755. * @param scene The scene to load the pipeline to.
  59756. * @param rootUrl The URL of the serialized pipeline.
  59757. * @returns An instantiated pipeline from the serialized object.
  59758. */
  59759. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59760. }
  59761. }
  59762. declare module "babylonjs/Shaders/ssao.fragment" {
  59763. /** @hidden */
  59764. export var ssaoPixelShader: {
  59765. name: string;
  59766. shader: string;
  59767. };
  59768. }
  59769. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59770. import { Camera } from "babylonjs/Cameras/camera";
  59771. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59772. import { Scene } from "babylonjs/scene";
  59773. import "babylonjs/Shaders/ssao.fragment";
  59774. import "babylonjs/Shaders/ssaoCombine.fragment";
  59775. /**
  59776. * Render pipeline to produce ssao effect
  59777. */
  59778. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59779. /**
  59780. * @ignore
  59781. * The PassPostProcess id in the pipeline that contains the original scene color
  59782. */
  59783. SSAOOriginalSceneColorEffect: string;
  59784. /**
  59785. * @ignore
  59786. * The SSAO PostProcess id in the pipeline
  59787. */
  59788. SSAORenderEffect: string;
  59789. /**
  59790. * @ignore
  59791. * The horizontal blur PostProcess id in the pipeline
  59792. */
  59793. SSAOBlurHRenderEffect: string;
  59794. /**
  59795. * @ignore
  59796. * The vertical blur PostProcess id in the pipeline
  59797. */
  59798. SSAOBlurVRenderEffect: string;
  59799. /**
  59800. * @ignore
  59801. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59802. */
  59803. SSAOCombineRenderEffect: string;
  59804. /**
  59805. * The output strength of the SSAO post-process. Default value is 1.0.
  59806. */
  59807. totalStrength: number;
  59808. /**
  59809. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59810. */
  59811. radius: number;
  59812. /**
  59813. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59814. * Must not be equal to fallOff and superior to fallOff.
  59815. * Default value is 0.0075
  59816. */
  59817. area: number;
  59818. /**
  59819. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59820. * Must not be equal to area and inferior to area.
  59821. * Default value is 0.000001
  59822. */
  59823. fallOff: number;
  59824. /**
  59825. * The base color of the SSAO post-process
  59826. * The final result is "base + ssao" between [0, 1]
  59827. */
  59828. base: number;
  59829. private _scene;
  59830. private _depthTexture;
  59831. private _randomTexture;
  59832. private _originalColorPostProcess;
  59833. private _ssaoPostProcess;
  59834. private _blurHPostProcess;
  59835. private _blurVPostProcess;
  59836. private _ssaoCombinePostProcess;
  59837. private _firstUpdate;
  59838. /**
  59839. * Gets active scene
  59840. */
  59841. readonly scene: Scene;
  59842. /**
  59843. * @constructor
  59844. * @param name - The rendering pipeline name
  59845. * @param scene - The scene linked to this pipeline
  59846. * @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 }
  59847. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59848. */
  59849. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59850. /**
  59851. * Get the class name
  59852. * @returns "SSAORenderingPipeline"
  59853. */
  59854. getClassName(): string;
  59855. /**
  59856. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59857. */
  59858. dispose(disableDepthRender?: boolean): void;
  59859. private _createBlurPostProcess;
  59860. /** @hidden */
  59861. _rebuild(): void;
  59862. private _createSSAOPostProcess;
  59863. private _createSSAOCombinePostProcess;
  59864. private _createRandomTexture;
  59865. }
  59866. }
  59867. declare module "babylonjs/Shaders/standard.fragment" {
  59868. /** @hidden */
  59869. export var standardPixelShader: {
  59870. name: string;
  59871. shader: string;
  59872. };
  59873. }
  59874. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59875. import { Nullable } from "babylonjs/types";
  59876. import { IAnimatable } from "babylonjs/Misc/tools";
  59877. import { Camera } from "babylonjs/Cameras/camera";
  59878. import { Texture } from "babylonjs/Materials/Textures/texture";
  59879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59880. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59881. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59882. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59883. import { IDisposable } from "babylonjs/scene";
  59884. import { SpotLight } from "babylonjs/Lights/spotLight";
  59885. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59886. import { Scene } from "babylonjs/scene";
  59887. import { Animation } from "babylonjs/Animations/animation";
  59888. import "babylonjs/Shaders/standard.fragment";
  59889. /**
  59890. * Standard rendering pipeline
  59891. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59892. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59893. */
  59894. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59895. /**
  59896. * Public members
  59897. */
  59898. /**
  59899. * Post-process which contains the original scene color before the pipeline applies all the effects
  59900. */
  59901. originalPostProcess: Nullable<PostProcess>;
  59902. /**
  59903. * Post-process used to down scale an image x4
  59904. */
  59905. downSampleX4PostProcess: Nullable<PostProcess>;
  59906. /**
  59907. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59908. */
  59909. brightPassPostProcess: Nullable<PostProcess>;
  59910. /**
  59911. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59912. */
  59913. blurHPostProcesses: PostProcess[];
  59914. /**
  59915. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59916. */
  59917. blurVPostProcesses: PostProcess[];
  59918. /**
  59919. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59920. */
  59921. textureAdderPostProcess: Nullable<PostProcess>;
  59922. /**
  59923. * Post-process used to create volumetric lighting effect
  59924. */
  59925. volumetricLightPostProcess: Nullable<PostProcess>;
  59926. /**
  59927. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59928. */
  59929. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59930. /**
  59931. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59932. */
  59933. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59934. /**
  59935. * Post-process used to merge the volumetric light effect and the real scene color
  59936. */
  59937. volumetricLightMergePostProces: Nullable<PostProcess>;
  59938. /**
  59939. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59940. */
  59941. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59942. /**
  59943. * Base post-process used to calculate the average luminance of the final image for HDR
  59944. */
  59945. luminancePostProcess: Nullable<PostProcess>;
  59946. /**
  59947. * Post-processes used to create down sample post-processes in order to get
  59948. * the average luminance of the final image for HDR
  59949. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59950. */
  59951. luminanceDownSamplePostProcesses: PostProcess[];
  59952. /**
  59953. * Post-process used to create a HDR effect (light adaptation)
  59954. */
  59955. hdrPostProcess: Nullable<PostProcess>;
  59956. /**
  59957. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59958. */
  59959. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59960. /**
  59961. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59962. */
  59963. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59964. /**
  59965. * Post-process used to merge the final HDR post-process and the real scene color
  59966. */
  59967. hdrFinalPostProcess: Nullable<PostProcess>;
  59968. /**
  59969. * Post-process used to create a lens flare effect
  59970. */
  59971. lensFlarePostProcess: Nullable<PostProcess>;
  59972. /**
  59973. * Post-process that merges the result of the lens flare post-process and the real scene color
  59974. */
  59975. lensFlareComposePostProcess: Nullable<PostProcess>;
  59976. /**
  59977. * Post-process used to create a motion blur effect
  59978. */
  59979. motionBlurPostProcess: Nullable<PostProcess>;
  59980. /**
  59981. * Post-process used to create a depth of field effect
  59982. */
  59983. depthOfFieldPostProcess: Nullable<PostProcess>;
  59984. /**
  59985. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59986. */
  59987. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59988. /**
  59989. * Represents the brightness threshold in order to configure the illuminated surfaces
  59990. */
  59991. brightThreshold: number;
  59992. /**
  59993. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59994. */
  59995. blurWidth: number;
  59996. /**
  59997. * Sets if the blur for highlighted surfaces must be only horizontal
  59998. */
  59999. horizontalBlur: boolean;
  60000. /**
  60001. * Gets the overall exposure used by the pipeline
  60002. */
  60003. /**
  60004. * Sets the overall exposure used by the pipeline
  60005. */
  60006. exposure: number;
  60007. /**
  60008. * Texture used typically to simulate "dirty" on camera lens
  60009. */
  60010. lensTexture: Nullable<Texture>;
  60011. /**
  60012. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60013. */
  60014. volumetricLightCoefficient: number;
  60015. /**
  60016. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60017. */
  60018. volumetricLightPower: number;
  60019. /**
  60020. * Used the set the blur intensity to smooth the volumetric lights
  60021. */
  60022. volumetricLightBlurScale: number;
  60023. /**
  60024. * Light (spot or directional) used to generate the volumetric lights rays
  60025. * The source light must have a shadow generate so the pipeline can get its
  60026. * depth map
  60027. */
  60028. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60029. /**
  60030. * For eye adaptation, represents the minimum luminance the eye can see
  60031. */
  60032. hdrMinimumLuminance: number;
  60033. /**
  60034. * For eye adaptation, represents the decrease luminance speed
  60035. */
  60036. hdrDecreaseRate: number;
  60037. /**
  60038. * For eye adaptation, represents the increase luminance speed
  60039. */
  60040. hdrIncreaseRate: number;
  60041. /**
  60042. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60043. */
  60044. /**
  60045. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60046. */
  60047. hdrAutoExposure: boolean;
  60048. /**
  60049. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60050. */
  60051. lensColorTexture: Nullable<Texture>;
  60052. /**
  60053. * The overall strengh for the lens flare effect
  60054. */
  60055. lensFlareStrength: number;
  60056. /**
  60057. * Dispersion coefficient for lens flare ghosts
  60058. */
  60059. lensFlareGhostDispersal: number;
  60060. /**
  60061. * Main lens flare halo width
  60062. */
  60063. lensFlareHaloWidth: number;
  60064. /**
  60065. * Based on the lens distortion effect, defines how much the lens flare result
  60066. * is distorted
  60067. */
  60068. lensFlareDistortionStrength: number;
  60069. /**
  60070. * Lens star texture must be used to simulate rays on the flares and is available
  60071. * in the documentation
  60072. */
  60073. lensStarTexture: Nullable<Texture>;
  60074. /**
  60075. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60076. * flare effect by taking account of the dirt texture
  60077. */
  60078. lensFlareDirtTexture: Nullable<Texture>;
  60079. /**
  60080. * Represents the focal length for the depth of field effect
  60081. */
  60082. depthOfFieldDistance: number;
  60083. /**
  60084. * Represents the blur intensity for the blurred part of the depth of field effect
  60085. */
  60086. depthOfFieldBlurWidth: number;
  60087. /**
  60088. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60089. */
  60090. /**
  60091. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60092. */
  60093. motionStrength: number;
  60094. /**
  60095. * Gets wether or not the motion blur post-process is object based or screen based.
  60096. */
  60097. /**
  60098. * Sets wether or not the motion blur post-process should be object based or screen based
  60099. */
  60100. objectBasedMotionBlur: boolean;
  60101. /**
  60102. * List of animations for the pipeline (IAnimatable implementation)
  60103. */
  60104. animations: Animation[];
  60105. /**
  60106. * Private members
  60107. */
  60108. private _scene;
  60109. private _currentDepthOfFieldSource;
  60110. private _basePostProcess;
  60111. private _fixedExposure;
  60112. private _currentExposure;
  60113. private _hdrAutoExposure;
  60114. private _hdrCurrentLuminance;
  60115. private _motionStrength;
  60116. private _isObjectBasedMotionBlur;
  60117. private _floatTextureType;
  60118. private _ratio;
  60119. private _bloomEnabled;
  60120. private _depthOfFieldEnabled;
  60121. private _vlsEnabled;
  60122. private _lensFlareEnabled;
  60123. private _hdrEnabled;
  60124. private _motionBlurEnabled;
  60125. private _fxaaEnabled;
  60126. private _motionBlurSamples;
  60127. private _volumetricLightStepsCount;
  60128. private _samples;
  60129. /**
  60130. * @ignore
  60131. * Specifies if the bloom pipeline is enabled
  60132. */
  60133. BloomEnabled: boolean;
  60134. /**
  60135. * @ignore
  60136. * Specifies if the depth of field pipeline is enabed
  60137. */
  60138. DepthOfFieldEnabled: boolean;
  60139. /**
  60140. * @ignore
  60141. * Specifies if the lens flare pipeline is enabed
  60142. */
  60143. LensFlareEnabled: boolean;
  60144. /**
  60145. * @ignore
  60146. * Specifies if the HDR pipeline is enabled
  60147. */
  60148. HDREnabled: boolean;
  60149. /**
  60150. * @ignore
  60151. * Specifies if the volumetric lights scattering effect is enabled
  60152. */
  60153. VLSEnabled: boolean;
  60154. /**
  60155. * @ignore
  60156. * Specifies if the motion blur effect is enabled
  60157. */
  60158. MotionBlurEnabled: boolean;
  60159. /**
  60160. * Specifies if anti-aliasing is enabled
  60161. */
  60162. fxaaEnabled: boolean;
  60163. /**
  60164. * Specifies the number of steps used to calculate the volumetric lights
  60165. * Typically in interval [50, 200]
  60166. */
  60167. volumetricLightStepsCount: number;
  60168. /**
  60169. * Specifies the number of samples used for the motion blur effect
  60170. * Typically in interval [16, 64]
  60171. */
  60172. motionBlurSamples: number;
  60173. /**
  60174. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60175. */
  60176. samples: number;
  60177. /**
  60178. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60179. * @constructor
  60180. * @param name The rendering pipeline name
  60181. * @param scene The scene linked to this pipeline
  60182. * @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)
  60183. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60184. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60185. */
  60186. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60187. private _buildPipeline;
  60188. private _createDownSampleX4PostProcess;
  60189. private _createBrightPassPostProcess;
  60190. private _createBlurPostProcesses;
  60191. private _createTextureAdderPostProcess;
  60192. private _createVolumetricLightPostProcess;
  60193. private _createLuminancePostProcesses;
  60194. private _createHdrPostProcess;
  60195. private _createLensFlarePostProcess;
  60196. private _createDepthOfFieldPostProcess;
  60197. private _createMotionBlurPostProcess;
  60198. private _getDepthTexture;
  60199. private _disposePostProcesses;
  60200. /**
  60201. * Dispose of the pipeline and stop all post processes
  60202. */
  60203. dispose(): void;
  60204. /**
  60205. * Serialize the rendering pipeline (Used when exporting)
  60206. * @returns the serialized object
  60207. */
  60208. serialize(): any;
  60209. /**
  60210. * Parse the serialized pipeline
  60211. * @param source Source pipeline.
  60212. * @param scene The scene to load the pipeline to.
  60213. * @param rootUrl The URL of the serialized pipeline.
  60214. * @returns An instantiated pipeline from the serialized object.
  60215. */
  60216. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60217. /**
  60218. * Luminance steps
  60219. */
  60220. static LuminanceSteps: number;
  60221. }
  60222. }
  60223. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60224. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60225. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60226. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60227. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60228. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60229. }
  60230. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60231. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60232. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60233. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60234. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60235. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60236. }
  60237. declare module "babylonjs/Shaders/tonemap.fragment" {
  60238. /** @hidden */
  60239. export var tonemapPixelShader: {
  60240. name: string;
  60241. shader: string;
  60242. };
  60243. }
  60244. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60245. import { Camera } from "babylonjs/Cameras/camera";
  60246. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60247. import "babylonjs/Shaders/tonemap.fragment";
  60248. import { Engine } from "babylonjs/Engines/engine";
  60249. /** Defines operator used for tonemapping */
  60250. export enum TonemappingOperator {
  60251. /** Hable */
  60252. Hable = 0,
  60253. /** Reinhard */
  60254. Reinhard = 1,
  60255. /** HejiDawson */
  60256. HejiDawson = 2,
  60257. /** Photographic */
  60258. Photographic = 3
  60259. }
  60260. /**
  60261. * Defines a post process to apply tone mapping
  60262. */
  60263. export class TonemapPostProcess extends PostProcess {
  60264. private _operator;
  60265. /** Defines the required exposure adjustement */
  60266. exposureAdjustment: number;
  60267. /**
  60268. * Creates a new TonemapPostProcess
  60269. * @param name defines the name of the postprocess
  60270. * @param _operator defines the operator to use
  60271. * @param exposureAdjustment defines the required exposure adjustement
  60272. * @param camera defines the camera to use (can be null)
  60273. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60274. * @param engine defines the hosting engine (can be ignore if camera is set)
  60275. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60276. */
  60277. constructor(name: string, _operator: TonemappingOperator,
  60278. /** Defines the required exposure adjustement */
  60279. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60280. }
  60281. }
  60282. declare module "babylonjs/Shaders/depth.vertex" {
  60283. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60284. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60286. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60287. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60288. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60289. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60290. /** @hidden */
  60291. export var depthVertexShader: {
  60292. name: string;
  60293. shader: string;
  60294. };
  60295. }
  60296. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60297. /** @hidden */
  60298. export var volumetricLightScatteringPixelShader: {
  60299. name: string;
  60300. shader: string;
  60301. };
  60302. }
  60303. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60304. /** @hidden */
  60305. export var volumetricLightScatteringPassPixelShader: {
  60306. name: string;
  60307. shader: string;
  60308. };
  60309. }
  60310. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60311. import { Vector3 } from "babylonjs/Maths/math";
  60312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60313. import { Mesh } from "babylonjs/Meshes/mesh";
  60314. import { Camera } from "babylonjs/Cameras/camera";
  60315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60316. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60317. import { Scene } from "babylonjs/scene";
  60318. import "babylonjs/Meshes/Builders/planeBuilder";
  60319. import "babylonjs/Shaders/depth.vertex";
  60320. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60321. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60322. import { Engine } from "babylonjs/Engines/engine";
  60323. /**
  60324. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60325. */
  60326. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60327. private _volumetricLightScatteringPass;
  60328. private _volumetricLightScatteringRTT;
  60329. private _viewPort;
  60330. private _screenCoordinates;
  60331. private _cachedDefines;
  60332. /**
  60333. * If not undefined, the mesh position is computed from the attached node position
  60334. */
  60335. attachedNode: {
  60336. position: Vector3;
  60337. };
  60338. /**
  60339. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60340. */
  60341. customMeshPosition: Vector3;
  60342. /**
  60343. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60344. */
  60345. useCustomMeshPosition: boolean;
  60346. /**
  60347. * If the post-process should inverse the light scattering direction
  60348. */
  60349. invert: boolean;
  60350. /**
  60351. * The internal mesh used by the post-process
  60352. */
  60353. mesh: Mesh;
  60354. /**
  60355. * @hidden
  60356. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60357. */
  60358. useDiffuseColor: boolean;
  60359. /**
  60360. * Array containing the excluded meshes not rendered in the internal pass
  60361. */
  60362. excludedMeshes: AbstractMesh[];
  60363. /**
  60364. * Controls the overall intensity of the post-process
  60365. */
  60366. exposure: number;
  60367. /**
  60368. * Dissipates each sample's contribution in range [0, 1]
  60369. */
  60370. decay: number;
  60371. /**
  60372. * Controls the overall intensity of each sample
  60373. */
  60374. weight: number;
  60375. /**
  60376. * Controls the density of each sample
  60377. */
  60378. density: number;
  60379. /**
  60380. * @constructor
  60381. * @param name The post-process name
  60382. * @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)
  60383. * @param camera The camera that the post-process will be attached to
  60384. * @param mesh The mesh used to create the light scattering
  60385. * @param samples The post-process quality, default 100
  60386. * @param samplingModeThe post-process filtering mode
  60387. * @param engine The babylon engine
  60388. * @param reusable If the post-process is reusable
  60389. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60390. */
  60391. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60392. /**
  60393. * Returns the string "VolumetricLightScatteringPostProcess"
  60394. * @returns "VolumetricLightScatteringPostProcess"
  60395. */
  60396. getClassName(): string;
  60397. private _isReady;
  60398. /**
  60399. * Sets the new light position for light scattering effect
  60400. * @param position The new custom light position
  60401. */
  60402. setCustomMeshPosition(position: Vector3): void;
  60403. /**
  60404. * Returns the light position for light scattering effect
  60405. * @return Vector3 The custom light position
  60406. */
  60407. getCustomMeshPosition(): Vector3;
  60408. /**
  60409. * Disposes the internal assets and detaches the post-process from the camera
  60410. */
  60411. dispose(camera: Camera): void;
  60412. /**
  60413. * Returns the render target texture used by the post-process
  60414. * @return the render target texture used by the post-process
  60415. */
  60416. getPass(): RenderTargetTexture;
  60417. private _meshExcluded;
  60418. private _createPass;
  60419. private _updateMeshScreenCoordinates;
  60420. /**
  60421. * Creates a default mesh for the Volumeric Light Scattering post-process
  60422. * @param name The mesh name
  60423. * @param scene The scene where to create the mesh
  60424. * @return the default mesh
  60425. */
  60426. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60427. }
  60428. }
  60429. declare module "babylonjs/PostProcesses/index" {
  60430. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60431. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60432. export * from "babylonjs/PostProcesses/bloomEffect";
  60433. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60434. export * from "babylonjs/PostProcesses/blurPostProcess";
  60435. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60436. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60437. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60438. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60439. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60440. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60441. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60442. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60443. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60444. export * from "babylonjs/PostProcesses/filterPostProcess";
  60445. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60446. export * from "babylonjs/PostProcesses/grainPostProcess";
  60447. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60448. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60449. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60450. export * from "babylonjs/PostProcesses/passPostProcess";
  60451. export * from "babylonjs/PostProcesses/postProcess";
  60452. export * from "babylonjs/PostProcesses/postProcessManager";
  60453. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60454. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60455. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60456. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60457. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60458. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60459. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60460. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60461. }
  60462. declare module "babylonjs/Probes/index" {
  60463. export * from "babylonjs/Probes/reflectionProbe";
  60464. }
  60465. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60466. import { Scene } from "babylonjs/scene";
  60467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60468. import { Color3 } from "babylonjs/Maths/math";
  60469. import { SmartArray } from "babylonjs/Misc/smartArray";
  60470. import { ISceneComponent } from "babylonjs/sceneComponent";
  60471. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60472. import "babylonjs/Meshes/Builders/boxBuilder";
  60473. import "babylonjs/Shaders/color.fragment";
  60474. import "babylonjs/Shaders/color.vertex";
  60475. module "babylonjs/scene" {
  60476. interface Scene {
  60477. /** @hidden (Backing field) */
  60478. _boundingBoxRenderer: BoundingBoxRenderer;
  60479. /** @hidden (Backing field) */
  60480. _forceShowBoundingBoxes: boolean;
  60481. /**
  60482. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60483. */
  60484. forceShowBoundingBoxes: boolean;
  60485. /**
  60486. * Gets the bounding box renderer associated with the scene
  60487. * @returns a BoundingBoxRenderer
  60488. */
  60489. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60490. }
  60491. }
  60492. module "babylonjs/Meshes/abstractMesh" {
  60493. interface AbstractMesh {
  60494. /** @hidden (Backing field) */
  60495. _showBoundingBox: boolean;
  60496. /**
  60497. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60498. */
  60499. showBoundingBox: boolean;
  60500. }
  60501. }
  60502. /**
  60503. * Component responsible of rendering the bounding box of the meshes in a scene.
  60504. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60505. */
  60506. export class BoundingBoxRenderer implements ISceneComponent {
  60507. /**
  60508. * The component name helpfull to identify the component in the list of scene components.
  60509. */
  60510. readonly name: string;
  60511. /**
  60512. * The scene the component belongs to.
  60513. */
  60514. scene: Scene;
  60515. /**
  60516. * Color of the bounding box lines placed in front of an object
  60517. */
  60518. frontColor: Color3;
  60519. /**
  60520. * Color of the bounding box lines placed behind an object
  60521. */
  60522. backColor: Color3;
  60523. /**
  60524. * Defines if the renderer should show the back lines or not
  60525. */
  60526. showBackLines: boolean;
  60527. /**
  60528. * @hidden
  60529. */
  60530. renderList: SmartArray<BoundingBox>;
  60531. private _colorShader;
  60532. private _vertexBuffers;
  60533. private _indexBuffer;
  60534. private _fillIndexBuffer;
  60535. private _fillIndexData;
  60536. /**
  60537. * Instantiates a new bounding box renderer in a scene.
  60538. * @param scene the scene the renderer renders in
  60539. */
  60540. constructor(scene: Scene);
  60541. /**
  60542. * Registers the component in a given scene
  60543. */
  60544. register(): void;
  60545. private _evaluateSubMesh;
  60546. private _activeMesh;
  60547. private _prepareRessources;
  60548. private _createIndexBuffer;
  60549. /**
  60550. * Rebuilds the elements related to this component in case of
  60551. * context lost for instance.
  60552. */
  60553. rebuild(): void;
  60554. /**
  60555. * @hidden
  60556. */
  60557. reset(): void;
  60558. /**
  60559. * Render the bounding boxes of a specific rendering group
  60560. * @param renderingGroupId defines the rendering group to render
  60561. */
  60562. render(renderingGroupId: number): void;
  60563. /**
  60564. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60565. * @param mesh Define the mesh to render the occlusion bounding box for
  60566. */
  60567. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60568. /**
  60569. * Dispose and release the resources attached to this renderer.
  60570. */
  60571. dispose(): void;
  60572. }
  60573. }
  60574. declare module "babylonjs/Shaders/depth.fragment" {
  60575. /** @hidden */
  60576. export var depthPixelShader: {
  60577. name: string;
  60578. shader: string;
  60579. };
  60580. }
  60581. declare module "babylonjs/Rendering/depthRenderer" {
  60582. import { Nullable } from "babylonjs/types";
  60583. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60584. import { Scene } from "babylonjs/scene";
  60585. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60586. import { Camera } from "babylonjs/Cameras/camera";
  60587. import "babylonjs/Shaders/depth.fragment";
  60588. import "babylonjs/Shaders/depth.vertex";
  60589. /**
  60590. * This represents a depth renderer in Babylon.
  60591. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60592. */
  60593. export class DepthRenderer {
  60594. private _scene;
  60595. private _depthMap;
  60596. private _effect;
  60597. private _cachedDefines;
  60598. private _camera;
  60599. /**
  60600. * Specifiess that the depth renderer will only be used within
  60601. * the camera it is created for.
  60602. * This can help forcing its rendering during the camera processing.
  60603. */
  60604. useOnlyInActiveCamera: boolean;
  60605. /** @hidden */
  60606. static _SceneComponentInitialization: (scene: Scene) => void;
  60607. /**
  60608. * Instantiates a depth renderer
  60609. * @param scene The scene the renderer belongs to
  60610. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60611. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60612. */
  60613. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60614. /**
  60615. * Creates the depth rendering effect and checks if the effect is ready.
  60616. * @param subMesh The submesh to be used to render the depth map of
  60617. * @param useInstances If multiple world instances should be used
  60618. * @returns if the depth renderer is ready to render the depth map
  60619. */
  60620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60621. /**
  60622. * Gets the texture which the depth map will be written to.
  60623. * @returns The depth map texture
  60624. */
  60625. getDepthMap(): RenderTargetTexture;
  60626. /**
  60627. * Disposes of the depth renderer.
  60628. */
  60629. dispose(): void;
  60630. }
  60631. }
  60632. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60633. import { Nullable } from "babylonjs/types";
  60634. import { Scene } from "babylonjs/scene";
  60635. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60636. import { Camera } from "babylonjs/Cameras/camera";
  60637. import { ISceneComponent } from "babylonjs/sceneComponent";
  60638. module "babylonjs/scene" {
  60639. interface Scene {
  60640. /** @hidden (Backing field) */
  60641. _depthRenderer: {
  60642. [id: string]: DepthRenderer;
  60643. };
  60644. /**
  60645. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60646. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60647. * @returns the created depth renderer
  60648. */
  60649. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60650. /**
  60651. * Disables a depth renderer for a given camera
  60652. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60653. */
  60654. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60655. }
  60656. }
  60657. /**
  60658. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60659. * in several rendering techniques.
  60660. */
  60661. export class DepthRendererSceneComponent implements ISceneComponent {
  60662. /**
  60663. * The component name helpfull to identify the component in the list of scene components.
  60664. */
  60665. readonly name: string;
  60666. /**
  60667. * The scene the component belongs to.
  60668. */
  60669. scene: Scene;
  60670. /**
  60671. * Creates a new instance of the component for the given scene
  60672. * @param scene Defines the scene to register the component in
  60673. */
  60674. constructor(scene: Scene);
  60675. /**
  60676. * Registers the component in a given scene
  60677. */
  60678. register(): void;
  60679. /**
  60680. * Rebuilds the elements related to this component in case of
  60681. * context lost for instance.
  60682. */
  60683. rebuild(): void;
  60684. /**
  60685. * Disposes the component and the associated ressources
  60686. */
  60687. dispose(): void;
  60688. private _gatherRenderTargets;
  60689. private _gatherActiveCameraRenderTargets;
  60690. }
  60691. }
  60692. declare module "babylonjs/Shaders/outline.fragment" {
  60693. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60694. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60695. /** @hidden */
  60696. export var outlinePixelShader: {
  60697. name: string;
  60698. shader: string;
  60699. };
  60700. }
  60701. declare module "babylonjs/Shaders/outline.vertex" {
  60702. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60703. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60704. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60705. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60706. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60707. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60708. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60709. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60710. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60711. /** @hidden */
  60712. export var outlineVertexShader: {
  60713. name: string;
  60714. shader: string;
  60715. };
  60716. }
  60717. declare module "babylonjs/Rendering/outlineRenderer" {
  60718. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60719. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60720. import { Scene } from "babylonjs/scene";
  60721. import { ISceneComponent } from "babylonjs/sceneComponent";
  60722. import "babylonjs/Shaders/outline.fragment";
  60723. import "babylonjs/Shaders/outline.vertex";
  60724. module "babylonjs/scene" {
  60725. interface Scene {
  60726. /** @hidden */
  60727. _outlineRenderer: OutlineRenderer;
  60728. /**
  60729. * Gets the outline renderer associated with the scene
  60730. * @returns a OutlineRenderer
  60731. */
  60732. getOutlineRenderer(): OutlineRenderer;
  60733. }
  60734. }
  60735. module "babylonjs/Meshes/abstractMesh" {
  60736. interface AbstractMesh {
  60737. /** @hidden (Backing field) */
  60738. _renderOutline: boolean;
  60739. /**
  60740. * Gets or sets a boolean indicating if the outline must be rendered as well
  60741. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60742. */
  60743. renderOutline: boolean;
  60744. /** @hidden (Backing field) */
  60745. _renderOverlay: boolean;
  60746. /**
  60747. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60748. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60749. */
  60750. renderOverlay: boolean;
  60751. }
  60752. }
  60753. /**
  60754. * This class is responsible to draw bothe outline/overlay of meshes.
  60755. * It should not be used directly but through the available method on mesh.
  60756. */
  60757. export class OutlineRenderer implements ISceneComponent {
  60758. /**
  60759. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60760. */
  60761. private static _StencilReference;
  60762. /**
  60763. * The name of the component. Each component must have a unique name.
  60764. */
  60765. name: string;
  60766. /**
  60767. * The scene the component belongs to.
  60768. */
  60769. scene: Scene;
  60770. /**
  60771. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60772. */
  60773. zOffset: number;
  60774. private _engine;
  60775. private _effect;
  60776. private _cachedDefines;
  60777. private _savedDepthWrite;
  60778. /**
  60779. * Instantiates a new outline renderer. (There could be only one per scene).
  60780. * @param scene Defines the scene it belongs to
  60781. */
  60782. constructor(scene: Scene);
  60783. /**
  60784. * Register the component to one instance of a scene.
  60785. */
  60786. register(): void;
  60787. /**
  60788. * Rebuilds the elements related to this component in case of
  60789. * context lost for instance.
  60790. */
  60791. rebuild(): void;
  60792. /**
  60793. * Disposes the component and the associated ressources.
  60794. */
  60795. dispose(): void;
  60796. /**
  60797. * Renders the outline in the canvas.
  60798. * @param subMesh Defines the sumesh to render
  60799. * @param batch Defines the batch of meshes in case of instances
  60800. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60801. */
  60802. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60803. /**
  60804. * Returns whether or not the outline renderer is ready for a given submesh.
  60805. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60806. * @param subMesh Defines the submesh to check readyness for
  60807. * @param useInstances Defines wheter wee are trying to render instances or not
  60808. * @returns true if ready otherwise false
  60809. */
  60810. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60811. private _beforeRenderingMesh;
  60812. private _afterRenderingMesh;
  60813. }
  60814. }
  60815. declare module "babylonjs/Rendering/index" {
  60816. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60817. export * from "babylonjs/Rendering/depthRenderer";
  60818. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60819. export * from "babylonjs/Rendering/edgesRenderer";
  60820. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60821. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60822. export * from "babylonjs/Rendering/outlineRenderer";
  60823. export * from "babylonjs/Rendering/renderingGroup";
  60824. export * from "babylonjs/Rendering/renderingManager";
  60825. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60826. }
  60827. declare module "babylonjs/Sprites/index" {
  60828. export * from "babylonjs/Sprites/sprite";
  60829. export * from "babylonjs/Sprites/spriteManager";
  60830. export * from "babylonjs/Sprites/spriteSceneComponent";
  60831. }
  60832. declare module "babylonjs/Misc/assetsManager" {
  60833. import { Scene } from "babylonjs/scene";
  60834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60835. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60836. import { Skeleton } from "babylonjs/Bones/skeleton";
  60837. import { Observable } from "babylonjs/Misc/observable";
  60838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60839. import { Texture } from "babylonjs/Materials/Textures/texture";
  60840. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60841. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60842. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60843. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60844. /**
  60845. * Defines the list of states available for a task inside a AssetsManager
  60846. */
  60847. export enum AssetTaskState {
  60848. /**
  60849. * Initialization
  60850. */
  60851. INIT = 0,
  60852. /**
  60853. * Running
  60854. */
  60855. RUNNING = 1,
  60856. /**
  60857. * Done
  60858. */
  60859. DONE = 2,
  60860. /**
  60861. * Error
  60862. */
  60863. ERROR = 3
  60864. }
  60865. /**
  60866. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60867. */
  60868. export abstract class AbstractAssetTask {
  60869. /**
  60870. * Task name
  60871. */ name: string;
  60872. /**
  60873. * Callback called when the task is successful
  60874. */
  60875. onSuccess: (task: any) => void;
  60876. /**
  60877. * Callback called when the task is not successful
  60878. */
  60879. onError: (task: any, message?: string, exception?: any) => void;
  60880. /**
  60881. * Creates a new AssetsManager
  60882. * @param name defines the name of the task
  60883. */
  60884. constructor(
  60885. /**
  60886. * Task name
  60887. */ name: string);
  60888. private _isCompleted;
  60889. private _taskState;
  60890. private _errorObject;
  60891. /**
  60892. * Get if the task is completed
  60893. */
  60894. readonly isCompleted: boolean;
  60895. /**
  60896. * Gets the current state of the task
  60897. */
  60898. readonly taskState: AssetTaskState;
  60899. /**
  60900. * Gets the current error object (if task is in error)
  60901. */
  60902. readonly errorObject: {
  60903. message?: string;
  60904. exception?: any;
  60905. };
  60906. /**
  60907. * Internal only
  60908. * @hidden
  60909. */
  60910. _setErrorObject(message?: string, exception?: any): void;
  60911. /**
  60912. * Execute the current task
  60913. * @param scene defines the scene where you want your assets to be loaded
  60914. * @param onSuccess is a callback called when the task is successfully executed
  60915. * @param onError is a callback called if an error occurs
  60916. */
  60917. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60918. /**
  60919. * Execute the current task
  60920. * @param scene defines the scene where you want your assets to be loaded
  60921. * @param onSuccess is a callback called when the task is successfully executed
  60922. * @param onError is a callback called if an error occurs
  60923. */
  60924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60925. /**
  60926. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60927. * This can be used with failed tasks that have the reason for failure fixed.
  60928. */
  60929. reset(): void;
  60930. private onErrorCallback;
  60931. private onDoneCallback;
  60932. }
  60933. /**
  60934. * Define the interface used by progress events raised during assets loading
  60935. */
  60936. export interface IAssetsProgressEvent {
  60937. /**
  60938. * Defines the number of remaining tasks to process
  60939. */
  60940. remainingCount: number;
  60941. /**
  60942. * Defines the total number of tasks
  60943. */
  60944. totalCount: number;
  60945. /**
  60946. * Defines the task that was just processed
  60947. */
  60948. task: AbstractAssetTask;
  60949. }
  60950. /**
  60951. * Class used to share progress information about assets loading
  60952. */
  60953. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60954. /**
  60955. * Defines the number of remaining tasks to process
  60956. */
  60957. remainingCount: number;
  60958. /**
  60959. * Defines the total number of tasks
  60960. */
  60961. totalCount: number;
  60962. /**
  60963. * Defines the task that was just processed
  60964. */
  60965. task: AbstractAssetTask;
  60966. /**
  60967. * Creates a AssetsProgressEvent
  60968. * @param remainingCount defines the number of remaining tasks to process
  60969. * @param totalCount defines the total number of tasks
  60970. * @param task defines the task that was just processed
  60971. */
  60972. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60973. }
  60974. /**
  60975. * Define a task used by AssetsManager to load meshes
  60976. */
  60977. export class MeshAssetTask extends AbstractAssetTask {
  60978. /**
  60979. * Defines the name of the task
  60980. */
  60981. name: string;
  60982. /**
  60983. * Defines the list of mesh's names you want to load
  60984. */
  60985. meshesNames: any;
  60986. /**
  60987. * Defines the root url to use as a base to load your meshes and associated resources
  60988. */
  60989. rootUrl: string;
  60990. /**
  60991. * Defines the filename of the scene to load from
  60992. */
  60993. sceneFilename: string;
  60994. /**
  60995. * Gets the list of loaded meshes
  60996. */
  60997. loadedMeshes: Array<AbstractMesh>;
  60998. /**
  60999. * Gets the list of loaded particle systems
  61000. */
  61001. loadedParticleSystems: Array<IParticleSystem>;
  61002. /**
  61003. * Gets the list of loaded skeletons
  61004. */
  61005. loadedSkeletons: Array<Skeleton>;
  61006. /**
  61007. * Gets the list of loaded animation groups
  61008. */
  61009. loadedAnimationGroups: Array<AnimationGroup>;
  61010. /**
  61011. * Callback called when the task is successful
  61012. */
  61013. onSuccess: (task: MeshAssetTask) => void;
  61014. /**
  61015. * Callback called when the task is successful
  61016. */
  61017. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61018. /**
  61019. * Creates a new MeshAssetTask
  61020. * @param name defines the name of the task
  61021. * @param meshesNames defines the list of mesh's names you want to load
  61022. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61023. * @param sceneFilename defines the filename of the scene to load from
  61024. */
  61025. constructor(
  61026. /**
  61027. * Defines the name of the task
  61028. */
  61029. name: string,
  61030. /**
  61031. * Defines the list of mesh's names you want to load
  61032. */
  61033. meshesNames: any,
  61034. /**
  61035. * Defines the root url to use as a base to load your meshes and associated resources
  61036. */
  61037. rootUrl: string,
  61038. /**
  61039. * Defines the filename of the scene to load from
  61040. */
  61041. sceneFilename: string);
  61042. /**
  61043. * Execute the current task
  61044. * @param scene defines the scene where you want your assets to be loaded
  61045. * @param onSuccess is a callback called when the task is successfully executed
  61046. * @param onError is a callback called if an error occurs
  61047. */
  61048. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61049. }
  61050. /**
  61051. * Define a task used by AssetsManager to load text content
  61052. */
  61053. export class TextFileAssetTask extends AbstractAssetTask {
  61054. /**
  61055. * Defines the name of the task
  61056. */
  61057. name: string;
  61058. /**
  61059. * Defines the location of the file to load
  61060. */
  61061. url: string;
  61062. /**
  61063. * Gets the loaded text string
  61064. */
  61065. text: string;
  61066. /**
  61067. * Callback called when the task is successful
  61068. */
  61069. onSuccess: (task: TextFileAssetTask) => void;
  61070. /**
  61071. * Callback called when the task is successful
  61072. */
  61073. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61074. /**
  61075. * Creates a new TextFileAssetTask object
  61076. * @param name defines the name of the task
  61077. * @param url defines the location of the file to load
  61078. */
  61079. constructor(
  61080. /**
  61081. * Defines the name of the task
  61082. */
  61083. name: string,
  61084. /**
  61085. * Defines the location of the file to load
  61086. */
  61087. url: string);
  61088. /**
  61089. * Execute the current task
  61090. * @param scene defines the scene where you want your assets to be loaded
  61091. * @param onSuccess is a callback called when the task is successfully executed
  61092. * @param onError is a callback called if an error occurs
  61093. */
  61094. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61095. }
  61096. /**
  61097. * Define a task used by AssetsManager to load binary data
  61098. */
  61099. export class BinaryFileAssetTask extends AbstractAssetTask {
  61100. /**
  61101. * Defines the name of the task
  61102. */
  61103. name: string;
  61104. /**
  61105. * Defines the location of the file to load
  61106. */
  61107. url: string;
  61108. /**
  61109. * Gets the lodaded data (as an array buffer)
  61110. */
  61111. data: ArrayBuffer;
  61112. /**
  61113. * Callback called when the task is successful
  61114. */
  61115. onSuccess: (task: BinaryFileAssetTask) => void;
  61116. /**
  61117. * Callback called when the task is successful
  61118. */
  61119. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61120. /**
  61121. * Creates a new BinaryFileAssetTask object
  61122. * @param name defines the name of the new task
  61123. * @param url defines the location of the file to load
  61124. */
  61125. constructor(
  61126. /**
  61127. * Defines the name of the task
  61128. */
  61129. name: string,
  61130. /**
  61131. * Defines the location of the file to load
  61132. */
  61133. url: string);
  61134. /**
  61135. * Execute the current task
  61136. * @param scene defines the scene where you want your assets to be loaded
  61137. * @param onSuccess is a callback called when the task is successfully executed
  61138. * @param onError is a callback called if an error occurs
  61139. */
  61140. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61141. }
  61142. /**
  61143. * Define a task used by AssetsManager to load images
  61144. */
  61145. export class ImageAssetTask extends AbstractAssetTask {
  61146. /**
  61147. * Defines the name of the task
  61148. */
  61149. name: string;
  61150. /**
  61151. * Defines the location of the image to load
  61152. */
  61153. url: string;
  61154. /**
  61155. * Gets the loaded images
  61156. */
  61157. image: HTMLImageElement;
  61158. /**
  61159. * Callback called when the task is successful
  61160. */
  61161. onSuccess: (task: ImageAssetTask) => void;
  61162. /**
  61163. * Callback called when the task is successful
  61164. */
  61165. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61166. /**
  61167. * Creates a new ImageAssetTask
  61168. * @param name defines the name of the task
  61169. * @param url defines the location of the image to load
  61170. */
  61171. constructor(
  61172. /**
  61173. * Defines the name of the task
  61174. */
  61175. name: string,
  61176. /**
  61177. * Defines the location of the image to load
  61178. */
  61179. url: string);
  61180. /**
  61181. * Execute the current task
  61182. * @param scene defines the scene where you want your assets to be loaded
  61183. * @param onSuccess is a callback called when the task is successfully executed
  61184. * @param onError is a callback called if an error occurs
  61185. */
  61186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61187. }
  61188. /**
  61189. * Defines the interface used by texture loading tasks
  61190. */
  61191. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61192. /**
  61193. * Gets the loaded texture
  61194. */
  61195. texture: TEX;
  61196. }
  61197. /**
  61198. * Define a task used by AssetsManager to load 2D textures
  61199. */
  61200. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61201. /**
  61202. * Defines the name of the task
  61203. */
  61204. name: string;
  61205. /**
  61206. * Defines the location of the file to load
  61207. */
  61208. url: string;
  61209. /**
  61210. * Defines if mipmap should not be generated (default is false)
  61211. */
  61212. noMipmap?: boolean | undefined;
  61213. /**
  61214. * Defines if texture must be inverted on Y axis (default is false)
  61215. */
  61216. invertY?: boolean | undefined;
  61217. /**
  61218. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61219. */
  61220. samplingMode: number;
  61221. /**
  61222. * Gets the loaded texture
  61223. */
  61224. texture: Texture;
  61225. /**
  61226. * Callback called when the task is successful
  61227. */
  61228. onSuccess: (task: TextureAssetTask) => void;
  61229. /**
  61230. * Callback called when the task is successful
  61231. */
  61232. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61233. /**
  61234. * Creates a new TextureAssetTask object
  61235. * @param name defines the name of the task
  61236. * @param url defines the location of the file to load
  61237. * @param noMipmap defines if mipmap should not be generated (default is false)
  61238. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61239. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61240. */
  61241. constructor(
  61242. /**
  61243. * Defines the name of the task
  61244. */
  61245. name: string,
  61246. /**
  61247. * Defines the location of the file to load
  61248. */
  61249. url: string,
  61250. /**
  61251. * Defines if mipmap should not be generated (default is false)
  61252. */
  61253. noMipmap?: boolean | undefined,
  61254. /**
  61255. * Defines if texture must be inverted on Y axis (default is false)
  61256. */
  61257. invertY?: boolean | undefined,
  61258. /**
  61259. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61260. */
  61261. samplingMode?: number);
  61262. /**
  61263. * Execute the current task
  61264. * @param scene defines the scene where you want your assets to be loaded
  61265. * @param onSuccess is a callback called when the task is successfully executed
  61266. * @param onError is a callback called if an error occurs
  61267. */
  61268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61269. }
  61270. /**
  61271. * Define a task used by AssetsManager to load cube textures
  61272. */
  61273. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61274. /**
  61275. * Defines the name of the task
  61276. */
  61277. name: string;
  61278. /**
  61279. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61280. */
  61281. url: string;
  61282. /**
  61283. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61284. */
  61285. extensions?: string[] | undefined;
  61286. /**
  61287. * Defines if mipmaps should not be generated (default is false)
  61288. */
  61289. noMipmap?: boolean | undefined;
  61290. /**
  61291. * Defines the explicit list of files (undefined by default)
  61292. */
  61293. files?: string[] | undefined;
  61294. /**
  61295. * Gets the loaded texture
  61296. */
  61297. texture: CubeTexture;
  61298. /**
  61299. * Callback called when the task is successful
  61300. */
  61301. onSuccess: (task: CubeTextureAssetTask) => void;
  61302. /**
  61303. * Callback called when the task is successful
  61304. */
  61305. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61306. /**
  61307. * Creates a new CubeTextureAssetTask
  61308. * @param name defines the name of the task
  61309. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61310. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61311. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61312. * @param files defines the explicit list of files (undefined by default)
  61313. */
  61314. constructor(
  61315. /**
  61316. * Defines the name of the task
  61317. */
  61318. name: string,
  61319. /**
  61320. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61321. */
  61322. url: string,
  61323. /**
  61324. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61325. */
  61326. extensions?: string[] | undefined,
  61327. /**
  61328. * Defines if mipmaps should not be generated (default is false)
  61329. */
  61330. noMipmap?: boolean | undefined,
  61331. /**
  61332. * Defines the explicit list of files (undefined by default)
  61333. */
  61334. files?: string[] | undefined);
  61335. /**
  61336. * Execute the current task
  61337. * @param scene defines the scene where you want your assets to be loaded
  61338. * @param onSuccess is a callback called when the task is successfully executed
  61339. * @param onError is a callback called if an error occurs
  61340. */
  61341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61342. }
  61343. /**
  61344. * Define a task used by AssetsManager to load HDR cube textures
  61345. */
  61346. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61347. /**
  61348. * Defines the name of the task
  61349. */
  61350. name: string;
  61351. /**
  61352. * Defines the location of the file to load
  61353. */
  61354. url: string;
  61355. /**
  61356. * Defines the desired size (the more it increases the longer the generation will be)
  61357. */
  61358. size: number;
  61359. /**
  61360. * Defines if mipmaps should not be generated (default is false)
  61361. */
  61362. noMipmap: boolean;
  61363. /**
  61364. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61365. */
  61366. generateHarmonics: boolean;
  61367. /**
  61368. * 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)
  61369. */
  61370. gammaSpace: boolean;
  61371. /**
  61372. * Internal Use Only
  61373. */
  61374. reserved: boolean;
  61375. /**
  61376. * Gets the loaded texture
  61377. */
  61378. texture: HDRCubeTexture;
  61379. /**
  61380. * Callback called when the task is successful
  61381. */
  61382. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61383. /**
  61384. * Callback called when the task is successful
  61385. */
  61386. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61387. /**
  61388. * Creates a new HDRCubeTextureAssetTask object
  61389. * @param name defines the name of the task
  61390. * @param url defines the location of the file to load
  61391. * @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.
  61392. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61393. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61394. * @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)
  61395. * @param reserved Internal use only
  61396. */
  61397. constructor(
  61398. /**
  61399. * Defines the name of the task
  61400. */
  61401. name: string,
  61402. /**
  61403. * Defines the location of the file to load
  61404. */
  61405. url: string,
  61406. /**
  61407. * Defines the desired size (the more it increases the longer the generation will be)
  61408. */
  61409. size: number,
  61410. /**
  61411. * Defines if mipmaps should not be generated (default is false)
  61412. */
  61413. noMipmap?: boolean,
  61414. /**
  61415. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61416. */
  61417. generateHarmonics?: boolean,
  61418. /**
  61419. * 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)
  61420. */
  61421. gammaSpace?: boolean,
  61422. /**
  61423. * Internal Use Only
  61424. */
  61425. reserved?: boolean);
  61426. /**
  61427. * Execute the current task
  61428. * @param scene defines the scene where you want your assets to be loaded
  61429. * @param onSuccess is a callback called when the task is successfully executed
  61430. * @param onError is a callback called if an error occurs
  61431. */
  61432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61433. }
  61434. /**
  61435. * Define a task used by AssetsManager to load Equirectangular cube textures
  61436. */
  61437. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61438. /**
  61439. * Defines the name of the task
  61440. */
  61441. name: string;
  61442. /**
  61443. * Defines the location of the file to load
  61444. */
  61445. url: string;
  61446. /**
  61447. * Defines the desired size (the more it increases the longer the generation will be)
  61448. */
  61449. size: number;
  61450. /**
  61451. * Defines if mipmaps should not be generated (default is false)
  61452. */
  61453. noMipmap: boolean;
  61454. /**
  61455. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61456. * but the standard material would require them in Gamma space) (default is true)
  61457. */
  61458. gammaSpace: boolean;
  61459. /**
  61460. * Gets the loaded texture
  61461. */
  61462. texture: EquiRectangularCubeTexture;
  61463. /**
  61464. * Callback called when the task is successful
  61465. */
  61466. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61467. /**
  61468. * Callback called when the task is successful
  61469. */
  61470. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61471. /**
  61472. * Creates a new EquiRectangularCubeTextureAssetTask object
  61473. * @param name defines the name of the task
  61474. * @param url defines the location of the file to load
  61475. * @param size defines the desired size (the more it increases the longer the generation will be)
  61476. * If the size is omitted this implies you are using a preprocessed cubemap.
  61477. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61478. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61479. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61480. * (default is true)
  61481. */
  61482. constructor(
  61483. /**
  61484. * Defines the name of the task
  61485. */
  61486. name: string,
  61487. /**
  61488. * Defines the location of the file to load
  61489. */
  61490. url: string,
  61491. /**
  61492. * Defines the desired size (the more it increases the longer the generation will be)
  61493. */
  61494. size: number,
  61495. /**
  61496. * Defines if mipmaps should not be generated (default is false)
  61497. */
  61498. noMipmap?: boolean,
  61499. /**
  61500. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61501. * but the standard material would require them in Gamma space) (default is true)
  61502. */
  61503. gammaSpace?: boolean);
  61504. /**
  61505. * Execute the current task
  61506. * @param scene defines the scene where you want your assets to be loaded
  61507. * @param onSuccess is a callback called when the task is successfully executed
  61508. * @param onError is a callback called if an error occurs
  61509. */
  61510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61511. }
  61512. /**
  61513. * This class can be used to easily import assets into a scene
  61514. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61515. */
  61516. export class AssetsManager {
  61517. private _scene;
  61518. private _isLoading;
  61519. protected _tasks: AbstractAssetTask[];
  61520. protected _waitingTasksCount: number;
  61521. protected _totalTasksCount: number;
  61522. /**
  61523. * Callback called when all tasks are processed
  61524. */
  61525. onFinish: (tasks: AbstractAssetTask[]) => void;
  61526. /**
  61527. * Callback called when a task is successful
  61528. */
  61529. onTaskSuccess: (task: AbstractAssetTask) => void;
  61530. /**
  61531. * Callback called when a task had an error
  61532. */
  61533. onTaskError: (task: AbstractAssetTask) => void;
  61534. /**
  61535. * Callback called when a task is done (whatever the result is)
  61536. */
  61537. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61538. /**
  61539. * Observable called when all tasks are processed
  61540. */
  61541. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61542. /**
  61543. * Observable called when a task had an error
  61544. */
  61545. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61546. /**
  61547. * Observable called when all tasks were executed
  61548. */
  61549. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61550. /**
  61551. * Observable called when a task is done (whatever the result is)
  61552. */
  61553. onProgressObservable: Observable<IAssetsProgressEvent>;
  61554. /**
  61555. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61556. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61557. */
  61558. useDefaultLoadingScreen: boolean;
  61559. /**
  61560. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61561. * when all assets have been downloaded.
  61562. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61563. */
  61564. autoHideLoadingUI: boolean;
  61565. /**
  61566. * Creates a new AssetsManager
  61567. * @param scene defines the scene to work on
  61568. */
  61569. constructor(scene: Scene);
  61570. /**
  61571. * Add a MeshAssetTask to the list of active tasks
  61572. * @param taskName defines the name of the new task
  61573. * @param meshesNames defines the name of meshes to load
  61574. * @param rootUrl defines the root url to use to locate files
  61575. * @param sceneFilename defines the filename of the scene file
  61576. * @returns a new MeshAssetTask object
  61577. */
  61578. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61579. /**
  61580. * Add a TextFileAssetTask to the list of active tasks
  61581. * @param taskName defines the name of the new task
  61582. * @param url defines the url of the file to load
  61583. * @returns a new TextFileAssetTask object
  61584. */
  61585. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61586. /**
  61587. * Add a BinaryFileAssetTask to the list of active tasks
  61588. * @param taskName defines the name of the new task
  61589. * @param url defines the url of the file to load
  61590. * @returns a new BinaryFileAssetTask object
  61591. */
  61592. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61593. /**
  61594. * Add a ImageAssetTask to the list of active tasks
  61595. * @param taskName defines the name of the new task
  61596. * @param url defines the url of the file to load
  61597. * @returns a new ImageAssetTask object
  61598. */
  61599. addImageTask(taskName: string, url: string): ImageAssetTask;
  61600. /**
  61601. * Add a TextureAssetTask to the list of active tasks
  61602. * @param taskName defines the name of the new task
  61603. * @param url defines the url of the file to load
  61604. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61605. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61606. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61607. * @returns a new TextureAssetTask object
  61608. */
  61609. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61610. /**
  61611. * Add a CubeTextureAssetTask 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. * @param extensions defines the extension to use to load the cube map (can be null)
  61615. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61616. * @param files defines the list of files to load (can be null)
  61617. * @returns a new CubeTextureAssetTask object
  61618. */
  61619. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61620. /**
  61621. *
  61622. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61623. * @param taskName defines the name of the new task
  61624. * @param url defines the url of the file to load
  61625. * @param size defines the size you want for the cubemap (can be null)
  61626. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61627. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61628. * @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)
  61629. * @param reserved Internal use only
  61630. * @returns a new HDRCubeTextureAssetTask object
  61631. */
  61632. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61633. /**
  61634. *
  61635. * Add a EquiRectangularCubeTextureAssetTask 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 size defines the size you want for the cubemap (can be null)
  61639. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61640. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61641. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61642. * @returns a new EquiRectangularCubeTextureAssetTask object
  61643. */
  61644. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61645. /**
  61646. * Remove a task from the assets manager.
  61647. * @param task the task to remove
  61648. */
  61649. removeTask(task: AbstractAssetTask): void;
  61650. private _decreaseWaitingTasksCount;
  61651. private _runTask;
  61652. /**
  61653. * Reset the AssetsManager and remove all tasks
  61654. * @return the current instance of the AssetsManager
  61655. */
  61656. reset(): AssetsManager;
  61657. /**
  61658. * Start the loading process
  61659. * @return the current instance of the AssetsManager
  61660. */
  61661. load(): AssetsManager;
  61662. /**
  61663. * Start the loading process as an async operation
  61664. * @return a promise returning the list of failed tasks
  61665. */
  61666. loadAsync(): Promise<void>;
  61667. }
  61668. }
  61669. declare module "babylonjs/Misc/deferred" {
  61670. /**
  61671. * Wrapper class for promise with external resolve and reject.
  61672. */
  61673. export class Deferred<T> {
  61674. /**
  61675. * The promise associated with this deferred object.
  61676. */
  61677. readonly promise: Promise<T>;
  61678. private _resolve;
  61679. private _reject;
  61680. /**
  61681. * The resolve method of the promise associated with this deferred object.
  61682. */
  61683. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61684. /**
  61685. * The reject method of the promise associated with this deferred object.
  61686. */
  61687. readonly reject: (reason?: any) => void;
  61688. /**
  61689. * Constructor for this deferred object.
  61690. */
  61691. constructor();
  61692. }
  61693. }
  61694. declare module "babylonjs/Misc/meshExploder" {
  61695. import { Mesh } from "babylonjs/Meshes/mesh";
  61696. /**
  61697. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61698. */
  61699. export class MeshExploder {
  61700. private _centerMesh;
  61701. private _meshes;
  61702. private _meshesOrigins;
  61703. private _toCenterVectors;
  61704. private _scaledDirection;
  61705. private _newPosition;
  61706. private _centerPosition;
  61707. /**
  61708. * Explodes meshes from a center mesh.
  61709. * @param meshes The meshes to explode.
  61710. * @param centerMesh The mesh to be center of explosion.
  61711. */
  61712. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61713. private _setCenterMesh;
  61714. /**
  61715. * Get class name
  61716. * @returns "MeshExploder"
  61717. */
  61718. getClassName(): string;
  61719. /**
  61720. * "Exploded meshes"
  61721. * @returns Array of meshes with the centerMesh at index 0.
  61722. */
  61723. getMeshes(): Array<Mesh>;
  61724. /**
  61725. * Explodes meshes giving a specific direction
  61726. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61727. */
  61728. explode(direction?: number): void;
  61729. }
  61730. }
  61731. declare module "babylonjs/Misc/filesInput" {
  61732. import { Engine } from "babylonjs/Engines/engine";
  61733. import { Scene } from "babylonjs/scene";
  61734. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61735. /**
  61736. * Class used to help managing file picking and drag'n'drop
  61737. */
  61738. export class FilesInput {
  61739. /**
  61740. * List of files ready to be loaded
  61741. */
  61742. static readonly FilesToLoad: {
  61743. [key: string]: File;
  61744. };
  61745. /**
  61746. * Callback called when a file is processed
  61747. */
  61748. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61749. private _engine;
  61750. private _currentScene;
  61751. private _sceneLoadedCallback;
  61752. private _progressCallback;
  61753. private _additionalRenderLoopLogicCallback;
  61754. private _textureLoadingCallback;
  61755. private _startingProcessingFilesCallback;
  61756. private _onReloadCallback;
  61757. private _errorCallback;
  61758. private _elementToMonitor;
  61759. private _sceneFileToLoad;
  61760. private _filesToLoad;
  61761. /**
  61762. * Creates a new FilesInput
  61763. * @param engine defines the rendering engine
  61764. * @param scene defines the hosting scene
  61765. * @param sceneLoadedCallback callback called when scene is loaded
  61766. * @param progressCallback callback called to track progress
  61767. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61768. * @param textureLoadingCallback callback called when a texture is loading
  61769. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61770. * @param onReloadCallback callback called when a reload is requested
  61771. * @param errorCallback callback call if an error occurs
  61772. */
  61773. 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);
  61774. private _dragEnterHandler;
  61775. private _dragOverHandler;
  61776. private _dropHandler;
  61777. /**
  61778. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61779. * @param elementToMonitor defines the DOM element to track
  61780. */
  61781. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61782. /**
  61783. * Release all associated resources
  61784. */
  61785. dispose(): void;
  61786. private renderFunction;
  61787. private drag;
  61788. private drop;
  61789. private _traverseFolder;
  61790. private _processFiles;
  61791. /**
  61792. * Load files from a drop event
  61793. * @param event defines the drop event to use as source
  61794. */
  61795. loadFiles(event: any): void;
  61796. private _processReload;
  61797. /**
  61798. * Reload the current scene from the loaded files
  61799. */
  61800. reload(): void;
  61801. }
  61802. }
  61803. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61804. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61805. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61806. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61807. }
  61808. declare module "babylonjs/Misc/sceneOptimizer" {
  61809. import { Scene, IDisposable } from "babylonjs/scene";
  61810. import { Observable } from "babylonjs/Misc/observable";
  61811. /**
  61812. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61814. */
  61815. export class SceneOptimization {
  61816. /**
  61817. * Defines the priority of this optimization (0 by default which means first in the list)
  61818. */
  61819. priority: number;
  61820. /**
  61821. * Gets a string describing the action executed by the current optimization
  61822. * @returns description string
  61823. */
  61824. getDescription(): string;
  61825. /**
  61826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61827. * @param scene defines the current scene where to apply this optimization
  61828. * @param optimizer defines the current optimizer
  61829. * @returns true if everything that can be done was applied
  61830. */
  61831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61832. /**
  61833. * Creates the SceneOptimization object
  61834. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61835. * @param desc defines the description associated with the optimization
  61836. */
  61837. constructor(
  61838. /**
  61839. * Defines the priority of this optimization (0 by default which means first in the list)
  61840. */
  61841. priority?: number);
  61842. }
  61843. /**
  61844. * Defines an optimization used to reduce the size of render target textures
  61845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61846. */
  61847. export class TextureOptimization extends SceneOptimization {
  61848. /**
  61849. * Defines the priority of this optimization (0 by default which means first in the list)
  61850. */
  61851. priority: number;
  61852. /**
  61853. * 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
  61854. */
  61855. maximumSize: number;
  61856. /**
  61857. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61858. */
  61859. step: number;
  61860. /**
  61861. * Gets a string describing the action executed by the current optimization
  61862. * @returns description string
  61863. */
  61864. getDescription(): string;
  61865. /**
  61866. * Creates the TextureOptimization object
  61867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61868. * @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
  61869. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61870. */
  61871. constructor(
  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. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61886. * @param scene defines the current scene where to apply this optimization
  61887. * @param optimizer defines the current optimizer
  61888. * @returns true if everything that can be done was applied
  61889. */
  61890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61891. }
  61892. /**
  61893. * Defines an optimization used to increase or decrease the rendering resolution
  61894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61895. */
  61896. export class HardwareScalingOptimization extends SceneOptimization {
  61897. /**
  61898. * Defines the priority of this optimization (0 by default which means first in the list)
  61899. */
  61900. priority: number;
  61901. /**
  61902. * Defines the maximum scale to use (2 by default)
  61903. */
  61904. maximumScale: number;
  61905. /**
  61906. * Defines the step to use between two passes (0.5 by default)
  61907. */
  61908. step: number;
  61909. private _currentScale;
  61910. private _directionOffset;
  61911. /**
  61912. * Gets a string describing the action executed by the current optimization
  61913. * @return description string
  61914. */
  61915. getDescription(): string;
  61916. /**
  61917. * Creates the HardwareScalingOptimization object
  61918. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61919. * @param maximumScale defines the maximum scale to use (2 by default)
  61920. * @param step defines the step to use between two passes (0.5 by default)
  61921. */
  61922. constructor(
  61923. /**
  61924. * Defines the priority of this optimization (0 by default which means first in the list)
  61925. */
  61926. priority?: number,
  61927. /**
  61928. * Defines the maximum scale to use (2 by default)
  61929. */
  61930. maximumScale?: number,
  61931. /**
  61932. * Defines the step to use between two passes (0.5 by default)
  61933. */
  61934. step?: number);
  61935. /**
  61936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61937. * @param scene defines the current scene where to apply this optimization
  61938. * @param optimizer defines the current optimizer
  61939. * @returns true if everything that can be done was applied
  61940. */
  61941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61942. }
  61943. /**
  61944. * Defines an optimization used to remove shadows
  61945. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61946. */
  61947. export class ShadowsOptimization extends SceneOptimization {
  61948. /**
  61949. * Gets a string describing the action executed by the current optimization
  61950. * @return description string
  61951. */
  61952. getDescription(): string;
  61953. /**
  61954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61955. * @param scene defines the current scene where to apply this optimization
  61956. * @param optimizer defines the current optimizer
  61957. * @returns true if everything that can be done was applied
  61958. */
  61959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61960. }
  61961. /**
  61962. * Defines an optimization used to turn post-processes off
  61963. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61964. */
  61965. export class PostProcessesOptimization extends SceneOptimization {
  61966. /**
  61967. * Gets a string describing the action executed by the current optimization
  61968. * @return description string
  61969. */
  61970. getDescription(): string;
  61971. /**
  61972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61973. * @param scene defines the current scene where to apply this optimization
  61974. * @param optimizer defines the current optimizer
  61975. * @returns true if everything that can be done was applied
  61976. */
  61977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61978. }
  61979. /**
  61980. * Defines an optimization used to turn lens flares off
  61981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61982. */
  61983. export class LensFlaresOptimization extends SceneOptimization {
  61984. /**
  61985. * Gets a string describing the action executed by the current optimization
  61986. * @return description string
  61987. */
  61988. getDescription(): string;
  61989. /**
  61990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61991. * @param scene defines the current scene where to apply this optimization
  61992. * @param optimizer defines the current optimizer
  61993. * @returns true if everything that can be done was applied
  61994. */
  61995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61996. }
  61997. /**
  61998. * Defines an optimization based on user defined callback.
  61999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62000. */
  62001. export class CustomOptimization extends SceneOptimization {
  62002. /**
  62003. * Callback called to apply the custom optimization.
  62004. */
  62005. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62006. /**
  62007. * Callback called to get custom description
  62008. */
  62009. onGetDescription: () => string;
  62010. /**
  62011. * Gets a string describing the action executed by the current optimization
  62012. * @returns description string
  62013. */
  62014. getDescription(): string;
  62015. /**
  62016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62017. * @param scene defines the current scene where to apply this optimization
  62018. * @param optimizer defines the current optimizer
  62019. * @returns true if everything that can be done was applied
  62020. */
  62021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62022. }
  62023. /**
  62024. * Defines an optimization used to turn particles off
  62025. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62026. */
  62027. export class ParticlesOptimization extends SceneOptimization {
  62028. /**
  62029. * Gets a string describing the action executed by the current optimization
  62030. * @return description string
  62031. */
  62032. getDescription(): string;
  62033. /**
  62034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62035. * @param scene defines the current scene where to apply this optimization
  62036. * @param optimizer defines the current optimizer
  62037. * @returns true if everything that can be done was applied
  62038. */
  62039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62040. }
  62041. /**
  62042. * Defines an optimization used to turn render targets off
  62043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62044. */
  62045. export class RenderTargetsOptimization extends SceneOptimization {
  62046. /**
  62047. * Gets a string describing the action executed by the current optimization
  62048. * @return description string
  62049. */
  62050. getDescription(): string;
  62051. /**
  62052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62053. * @param scene defines the current scene where to apply this optimization
  62054. * @param optimizer defines the current optimizer
  62055. * @returns true if everything that can be done was applied
  62056. */
  62057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62058. }
  62059. /**
  62060. * Defines an optimization used to merge meshes with compatible materials
  62061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62062. */
  62063. export class MergeMeshesOptimization extends SceneOptimization {
  62064. private static _UpdateSelectionTree;
  62065. /**
  62066. * Gets or sets a boolean which defines if optimization octree has to be updated
  62067. */
  62068. /**
  62069. * Gets or sets a boolean which defines if optimization octree has to be updated
  62070. */
  62071. static UpdateSelectionTree: boolean;
  62072. /**
  62073. * Gets a string describing the action executed by the current optimization
  62074. * @return description string
  62075. */
  62076. getDescription(): string;
  62077. private _canBeMerged;
  62078. /**
  62079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62080. * @param scene defines the current scene where to apply this optimization
  62081. * @param optimizer defines the current optimizer
  62082. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62083. * @returns true if everything that can be done was applied
  62084. */
  62085. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62086. }
  62087. /**
  62088. * Defines a list of options used by SceneOptimizer
  62089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62090. */
  62091. export class SceneOptimizerOptions {
  62092. /**
  62093. * Defines the target frame rate to reach (60 by default)
  62094. */
  62095. targetFrameRate: number;
  62096. /**
  62097. * Defines the interval between two checkes (2000ms by default)
  62098. */
  62099. trackerDuration: number;
  62100. /**
  62101. * Gets the list of optimizations to apply
  62102. */
  62103. optimizations: SceneOptimization[];
  62104. /**
  62105. * Creates a new list of options used by SceneOptimizer
  62106. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62107. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62108. */
  62109. constructor(
  62110. /**
  62111. * Defines the target frame rate to reach (60 by default)
  62112. */
  62113. targetFrameRate?: number,
  62114. /**
  62115. * Defines the interval between two checkes (2000ms by default)
  62116. */
  62117. trackerDuration?: number);
  62118. /**
  62119. * Add a new optimization
  62120. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62121. * @returns the current SceneOptimizerOptions
  62122. */
  62123. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62124. /**
  62125. * Add a new custom optimization
  62126. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62127. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62129. * @returns the current SceneOptimizerOptions
  62130. */
  62131. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62132. /**
  62133. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62134. * @param targetFrameRate defines the target frame rate (60 by default)
  62135. * @returns a SceneOptimizerOptions object
  62136. */
  62137. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62138. /**
  62139. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62140. * @param targetFrameRate defines the target frame rate (60 by default)
  62141. * @returns a SceneOptimizerOptions object
  62142. */
  62143. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62144. /**
  62145. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62146. * @param targetFrameRate defines the target frame rate (60 by default)
  62147. * @returns a SceneOptimizerOptions object
  62148. */
  62149. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62150. }
  62151. /**
  62152. * Class used to run optimizations in order to reach a target frame rate
  62153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62154. */
  62155. export class SceneOptimizer implements IDisposable {
  62156. private _isRunning;
  62157. private _options;
  62158. private _scene;
  62159. private _currentPriorityLevel;
  62160. private _targetFrameRate;
  62161. private _trackerDuration;
  62162. private _currentFrameRate;
  62163. private _sceneDisposeObserver;
  62164. private _improvementMode;
  62165. /**
  62166. * Defines an observable called when the optimizer reaches the target frame rate
  62167. */
  62168. onSuccessObservable: Observable<SceneOptimizer>;
  62169. /**
  62170. * Defines an observable called when the optimizer enables an optimization
  62171. */
  62172. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62173. /**
  62174. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62175. */
  62176. onFailureObservable: Observable<SceneOptimizer>;
  62177. /**
  62178. * Gets a boolean indicating if the optimizer is in improvement mode
  62179. */
  62180. readonly isInImprovementMode: boolean;
  62181. /**
  62182. * Gets the current priority level (0 at start)
  62183. */
  62184. readonly currentPriorityLevel: number;
  62185. /**
  62186. * Gets the current frame rate checked by the SceneOptimizer
  62187. */
  62188. readonly currentFrameRate: number;
  62189. /**
  62190. * Gets or sets the current target frame rate (60 by default)
  62191. */
  62192. /**
  62193. * Gets or sets the current target frame rate (60 by default)
  62194. */
  62195. targetFrameRate: number;
  62196. /**
  62197. * Gets or sets the current interval between two checks (every 2000ms by default)
  62198. */
  62199. /**
  62200. * Gets or sets the current interval between two checks (every 2000ms by default)
  62201. */
  62202. trackerDuration: number;
  62203. /**
  62204. * Gets the list of active optimizations
  62205. */
  62206. readonly optimizations: SceneOptimization[];
  62207. /**
  62208. * Creates a new SceneOptimizer
  62209. * @param scene defines the scene to work on
  62210. * @param options defines the options to use with the SceneOptimizer
  62211. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62212. * @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)
  62213. */
  62214. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62215. /**
  62216. * Stops the current optimizer
  62217. */
  62218. stop(): void;
  62219. /**
  62220. * Reset the optimizer to initial step (current priority level = 0)
  62221. */
  62222. reset(): void;
  62223. /**
  62224. * Start the optimizer. By default it will try to reach a specific framerate
  62225. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62226. */
  62227. start(): void;
  62228. private _checkCurrentState;
  62229. /**
  62230. * Release all resources
  62231. */
  62232. dispose(): void;
  62233. /**
  62234. * Helper function to create a SceneOptimizer with one single line of code
  62235. * @param scene defines the scene to work on
  62236. * @param options defines the options to use with the SceneOptimizer
  62237. * @param onSuccess defines a callback to call on success
  62238. * @param onFailure defines a callback to call on failure
  62239. * @returns the new SceneOptimizer object
  62240. */
  62241. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62242. }
  62243. }
  62244. declare module "babylonjs/Misc/sceneSerializer" {
  62245. import { Scene } from "babylonjs/scene";
  62246. /**
  62247. * Class used to serialize a scene into a string
  62248. */
  62249. export class SceneSerializer {
  62250. /**
  62251. * Clear cache used by a previous serialization
  62252. */
  62253. static ClearCache(): void;
  62254. /**
  62255. * Serialize a scene into a JSON compatible object
  62256. * @param scene defines the scene to serialize
  62257. * @returns a JSON compatible object
  62258. */
  62259. static Serialize(scene: Scene): any;
  62260. /**
  62261. * Serialize a mesh into a JSON compatible object
  62262. * @param toSerialize defines the mesh to serialize
  62263. * @param withParents defines if parents must be serialized as well
  62264. * @param withChildren defines if children must be serialized as well
  62265. * @returns a JSON compatible object
  62266. */
  62267. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62268. }
  62269. }
  62270. declare module "babylonjs/Misc/textureTools" {
  62271. import { Texture } from "babylonjs/Materials/Textures/texture";
  62272. /**
  62273. * Class used to host texture specific utilities
  62274. */
  62275. export class TextureTools {
  62276. /**
  62277. * Uses the GPU to create a copy texture rescaled at a given size
  62278. * @param texture Texture to copy from
  62279. * @param width defines the desired width
  62280. * @param height defines the desired height
  62281. * @param useBilinearMode defines if bilinear mode has to be used
  62282. * @return the generated texture
  62283. */
  62284. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62285. }
  62286. }
  62287. declare module "babylonjs/Misc/videoRecorder" {
  62288. import { Nullable } from "babylonjs/types";
  62289. import { Engine } from "babylonjs/Engines/engine";
  62290. /**
  62291. * This represents the different options available for the video capture.
  62292. */
  62293. export interface VideoRecorderOptions {
  62294. /** Defines the mime type of the video. */
  62295. mimeType: string;
  62296. /** Defines the FPS the video should be recorded at. */
  62297. fps: number;
  62298. /** Defines the chunk size for the recording data. */
  62299. recordChunckSize: number;
  62300. /** The audio tracks to attach to the recording. */
  62301. audioTracks?: MediaStreamTrack[];
  62302. }
  62303. /**
  62304. * This can help with recording videos from BabylonJS.
  62305. * This is based on the available WebRTC functionalities of the browser.
  62306. *
  62307. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62308. */
  62309. export class VideoRecorder {
  62310. private static readonly _defaultOptions;
  62311. /**
  62312. * Returns whether or not the VideoRecorder is available in your browser.
  62313. * @param engine Defines the Babylon Engine.
  62314. * @returns true if supported otherwise false.
  62315. */
  62316. static IsSupported(engine: Engine): boolean;
  62317. private readonly _options;
  62318. private _canvas;
  62319. private _mediaRecorder;
  62320. private _recordedChunks;
  62321. private _fileName;
  62322. private _resolve;
  62323. private _reject;
  62324. /**
  62325. * True when a recording is already in progress.
  62326. */
  62327. readonly isRecording: boolean;
  62328. /**
  62329. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62330. * @param engine Defines the BabylonJS Engine you wish to record.
  62331. * @param options Defines options that can be used to customize the capture.
  62332. */
  62333. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62334. /**
  62335. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62336. */
  62337. stopRecording(): void;
  62338. /**
  62339. * Starts recording the canvas for a max duration specified in parameters.
  62340. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62341. * If null no automatic download will start and you can rely on the promise to get the data back.
  62342. * @param maxDuration Defines the maximum recording time in seconds.
  62343. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62344. * @return A promise callback at the end of the recording with the video data in Blob.
  62345. */
  62346. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62347. /**
  62348. * Releases internal resources used during the recording.
  62349. */
  62350. dispose(): void;
  62351. private _handleDataAvailable;
  62352. private _handleError;
  62353. private _handleStop;
  62354. }
  62355. }
  62356. declare module "babylonjs/Misc/screenshotTools" {
  62357. import { Camera } from "babylonjs/Cameras/camera";
  62358. import { Engine } from "babylonjs/Engines/engine";
  62359. /**
  62360. * Class containing a set of static utilities functions for screenshots
  62361. */
  62362. export class ScreenshotTools {
  62363. /**
  62364. * Captures a screenshot of the current rendering
  62365. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62366. * @param engine defines the rendering engine
  62367. * @param camera defines the source camera
  62368. * @param size This parameter can be set to a single number or to an object with the
  62369. * following (optional) properties: precision, width, height. If a single number is passed,
  62370. * it will be used for both width and height. If an object is passed, the screenshot size
  62371. * will be derived from the parameters. The precision property is a multiplier allowing
  62372. * rendering at a higher or lower resolution
  62373. * @param successCallback defines the callback receives a single parameter which contains the
  62374. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62375. * src parameter of an <img> to display it
  62376. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62377. * Check your browser for supported MIME types
  62378. */
  62379. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62380. /**
  62381. * Generates an image screenshot from the specified camera.
  62382. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62383. * @param engine The engine to use for rendering
  62384. * @param camera The camera to use for rendering
  62385. * @param size This parameter can be set to a single number or to an object with the
  62386. * following (optional) properties: precision, width, height. If a single number is passed,
  62387. * it will be used for both width and height. If an object is passed, the screenshot size
  62388. * will be derived from the parameters. The precision property is a multiplier allowing
  62389. * rendering at a higher or lower resolution
  62390. * @param successCallback The callback receives a single parameter which contains the
  62391. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62392. * src parameter of an <img> to display it
  62393. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62394. * Check your browser for supported MIME types
  62395. * @param samples Texture samples (default: 1)
  62396. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62397. * @param fileName A name for for the downloaded file.
  62398. */
  62399. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62400. }
  62401. }
  62402. declare module "babylonjs/Misc/index" {
  62403. export * from "babylonjs/Misc/andOrNotEvaluator";
  62404. export * from "babylonjs/Misc/assetsManager";
  62405. export * from "babylonjs/Misc/dds";
  62406. export * from "babylonjs/Misc/decorators";
  62407. export * from "babylonjs/Misc/deferred";
  62408. export * from "babylonjs/Misc/environmentTextureTools";
  62409. export * from "babylonjs/Misc/meshExploder";
  62410. export * from "babylonjs/Misc/filesInput";
  62411. export * from "babylonjs/Misc/HighDynamicRange/index";
  62412. export * from "babylonjs/Misc/khronosTextureContainer";
  62413. export * from "babylonjs/Misc/observable";
  62414. export * from "babylonjs/Misc/performanceMonitor";
  62415. export * from "babylonjs/Misc/promise";
  62416. export * from "babylonjs/Misc/sceneOptimizer";
  62417. export * from "babylonjs/Misc/sceneSerializer";
  62418. export * from "babylonjs/Misc/smartArray";
  62419. export * from "babylonjs/Misc/stringDictionary";
  62420. export * from "babylonjs/Misc/tags";
  62421. export * from "babylonjs/Misc/textureTools";
  62422. export * from "babylonjs/Misc/tga";
  62423. export * from "babylonjs/Misc/tools";
  62424. export * from "babylonjs/Misc/videoRecorder";
  62425. export * from "babylonjs/Misc/virtualJoystick";
  62426. export * from "babylonjs/Misc/workerPool";
  62427. export * from "babylonjs/Misc/logger";
  62428. export * from "babylonjs/Misc/typeStore";
  62429. export * from "babylonjs/Misc/filesInputStore";
  62430. export * from "babylonjs/Misc/deepCopier";
  62431. export * from "babylonjs/Misc/pivotTools";
  62432. export * from "babylonjs/Misc/precisionDate";
  62433. export * from "babylonjs/Misc/screenshotTools";
  62434. export * from "babylonjs/Misc/typeStore";
  62435. export * from "babylonjs/Misc/webRequest";
  62436. export * from "babylonjs/Misc/iInspectable";
  62437. export * from "babylonjs/Misc/brdfTextureTools";
  62438. }
  62439. declare module "babylonjs/index" {
  62440. export * from "babylonjs/abstractScene";
  62441. export * from "babylonjs/Actions/index";
  62442. export * from "babylonjs/Animations/index";
  62443. export * from "babylonjs/assetContainer";
  62444. export * from "babylonjs/Audio/index";
  62445. export * from "babylonjs/Behaviors/index";
  62446. export * from "babylonjs/Bones/index";
  62447. export * from "babylonjs/Cameras/index";
  62448. export * from "babylonjs/Collisions/index";
  62449. export * from "babylonjs/Culling/index";
  62450. export * from "babylonjs/Debug/index";
  62451. export * from "babylonjs/Engines/index";
  62452. export * from "babylonjs/Events/index";
  62453. export * from "babylonjs/Gamepads/index";
  62454. export * from "babylonjs/Gizmos/index";
  62455. export * from "babylonjs/Helpers/index";
  62456. export * from "babylonjs/Instrumentation/index";
  62457. export * from "babylonjs/Layers/index";
  62458. export * from "babylonjs/LensFlares/index";
  62459. export * from "babylonjs/Lights/index";
  62460. export * from "babylonjs/Loading/index";
  62461. export * from "babylonjs/Materials/index";
  62462. export * from "babylonjs/Maths/index";
  62463. export * from "babylonjs/Meshes/index";
  62464. export * from "babylonjs/Morph/index";
  62465. export * from "babylonjs/node";
  62466. export * from "babylonjs/Offline/index";
  62467. export * from "babylonjs/Particles/index";
  62468. export * from "babylonjs/Physics/index";
  62469. export * from "babylonjs/PostProcesses/index";
  62470. export * from "babylonjs/Probes/index";
  62471. export * from "babylonjs/Rendering/index";
  62472. export * from "babylonjs/scene";
  62473. export * from "babylonjs/sceneComponent";
  62474. export * from "babylonjs/Sprites/index";
  62475. export * from "babylonjs/States/index";
  62476. export * from "babylonjs/Misc/index";
  62477. export * from "babylonjs/types";
  62478. }
  62479. declare module "babylonjs/Animations/pathCursor" {
  62480. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62481. /**
  62482. * A cursor which tracks a point on a path
  62483. */
  62484. export class PathCursor {
  62485. private path;
  62486. /**
  62487. * Stores path cursor callbacks for when an onchange event is triggered
  62488. */
  62489. private _onchange;
  62490. /**
  62491. * The value of the path cursor
  62492. */
  62493. value: number;
  62494. /**
  62495. * The animation array of the path cursor
  62496. */
  62497. animations: Animation[];
  62498. /**
  62499. * Initializes the path cursor
  62500. * @param path The path to track
  62501. */
  62502. constructor(path: Path2);
  62503. /**
  62504. * Gets the cursor point on the path
  62505. * @returns A point on the path cursor at the cursor location
  62506. */
  62507. getPoint(): Vector3;
  62508. /**
  62509. * Moves the cursor ahead by the step amount
  62510. * @param step The amount to move the cursor forward
  62511. * @returns This path cursor
  62512. */
  62513. moveAhead(step?: number): PathCursor;
  62514. /**
  62515. * Moves the cursor behind by the step amount
  62516. * @param step The amount to move the cursor back
  62517. * @returns This path cursor
  62518. */
  62519. moveBack(step?: number): PathCursor;
  62520. /**
  62521. * Moves the cursor by the step amount
  62522. * If the step amount is greater than one, an exception is thrown
  62523. * @param step The amount to move the cursor
  62524. * @returns This path cursor
  62525. */
  62526. move(step: number): PathCursor;
  62527. /**
  62528. * Ensures that the value is limited between zero and one
  62529. * @returns This path cursor
  62530. */
  62531. private ensureLimits;
  62532. /**
  62533. * Runs onchange callbacks on change (used by the animation engine)
  62534. * @returns This path cursor
  62535. */
  62536. private raiseOnChange;
  62537. /**
  62538. * Executes a function on change
  62539. * @param f A path cursor onchange callback
  62540. * @returns This path cursor
  62541. */
  62542. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62543. }
  62544. }
  62545. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62546. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62547. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62548. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62549. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62550. }
  62551. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62552. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62553. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62554. }
  62555. declare module "babylonjs/Engines/Processors/index" {
  62556. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62557. export * from "babylonjs/Engines/Processors/Expressions/index";
  62558. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62559. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62560. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62561. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62562. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62563. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62564. }
  62565. declare module "babylonjs/Legacy/legacy" {
  62566. import * as Babylon from "babylonjs/index";
  62567. export * from "babylonjs/index";
  62568. }
  62569. declare module "babylonjs/Shaders/blur.fragment" {
  62570. /** @hidden */
  62571. export var blurPixelShader: {
  62572. name: string;
  62573. shader: string;
  62574. };
  62575. }
  62576. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62577. /** @hidden */
  62578. export var pointCloudVertexDeclaration: {
  62579. name: string;
  62580. shader: string;
  62581. };
  62582. }
  62583. declare module "babylonjs" {
  62584. export * from "babylonjs/Legacy/legacy";
  62585. }
  62586. declare module BABYLON {
  62587. /** Alias type for value that can be null */
  62588. export type Nullable<T> = T | null;
  62589. /**
  62590. * Alias type for number that are floats
  62591. * @ignorenaming
  62592. */
  62593. export type float = number;
  62594. /**
  62595. * Alias type for number that are doubles.
  62596. * @ignorenaming
  62597. */
  62598. export type double = number;
  62599. /**
  62600. * Alias type for number that are integer
  62601. * @ignorenaming
  62602. */
  62603. export type int = number;
  62604. /** Alias type for number array or Float32Array */
  62605. export type FloatArray = number[] | Float32Array;
  62606. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62607. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62608. /**
  62609. * Alias for types that can be used by a Buffer or VertexBuffer.
  62610. */
  62611. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62612. /**
  62613. * Alias type for primitive types
  62614. * @ignorenaming
  62615. */
  62616. type Primitive = undefined | null | boolean | string | number | Function;
  62617. /**
  62618. * Type modifier to make all the properties of an object Readonly
  62619. */
  62620. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62621. /**
  62622. * Type modifier to make all the properties of an object Readonly recursively
  62623. */
  62624. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62625. /** @hidden */
  62626. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62627. }
  62628. /** @hidden */
  62629. /** @hidden */
  62630. type DeepImmutableObject<T> = {
  62631. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62632. };
  62633. }
  62634. declare module BABYLON {
  62635. /**
  62636. * Class containing a set of static utilities functions for arrays.
  62637. */
  62638. export class ArrayTools {
  62639. /**
  62640. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62641. * @param size the number of element to construct and put in the array
  62642. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62643. * @returns a new array filled with new objects
  62644. */
  62645. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62646. }
  62647. }
  62648. declare module BABYLON {
  62649. /**
  62650. * Scalar computation library
  62651. */
  62652. export class Scalar {
  62653. /**
  62654. * Two pi constants convenient for computation.
  62655. */
  62656. static TwoPi: number;
  62657. /**
  62658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62659. * @param a number
  62660. * @param b number
  62661. * @param epsilon (default = 1.401298E-45)
  62662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62663. */
  62664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62665. /**
  62666. * Returns a string : the upper case translation of the number i to hexadecimal.
  62667. * @param i number
  62668. * @returns the upper case translation of the number i to hexadecimal.
  62669. */
  62670. static ToHex(i: number): string;
  62671. /**
  62672. * Returns -1 if value is negative and +1 is value is positive.
  62673. * @param value the value
  62674. * @returns the value itself if it's equal to zero.
  62675. */
  62676. static Sign(value: number): number;
  62677. /**
  62678. * Returns the value itself if it's between min and max.
  62679. * Returns min if the value is lower than min.
  62680. * Returns max if the value is greater than max.
  62681. * @param value the value to clmap
  62682. * @param min the min value to clamp to (default: 0)
  62683. * @param max the max value to clamp to (default: 1)
  62684. * @returns the clamped value
  62685. */
  62686. static Clamp(value: number, min?: number, max?: number): number;
  62687. /**
  62688. * the log2 of value.
  62689. * @param value the value to compute log2 of
  62690. * @returns the log2 of value.
  62691. */
  62692. static Log2(value: number): number;
  62693. /**
  62694. * Loops the value, so that it is never larger than length and never smaller than 0.
  62695. *
  62696. * This is similar to the modulo operator but it works with floating point numbers.
  62697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62698. * With t = 5 and length = 2.5, the result would be 0.0.
  62699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62700. * @param value the value
  62701. * @param length the length
  62702. * @returns the looped value
  62703. */
  62704. static Repeat(value: number, length: number): number;
  62705. /**
  62706. * Normalize the value between 0.0 and 1.0 using min and max values
  62707. * @param value value to normalize
  62708. * @param min max to normalize between
  62709. * @param max min to normalize between
  62710. * @returns the normalized value
  62711. */
  62712. static Normalize(value: number, min: number, max: number): number;
  62713. /**
  62714. * Denormalize the value from 0.0 and 1.0 using min and max values
  62715. * @param normalized value to denormalize
  62716. * @param min max to denormalize between
  62717. * @param max min to denormalize between
  62718. * @returns the denormalized value
  62719. */
  62720. static Denormalize(normalized: number, min: number, max: number): number;
  62721. /**
  62722. * Calculates the shortest difference between two given angles given in degrees.
  62723. * @param current current angle in degrees
  62724. * @param target target angle in degrees
  62725. * @returns the delta
  62726. */
  62727. static DeltaAngle(current: number, target: number): number;
  62728. /**
  62729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62730. * @param tx value
  62731. * @param length length
  62732. * @returns The returned value will move back and forth between 0 and length
  62733. */
  62734. static PingPong(tx: number, length: number): number;
  62735. /**
  62736. * Interpolates between min and max with smoothing at the limits.
  62737. *
  62738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62740. * @param from from
  62741. * @param to to
  62742. * @param tx value
  62743. * @returns the smooth stepped value
  62744. */
  62745. static SmoothStep(from: number, to: number, tx: number): number;
  62746. /**
  62747. * Moves a value current towards target.
  62748. *
  62749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62750. * Negative values of maxDelta pushes the value away from target.
  62751. * @param current current value
  62752. * @param target target value
  62753. * @param maxDelta max distance to move
  62754. * @returns resulting value
  62755. */
  62756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62757. /**
  62758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62759. *
  62760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62762. * @param current current value
  62763. * @param target target value
  62764. * @param maxDelta max distance to move
  62765. * @returns resulting angle
  62766. */
  62767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62768. /**
  62769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62770. * @param start start value
  62771. * @param end target value
  62772. * @param amount amount to lerp between
  62773. * @returns the lerped value
  62774. */
  62775. static Lerp(start: number, end: number, amount: number): number;
  62776. /**
  62777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62779. * @param start start value
  62780. * @param end target value
  62781. * @param amount amount to lerp between
  62782. * @returns the lerped value
  62783. */
  62784. static LerpAngle(start: number, end: number, amount: number): number;
  62785. /**
  62786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62787. * @param a start value
  62788. * @param b target value
  62789. * @param value value between a and b
  62790. * @returns the inverseLerp value
  62791. */
  62792. static InverseLerp(a: number, b: number, value: number): number;
  62793. /**
  62794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62796. * @param value1 spline value
  62797. * @param tangent1 spline value
  62798. * @param value2 spline value
  62799. * @param tangent2 spline value
  62800. * @param amount input value
  62801. * @returns hermite result
  62802. */
  62803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62804. /**
  62805. * Returns a random float number between and min and max values
  62806. * @param min min value of random
  62807. * @param max max value of random
  62808. * @returns random value
  62809. */
  62810. static RandomRange(min: number, max: number): number;
  62811. /**
  62812. * This function returns percentage of a number in a given range.
  62813. *
  62814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62816. * @param number to convert to percentage
  62817. * @param min min range
  62818. * @param max max range
  62819. * @returns the percentage
  62820. */
  62821. static RangeToPercent(number: number, min: number, max: number): number;
  62822. /**
  62823. * This function returns number that corresponds to the percentage in a given range.
  62824. *
  62825. * PercentToRange(0.34,0,100) will return 34.
  62826. * @param percent to convert to number
  62827. * @param min min range
  62828. * @param max max range
  62829. * @returns the number
  62830. */
  62831. static PercentToRange(percent: number, min: number, max: number): number;
  62832. /**
  62833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62834. * @param angle The angle to normalize in radian.
  62835. * @return The converted angle.
  62836. */
  62837. static NormalizeRadians(angle: number): number;
  62838. }
  62839. }
  62840. declare module BABYLON {
  62841. /**
  62842. * Constant used to convert a value to gamma space
  62843. * @ignorenaming
  62844. */
  62845. export const ToGammaSpace: number;
  62846. /**
  62847. * Constant used to convert a value to linear space
  62848. * @ignorenaming
  62849. */
  62850. export const ToLinearSpace = 2.2;
  62851. /**
  62852. * Constant used to define the minimal number value in Babylon.js
  62853. * @ignorenaming
  62854. */
  62855. let Epsilon: number;
  62856. /**
  62857. * Class used to hold a RBG color
  62858. */
  62859. export class Color3 {
  62860. /**
  62861. * Defines the red component (between 0 and 1, default is 0)
  62862. */
  62863. r: number;
  62864. /**
  62865. * Defines the green component (between 0 and 1, default is 0)
  62866. */
  62867. g: number;
  62868. /**
  62869. * Defines the blue component (between 0 and 1, default is 0)
  62870. */
  62871. b: number;
  62872. /**
  62873. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62874. * @param r defines the red component (between 0 and 1, default is 0)
  62875. * @param g defines the green component (between 0 and 1, default is 0)
  62876. * @param b defines the blue component (between 0 and 1, default is 0)
  62877. */
  62878. constructor(
  62879. /**
  62880. * Defines the red component (between 0 and 1, default is 0)
  62881. */
  62882. r?: number,
  62883. /**
  62884. * Defines the green component (between 0 and 1, default is 0)
  62885. */
  62886. g?: number,
  62887. /**
  62888. * Defines the blue component (between 0 and 1, default is 0)
  62889. */
  62890. b?: number);
  62891. /**
  62892. * Creates a string with the Color3 current values
  62893. * @returns the string representation of the Color3 object
  62894. */
  62895. toString(): string;
  62896. /**
  62897. * Returns the string "Color3"
  62898. * @returns "Color3"
  62899. */
  62900. getClassName(): string;
  62901. /**
  62902. * Compute the Color3 hash code
  62903. * @returns an unique number that can be used to hash Color3 objects
  62904. */
  62905. getHashCode(): number;
  62906. /**
  62907. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62908. * @param array defines the array where to store the r,g,b components
  62909. * @param index defines an optional index in the target array to define where to start storing values
  62910. * @returns the current Color3 object
  62911. */
  62912. toArray(array: FloatArray, index?: number): Color3;
  62913. /**
  62914. * Returns a new Color4 object from the current Color3 and the given alpha
  62915. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62916. * @returns a new Color4 object
  62917. */
  62918. toColor4(alpha?: number): Color4;
  62919. /**
  62920. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62921. * @returns the new array
  62922. */
  62923. asArray(): number[];
  62924. /**
  62925. * Returns the luminance value
  62926. * @returns a float value
  62927. */
  62928. toLuminance(): number;
  62929. /**
  62930. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62931. * @param otherColor defines the second operand
  62932. * @returns the new Color3 object
  62933. */
  62934. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62935. /**
  62936. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62937. * @param otherColor defines the second operand
  62938. * @param result defines the Color3 object where to store the result
  62939. * @returns the current Color3
  62940. */
  62941. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62942. /**
  62943. * Determines equality between Color3 objects
  62944. * @param otherColor defines the second operand
  62945. * @returns true if the rgb values are equal to the given ones
  62946. */
  62947. equals(otherColor: DeepImmutable<Color3>): boolean;
  62948. /**
  62949. * Determines equality between the current Color3 object and a set of r,b,g values
  62950. * @param r defines the red component to check
  62951. * @param g defines the green component to check
  62952. * @param b defines the blue component to check
  62953. * @returns true if the rgb values are equal to the given ones
  62954. */
  62955. equalsFloats(r: number, g: number, b: number): boolean;
  62956. /**
  62957. * Multiplies in place each rgb value by scale
  62958. * @param scale defines the scaling factor
  62959. * @returns the updated Color3
  62960. */
  62961. scale(scale: number): Color3;
  62962. /**
  62963. * Multiplies the rgb values by scale and stores the result into "result"
  62964. * @param scale defines the scaling factor
  62965. * @param result defines the Color3 object where to store the result
  62966. * @returns the unmodified current Color3
  62967. */
  62968. scaleToRef(scale: number, result: Color3): Color3;
  62969. /**
  62970. * Scale the current Color3 values by a factor and add the result to a given Color3
  62971. * @param scale defines the scale factor
  62972. * @param result defines color to store the result into
  62973. * @returns the unmodified current Color3
  62974. */
  62975. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62976. /**
  62977. * Clamps the rgb values by the min and max values and stores the result into "result"
  62978. * @param min defines minimum clamping value (default is 0)
  62979. * @param max defines maximum clamping value (default is 1)
  62980. * @param result defines color to store the result into
  62981. * @returns the original Color3
  62982. */
  62983. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62984. /**
  62985. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62986. * @param otherColor defines the second operand
  62987. * @returns the new Color3
  62988. */
  62989. add(otherColor: DeepImmutable<Color3>): Color3;
  62990. /**
  62991. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62992. * @param otherColor defines the second operand
  62993. * @param result defines Color3 object to store the result into
  62994. * @returns the unmodified current Color3
  62995. */
  62996. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62997. /**
  62998. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62999. * @param otherColor defines the second operand
  63000. * @returns the new Color3
  63001. */
  63002. subtract(otherColor: DeepImmutable<Color3>): Color3;
  63003. /**
  63004. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  63005. * @param otherColor defines the second operand
  63006. * @param result defines Color3 object to store the result into
  63007. * @returns the unmodified current Color3
  63008. */
  63009. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  63010. /**
  63011. * Copy the current object
  63012. * @returns a new Color3 copied the current one
  63013. */
  63014. clone(): Color3;
  63015. /**
  63016. * Copies the rgb values from the source in the current Color3
  63017. * @param source defines the source Color3 object
  63018. * @returns the updated Color3 object
  63019. */
  63020. copyFrom(source: DeepImmutable<Color3>): Color3;
  63021. /**
  63022. * Updates the Color3 rgb values from the given floats
  63023. * @param r defines the red component to read from
  63024. * @param g defines the green component to read from
  63025. * @param b defines the blue component to read from
  63026. * @returns the current Color3 object
  63027. */
  63028. copyFromFloats(r: number, g: number, b: number): Color3;
  63029. /**
  63030. * Updates the Color3 rgb values from the given floats
  63031. * @param r defines the red component to read from
  63032. * @param g defines the green component to read from
  63033. * @param b defines the blue component to read from
  63034. * @returns the current Color3 object
  63035. */
  63036. set(r: number, g: number, b: number): Color3;
  63037. /**
  63038. * Compute the Color3 hexadecimal code as a string
  63039. * @returns a string containing the hexadecimal representation of the Color3 object
  63040. */
  63041. toHexString(): string;
  63042. /**
  63043. * Computes a new Color3 converted from the current one to linear space
  63044. * @returns a new Color3 object
  63045. */
  63046. toLinearSpace(): Color3;
  63047. /**
  63048. * Converts current color in rgb space to HSV values
  63049. * @returns a new color3 representing the HSV values
  63050. */
  63051. toHSV(): Color3;
  63052. /**
  63053. * Converts current color in rgb space to HSV values
  63054. * @param result defines the Color3 where to store the HSV values
  63055. */
  63056. toHSVToRef(result: Color3): void;
  63057. /**
  63058. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63059. * @param convertedColor defines the Color3 object where to store the linear space version
  63060. * @returns the unmodified Color3
  63061. */
  63062. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63063. /**
  63064. * Computes a new Color3 converted from the current one to gamma space
  63065. * @returns a new Color3 object
  63066. */
  63067. toGammaSpace(): Color3;
  63068. /**
  63069. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63070. * @param convertedColor defines the Color3 object where to store the gamma space version
  63071. * @returns the unmodified Color3
  63072. */
  63073. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63074. private static _BlackReadOnly;
  63075. /**
  63076. * Convert Hue, saturation and value to a Color3 (RGB)
  63077. * @param hue defines the hue
  63078. * @param saturation defines the saturation
  63079. * @param value defines the value
  63080. * @param result defines the Color3 where to store the RGB values
  63081. */
  63082. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63083. /**
  63084. * Creates a new Color3 from the string containing valid hexadecimal values
  63085. * @param hex defines a string containing valid hexadecimal values
  63086. * @returns a new Color3 object
  63087. */
  63088. static FromHexString(hex: string): Color3;
  63089. /**
  63090. * Creates a new Color3 from the starting index of the given array
  63091. * @param array defines the source array
  63092. * @param offset defines an offset in the source array
  63093. * @returns a new Color3 object
  63094. */
  63095. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63096. /**
  63097. * Creates a new Color3 from integer values (< 256)
  63098. * @param r defines the red component to read from (value between 0 and 255)
  63099. * @param g defines the green component to read from (value between 0 and 255)
  63100. * @param b defines the blue component to read from (value between 0 and 255)
  63101. * @returns a new Color3 object
  63102. */
  63103. static FromInts(r: number, g: number, b: number): Color3;
  63104. /**
  63105. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63106. * @param start defines the start Color3 value
  63107. * @param end defines the end Color3 value
  63108. * @param amount defines the gradient value between start and end
  63109. * @returns a new Color3 object
  63110. */
  63111. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63112. /**
  63113. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63114. * @param left defines the start value
  63115. * @param right defines the end value
  63116. * @param amount defines the gradient factor
  63117. * @param result defines the Color3 object where to store the result
  63118. */
  63119. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63120. /**
  63121. * Returns a Color3 value containing a red color
  63122. * @returns a new Color3 object
  63123. */
  63124. static Red(): Color3;
  63125. /**
  63126. * Returns a Color3 value containing a green color
  63127. * @returns a new Color3 object
  63128. */
  63129. static Green(): Color3;
  63130. /**
  63131. * Returns a Color3 value containing a blue color
  63132. * @returns a new Color3 object
  63133. */
  63134. static Blue(): Color3;
  63135. /**
  63136. * Returns a Color3 value containing a black color
  63137. * @returns a new Color3 object
  63138. */
  63139. static Black(): Color3;
  63140. /**
  63141. * Gets a Color3 value containing a black color that must not be updated
  63142. */
  63143. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63144. /**
  63145. * Returns a Color3 value containing a white color
  63146. * @returns a new Color3 object
  63147. */
  63148. static White(): Color3;
  63149. /**
  63150. * Returns a Color3 value containing a purple color
  63151. * @returns a new Color3 object
  63152. */
  63153. static Purple(): Color3;
  63154. /**
  63155. * Returns a Color3 value containing a magenta color
  63156. * @returns a new Color3 object
  63157. */
  63158. static Magenta(): Color3;
  63159. /**
  63160. * Returns a Color3 value containing a yellow color
  63161. * @returns a new Color3 object
  63162. */
  63163. static Yellow(): Color3;
  63164. /**
  63165. * Returns a Color3 value containing a gray color
  63166. * @returns a new Color3 object
  63167. */
  63168. static Gray(): Color3;
  63169. /**
  63170. * Returns a Color3 value containing a teal color
  63171. * @returns a new Color3 object
  63172. */
  63173. static Teal(): Color3;
  63174. /**
  63175. * Returns a Color3 value containing a random color
  63176. * @returns a new Color3 object
  63177. */
  63178. static Random(): Color3;
  63179. }
  63180. /**
  63181. * Class used to hold a RBGA color
  63182. */
  63183. export class Color4 {
  63184. /**
  63185. * Defines the red component (between 0 and 1, default is 0)
  63186. */
  63187. r: number;
  63188. /**
  63189. * Defines the green component (between 0 and 1, default is 0)
  63190. */
  63191. g: number;
  63192. /**
  63193. * Defines the blue component (between 0 and 1, default is 0)
  63194. */
  63195. b: number;
  63196. /**
  63197. * Defines the alpha component (between 0 and 1, default is 1)
  63198. */
  63199. a: number;
  63200. /**
  63201. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63202. * @param r defines the red component (between 0 and 1, default is 0)
  63203. * @param g defines the green component (between 0 and 1, default is 0)
  63204. * @param b defines the blue component (between 0 and 1, default is 0)
  63205. * @param a defines the alpha component (between 0 and 1, default is 1)
  63206. */
  63207. constructor(
  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. * Adds in place the given Color4 values to the current Color4 object
  63226. * @param right defines the second operand
  63227. * @returns the current updated Color4 object
  63228. */
  63229. addInPlace(right: DeepImmutable<Color4>): Color4;
  63230. /**
  63231. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63232. * @returns the new array
  63233. */
  63234. asArray(): number[];
  63235. /**
  63236. * Stores from the starting index in the given array the Color4 successive values
  63237. * @param array defines the array where to store the r,g,b components
  63238. * @param index defines an optional index in the target array to define where to start storing values
  63239. * @returns the current Color4 object
  63240. */
  63241. toArray(array: number[], index?: number): Color4;
  63242. /**
  63243. * Determines equality between Color4 objects
  63244. * @param otherColor defines the second operand
  63245. * @returns true if the rgba values are equal to the given ones
  63246. */
  63247. equals(otherColor: DeepImmutable<Color4>): boolean;
  63248. /**
  63249. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63250. * @param right defines the second operand
  63251. * @returns a new Color4 object
  63252. */
  63253. add(right: DeepImmutable<Color4>): Color4;
  63254. /**
  63255. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63256. * @param right defines the second operand
  63257. * @returns a new Color4 object
  63258. */
  63259. subtract(right: DeepImmutable<Color4>): Color4;
  63260. /**
  63261. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63262. * @param right defines the second operand
  63263. * @param result defines the Color4 object where to store the result
  63264. * @returns the current Color4 object
  63265. */
  63266. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63267. /**
  63268. * Creates a new Color4 with the current Color4 values multiplied by scale
  63269. * @param scale defines the scaling factor to apply
  63270. * @returns a new Color4 object
  63271. */
  63272. scale(scale: number): Color4;
  63273. /**
  63274. * Multiplies the current Color4 values by scale and stores the result in "result"
  63275. * @param scale defines the scaling factor to apply
  63276. * @param result defines the Color4 object where to store the result
  63277. * @returns the current unmodified Color4
  63278. */
  63279. scaleToRef(scale: number, result: Color4): Color4;
  63280. /**
  63281. * Scale the current Color4 values by a factor and add the result to a given Color4
  63282. * @param scale defines the scale factor
  63283. * @param result defines the Color4 object where to store the result
  63284. * @returns the unmodified current Color4
  63285. */
  63286. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63287. /**
  63288. * Clamps the rgb values by the min and max values and stores the result into "result"
  63289. * @param min defines minimum clamping value (default is 0)
  63290. * @param max defines maximum clamping value (default is 1)
  63291. * @param result defines color to store the result into.
  63292. * @returns the cuurent Color4
  63293. */
  63294. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63295. /**
  63296. * Multipy an Color4 value by another and return a new Color4 object
  63297. * @param color defines the Color4 value to multiply by
  63298. * @returns a new Color4 object
  63299. */
  63300. multiply(color: Color4): Color4;
  63301. /**
  63302. * Multipy a Color4 value by another and push the result in a reference value
  63303. * @param color defines the Color4 value to multiply by
  63304. * @param result defines the Color4 to fill the result in
  63305. * @returns the result Color4
  63306. */
  63307. multiplyToRef(color: Color4, result: Color4): Color4;
  63308. /**
  63309. * Creates a string with the Color4 current values
  63310. * @returns the string representation of the Color4 object
  63311. */
  63312. toString(): string;
  63313. /**
  63314. * Returns the string "Color4"
  63315. * @returns "Color4"
  63316. */
  63317. getClassName(): string;
  63318. /**
  63319. * Compute the Color4 hash code
  63320. * @returns an unique number that can be used to hash Color4 objects
  63321. */
  63322. getHashCode(): number;
  63323. /**
  63324. * Creates a new Color4 copied from the current one
  63325. * @returns a new Color4 object
  63326. */
  63327. clone(): Color4;
  63328. /**
  63329. * Copies the given Color4 values into the current one
  63330. * @param source defines the source Color4 object
  63331. * @returns the current updated Color4 object
  63332. */
  63333. copyFrom(source: Color4): Color4;
  63334. /**
  63335. * Copies the given float values into the current one
  63336. * @param r defines the red component to read from
  63337. * @param g defines the green component to read from
  63338. * @param b defines the blue component to read from
  63339. * @param a defines the alpha component to read from
  63340. * @returns the current updated Color4 object
  63341. */
  63342. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63343. /**
  63344. * Copies the given float values into the current one
  63345. * @param r defines the red component to read from
  63346. * @param g defines the green component to read from
  63347. * @param b defines the blue component to read from
  63348. * @param a defines the alpha component to read from
  63349. * @returns the current updated Color4 object
  63350. */
  63351. set(r: number, g: number, b: number, a: number): Color4;
  63352. /**
  63353. * Compute the Color4 hexadecimal code as a string
  63354. * @returns a string containing the hexadecimal representation of the Color4 object
  63355. */
  63356. toHexString(): string;
  63357. /**
  63358. * Computes a new Color4 converted from the current one to linear space
  63359. * @returns a new Color4 object
  63360. */
  63361. toLinearSpace(): Color4;
  63362. /**
  63363. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63364. * @param convertedColor defines the Color4 object where to store the linear space version
  63365. * @returns the unmodified Color4
  63366. */
  63367. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63368. /**
  63369. * Computes a new Color4 converted from the current one to gamma space
  63370. * @returns a new Color4 object
  63371. */
  63372. toGammaSpace(): Color4;
  63373. /**
  63374. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63375. * @param convertedColor defines the Color4 object where to store the gamma space version
  63376. * @returns the unmodified Color4
  63377. */
  63378. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63379. /**
  63380. * Creates a new Color4 from the string containing valid hexadecimal values
  63381. * @param hex defines a string containing valid hexadecimal values
  63382. * @returns a new Color4 object
  63383. */
  63384. static FromHexString(hex: string): Color4;
  63385. /**
  63386. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63387. * @param left defines the start value
  63388. * @param right defines the end value
  63389. * @param amount defines the gradient factor
  63390. * @returns a new Color4 object
  63391. */
  63392. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63393. /**
  63394. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63395. * @param left defines the start value
  63396. * @param right defines the end value
  63397. * @param amount defines the gradient factor
  63398. * @param result defines the Color4 object where to store data
  63399. */
  63400. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63401. /**
  63402. * Creates a new Color4 from a Color3 and an alpha value
  63403. * @param color3 defines the source Color3 to read from
  63404. * @param alpha defines the alpha component (1.0 by default)
  63405. * @returns a new Color4 object
  63406. */
  63407. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63408. /**
  63409. * Creates a new Color4 from the starting index element of the given array
  63410. * @param array defines the source array to read from
  63411. * @param offset defines the offset in the source array
  63412. * @returns a new Color4 object
  63413. */
  63414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63415. /**
  63416. * Creates a new Color3 from integer values (< 256)
  63417. * @param r defines the red component to read from (value between 0 and 255)
  63418. * @param g defines the green component to read from (value between 0 and 255)
  63419. * @param b defines the blue component to read from (value between 0 and 255)
  63420. * @param a defines the alpha component to read from (value between 0 and 255)
  63421. * @returns a new Color3 object
  63422. */
  63423. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63424. /**
  63425. * Check the content of a given array and convert it to an array containing RGBA data
  63426. * If the original array was already containing count * 4 values then it is returned directly
  63427. * @param colors defines the array to check
  63428. * @param count defines the number of RGBA data to expect
  63429. * @returns an array containing count * 4 values (RGBA)
  63430. */
  63431. static CheckColors4(colors: number[], count: number): number[];
  63432. }
  63433. /**
  63434. * Class representing a vector containing 2 coordinates
  63435. */
  63436. export class Vector2 {
  63437. /** defines the first coordinate */
  63438. x: number;
  63439. /** defines the second coordinate */
  63440. y: number;
  63441. /**
  63442. * Creates a new Vector2 from the given x and y coordinates
  63443. * @param x defines the first coordinate
  63444. * @param y defines the second coordinate
  63445. */
  63446. constructor(
  63447. /** defines the first coordinate */
  63448. x?: number,
  63449. /** defines the second coordinate */
  63450. y?: number);
  63451. /**
  63452. * Gets a string with the Vector2 coordinates
  63453. * @returns a string with the Vector2 coordinates
  63454. */
  63455. toString(): string;
  63456. /**
  63457. * Gets class name
  63458. * @returns the string "Vector2"
  63459. */
  63460. getClassName(): string;
  63461. /**
  63462. * Gets current vector hash code
  63463. * @returns the Vector2 hash code as a number
  63464. */
  63465. getHashCode(): number;
  63466. /**
  63467. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63468. * @param array defines the source array
  63469. * @param index defines the offset in source array
  63470. * @returns the current Vector2
  63471. */
  63472. toArray(array: FloatArray, index?: number): Vector2;
  63473. /**
  63474. * Copy the current vector to an array
  63475. * @returns a new array with 2 elements: the Vector2 coordinates.
  63476. */
  63477. asArray(): number[];
  63478. /**
  63479. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63480. * @param source defines the source Vector2
  63481. * @returns the current updated Vector2
  63482. */
  63483. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63484. /**
  63485. * Sets the Vector2 coordinates with the given floats
  63486. * @param x defines the first coordinate
  63487. * @param y defines the second coordinate
  63488. * @returns the current updated Vector2
  63489. */
  63490. copyFromFloats(x: number, y: number): Vector2;
  63491. /**
  63492. * Sets the Vector2 coordinates with the given floats
  63493. * @param x defines the first coordinate
  63494. * @param y defines the second coordinate
  63495. * @returns the current updated Vector2
  63496. */
  63497. set(x: number, y: number): Vector2;
  63498. /**
  63499. * Add another vector with the current one
  63500. * @param otherVector defines the other vector
  63501. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63502. */
  63503. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63504. /**
  63505. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63506. * @param otherVector defines the other vector
  63507. * @param result defines the target vector
  63508. * @returns the unmodified current Vector2
  63509. */
  63510. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63511. /**
  63512. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63513. * @param otherVector defines the other vector
  63514. * @returns the current updated Vector2
  63515. */
  63516. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63517. /**
  63518. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63519. * @param otherVector defines the other vector
  63520. * @returns a new Vector2
  63521. */
  63522. addVector3(otherVector: Vector3): Vector2;
  63523. /**
  63524. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63525. * @param otherVector defines the other vector
  63526. * @returns a new Vector2
  63527. */
  63528. subtract(otherVector: Vector2): Vector2;
  63529. /**
  63530. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63531. * @param otherVector defines the other vector
  63532. * @param result defines the target vector
  63533. * @returns the unmodified current Vector2
  63534. */
  63535. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63536. /**
  63537. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63538. * @param otherVector defines the other vector
  63539. * @returns the current updated Vector2
  63540. */
  63541. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63542. /**
  63543. * Multiplies in place the current Vector2 coordinates by the given ones
  63544. * @param otherVector defines the other vector
  63545. * @returns the current updated Vector2
  63546. */
  63547. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63548. /**
  63549. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63550. * @param otherVector defines the other vector
  63551. * @returns a new Vector2
  63552. */
  63553. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63554. /**
  63555. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63556. * @param otherVector defines the other vector
  63557. * @param result defines the target vector
  63558. * @returns the unmodified current Vector2
  63559. */
  63560. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63561. /**
  63562. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63563. * @param x defines the first coordinate
  63564. * @param y defines the second coordinate
  63565. * @returns a new Vector2
  63566. */
  63567. multiplyByFloats(x: number, y: number): Vector2;
  63568. /**
  63569. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63570. * @param otherVector defines the other vector
  63571. * @returns a new Vector2
  63572. */
  63573. divide(otherVector: Vector2): Vector2;
  63574. /**
  63575. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63576. * @param otherVector defines the other vector
  63577. * @param result defines the target vector
  63578. * @returns the unmodified current Vector2
  63579. */
  63580. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63581. /**
  63582. * Divides the current Vector2 coordinates by the given ones
  63583. * @param otherVector defines the other vector
  63584. * @returns the current updated Vector2
  63585. */
  63586. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63587. /**
  63588. * Gets a new Vector2 with current Vector2 negated coordinates
  63589. * @returns a new Vector2
  63590. */
  63591. negate(): Vector2;
  63592. /**
  63593. * Multiply the Vector2 coordinates by scale
  63594. * @param scale defines the scaling factor
  63595. * @returns the current updated Vector2
  63596. */
  63597. scaleInPlace(scale: number): Vector2;
  63598. /**
  63599. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63600. * @param scale defines the scaling factor
  63601. * @returns a new Vector2
  63602. */
  63603. scale(scale: number): Vector2;
  63604. /**
  63605. * Scale the current Vector2 values by a factor to a given Vector2
  63606. * @param scale defines the scale factor
  63607. * @param result defines the Vector2 object where to store the result
  63608. * @returns the unmodified current Vector2
  63609. */
  63610. scaleToRef(scale: number, result: Vector2): Vector2;
  63611. /**
  63612. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63613. * @param scale defines the scale factor
  63614. * @param result defines the Vector2 object where to store the result
  63615. * @returns the unmodified current Vector2
  63616. */
  63617. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63618. /**
  63619. * Gets a boolean if two vectors are equals
  63620. * @param otherVector defines the other vector
  63621. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63622. */
  63623. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63624. /**
  63625. * Gets a boolean if two vectors are equals (using an epsilon value)
  63626. * @param otherVector defines the other vector
  63627. * @param epsilon defines the minimal distance to consider equality
  63628. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63629. */
  63630. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63631. /**
  63632. * Gets a new Vector2 from current Vector2 floored values
  63633. * @returns a new Vector2
  63634. */
  63635. floor(): Vector2;
  63636. /**
  63637. * Gets a new Vector2 from current Vector2 floored values
  63638. * @returns a new Vector2
  63639. */
  63640. fract(): Vector2;
  63641. /**
  63642. * Gets the length of the vector
  63643. * @returns the vector length (float)
  63644. */
  63645. length(): number;
  63646. /**
  63647. * Gets the vector squared length
  63648. * @returns the vector squared length (float)
  63649. */
  63650. lengthSquared(): number;
  63651. /**
  63652. * Normalize the vector
  63653. * @returns the current updated Vector2
  63654. */
  63655. normalize(): Vector2;
  63656. /**
  63657. * Gets a new Vector2 copied from the Vector2
  63658. * @returns a new Vector2
  63659. */
  63660. clone(): Vector2;
  63661. /**
  63662. * Gets a new Vector2(0, 0)
  63663. * @returns a new Vector2
  63664. */
  63665. static Zero(): Vector2;
  63666. /**
  63667. * Gets a new Vector2(1, 1)
  63668. * @returns a new Vector2
  63669. */
  63670. static One(): Vector2;
  63671. /**
  63672. * Gets a new Vector2 set from the given index element of the given array
  63673. * @param array defines the data source
  63674. * @param offset defines the offset in the data source
  63675. * @returns a new Vector2
  63676. */
  63677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63678. /**
  63679. * Sets "result" from the given index element of the given array
  63680. * @param array defines the data source
  63681. * @param offset defines the offset in the data source
  63682. * @param result defines the target vector
  63683. */
  63684. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63685. /**
  63686. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63687. * @param value1 defines 1st point of control
  63688. * @param value2 defines 2nd point of control
  63689. * @param value3 defines 3rd point of control
  63690. * @param value4 defines 4th point of control
  63691. * @param amount defines the interpolation factor
  63692. * @returns a new Vector2
  63693. */
  63694. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63695. /**
  63696. * 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".
  63697. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63698. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63699. * @param value defines the value to clamp
  63700. * @param min defines the lower limit
  63701. * @param max defines the upper limit
  63702. * @returns a new Vector2
  63703. */
  63704. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63705. /**
  63706. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63707. * @param value1 defines the 1st control point
  63708. * @param tangent1 defines the outgoing tangent
  63709. * @param value2 defines the 2nd control point
  63710. * @param tangent2 defines the incoming tangent
  63711. * @param amount defines the interpolation factor
  63712. * @returns a new Vector2
  63713. */
  63714. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63715. /**
  63716. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63717. * @param start defines the start vector
  63718. * @param end defines the end vector
  63719. * @param amount defines the interpolation factor
  63720. * @returns a new Vector2
  63721. */
  63722. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63723. /**
  63724. * Gets the dot product of the vector "left" and the vector "right"
  63725. * @param left defines first vector
  63726. * @param right defines second vector
  63727. * @returns the dot product (float)
  63728. */
  63729. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63730. /**
  63731. * Returns a new Vector2 equal to the normalized given vector
  63732. * @param vector defines the vector to normalize
  63733. * @returns a new Vector2
  63734. */
  63735. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63736. /**
  63737. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63738. * @param left defines 1st vector
  63739. * @param right defines 2nd vector
  63740. * @returns a new Vector2
  63741. */
  63742. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63743. /**
  63744. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63745. * @param left defines 1st vector
  63746. * @param right defines 2nd vector
  63747. * @returns a new Vector2
  63748. */
  63749. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63750. /**
  63751. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63752. * @param vector defines the vector to transform
  63753. * @param transformation defines the matrix to apply
  63754. * @returns a new Vector2
  63755. */
  63756. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63757. /**
  63758. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63759. * @param vector defines the vector to transform
  63760. * @param transformation defines the matrix to apply
  63761. * @param result defines the target vector
  63762. */
  63763. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63764. /**
  63765. * Determines if a given vector is included in a triangle
  63766. * @param p defines the vector to test
  63767. * @param p0 defines 1st triangle point
  63768. * @param p1 defines 2nd triangle point
  63769. * @param p2 defines 3rd triangle point
  63770. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63771. */
  63772. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63773. /**
  63774. * Gets the distance between the vectors "value1" and "value2"
  63775. * @param value1 defines first vector
  63776. * @param value2 defines second vector
  63777. * @returns the distance between vectors
  63778. */
  63779. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63780. /**
  63781. * Returns the squared distance between the vectors "value1" and "value2"
  63782. * @param value1 defines first vector
  63783. * @param value2 defines second vector
  63784. * @returns the squared distance between vectors
  63785. */
  63786. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63787. /**
  63788. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63789. * @param value1 defines first vector
  63790. * @param value2 defines second vector
  63791. * @returns a new Vector2
  63792. */
  63793. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63794. /**
  63795. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63796. * @param p defines the middle point
  63797. * @param segA defines one point of the segment
  63798. * @param segB defines the other point of the segment
  63799. * @returns the shortest distance
  63800. */
  63801. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63802. }
  63803. /**
  63804. * Classed used to store (x,y,z) vector representation
  63805. * A Vector3 is the main object used in 3D geometry
  63806. * It can represent etiher the coordinates of a point the space, either a direction
  63807. * Reminder: js uses a left handed forward facing system
  63808. */
  63809. export class Vector3 {
  63810. /**
  63811. * Defines the first coordinates (on X axis)
  63812. */
  63813. x: number;
  63814. /**
  63815. * Defines the second coordinates (on Y axis)
  63816. */
  63817. y: number;
  63818. /**
  63819. * Defines the third coordinates (on Z axis)
  63820. */
  63821. z: number;
  63822. private static _UpReadOnly;
  63823. private static _ZeroReadOnly;
  63824. /**
  63825. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63826. * @param x defines the first coordinates (on X axis)
  63827. * @param y defines the second coordinates (on Y axis)
  63828. * @param z defines the third coordinates (on Z axis)
  63829. */
  63830. constructor(
  63831. /**
  63832. * Defines the first coordinates (on X axis)
  63833. */
  63834. x?: number,
  63835. /**
  63836. * Defines the second coordinates (on Y axis)
  63837. */
  63838. y?: number,
  63839. /**
  63840. * Defines the third coordinates (on Z axis)
  63841. */
  63842. z?: number);
  63843. /**
  63844. * Creates a string representation of the Vector3
  63845. * @returns a string with the Vector3 coordinates.
  63846. */
  63847. toString(): string;
  63848. /**
  63849. * Gets the class name
  63850. * @returns the string "Vector3"
  63851. */
  63852. getClassName(): string;
  63853. /**
  63854. * Creates the Vector3 hash code
  63855. * @returns a number which tends to be unique between Vector3 instances
  63856. */
  63857. getHashCode(): number;
  63858. /**
  63859. * Creates an array containing three elements : the coordinates of the Vector3
  63860. * @returns a new array of numbers
  63861. */
  63862. asArray(): number[];
  63863. /**
  63864. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63865. * @param array defines the destination array
  63866. * @param index defines the offset in the destination array
  63867. * @returns the current Vector3
  63868. */
  63869. toArray(array: FloatArray, index?: number): Vector3;
  63870. /**
  63871. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63872. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63873. */
  63874. toQuaternion(): Quaternion;
  63875. /**
  63876. * Adds the given vector to the current Vector3
  63877. * @param otherVector defines the second operand
  63878. * @returns the current updated Vector3
  63879. */
  63880. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63881. /**
  63882. * Adds the given coordinates to the current Vector3
  63883. * @param x defines the x coordinate of the operand
  63884. * @param y defines the y coordinate of the operand
  63885. * @param z defines the z coordinate of the operand
  63886. * @returns the current updated Vector3
  63887. */
  63888. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63889. /**
  63890. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63891. * @param otherVector defines the second operand
  63892. * @returns the resulting Vector3
  63893. */
  63894. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63895. /**
  63896. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63897. * @param otherVector defines the second operand
  63898. * @param result defines the Vector3 object where to store the result
  63899. * @returns the current Vector3
  63900. */
  63901. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63902. /**
  63903. * Subtract the given vector from the current Vector3
  63904. * @param otherVector defines the second operand
  63905. * @returns the current updated Vector3
  63906. */
  63907. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63908. /**
  63909. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63910. * @param otherVector defines the second operand
  63911. * @returns the resulting Vector3
  63912. */
  63913. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63914. /**
  63915. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63916. * @param otherVector defines the second operand
  63917. * @param result defines the Vector3 object where to store the result
  63918. * @returns the current Vector3
  63919. */
  63920. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63921. /**
  63922. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63923. * @param x defines the x coordinate of the operand
  63924. * @param y defines the y coordinate of the operand
  63925. * @param z defines the z coordinate of the operand
  63926. * @returns the resulting Vector3
  63927. */
  63928. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63929. /**
  63930. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63931. * @param x defines the x coordinate of the operand
  63932. * @param y defines the y coordinate of the operand
  63933. * @param z defines the z coordinate of the operand
  63934. * @param result defines the Vector3 object where to store the result
  63935. * @returns the current Vector3
  63936. */
  63937. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63938. /**
  63939. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63940. * @returns a new Vector3
  63941. */
  63942. negate(): Vector3;
  63943. /**
  63944. * Multiplies the Vector3 coordinates by the float "scale"
  63945. * @param scale defines the multiplier factor
  63946. * @returns the current updated Vector3
  63947. */
  63948. scaleInPlace(scale: number): Vector3;
  63949. /**
  63950. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63951. * @param scale defines the multiplier factor
  63952. * @returns a new Vector3
  63953. */
  63954. scale(scale: number): Vector3;
  63955. /**
  63956. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63957. * @param scale defines the multiplier factor
  63958. * @param result defines the Vector3 object where to store the result
  63959. * @returns the current Vector3
  63960. */
  63961. scaleToRef(scale: number, result: Vector3): Vector3;
  63962. /**
  63963. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63964. * @param scale defines the scale factor
  63965. * @param result defines the Vector3 object where to store the result
  63966. * @returns the unmodified current Vector3
  63967. */
  63968. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63969. /**
  63970. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63971. * @param otherVector defines the second operand
  63972. * @returns true if both vectors are equals
  63973. */
  63974. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63975. /**
  63976. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63977. * @param otherVector defines the second operand
  63978. * @param epsilon defines the minimal distance to define values as equals
  63979. * @returns true if both vectors are distant less than epsilon
  63980. */
  63981. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63982. /**
  63983. * Returns true if the current Vector3 coordinates equals the given floats
  63984. * @param x defines the x coordinate of the operand
  63985. * @param y defines the y coordinate of the operand
  63986. * @param z defines the z coordinate of the operand
  63987. * @returns true if both vectors are equals
  63988. */
  63989. equalsToFloats(x: number, y: number, z: number): boolean;
  63990. /**
  63991. * Multiplies the current Vector3 coordinates by the given ones
  63992. * @param otherVector defines the second operand
  63993. * @returns the current updated Vector3
  63994. */
  63995. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63996. /**
  63997. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63998. * @param otherVector defines the second operand
  63999. * @returns the new Vector3
  64000. */
  64001. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  64002. /**
  64003. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  64004. * @param otherVector defines the second operand
  64005. * @param result defines the Vector3 object where to store the result
  64006. * @returns the current Vector3
  64007. */
  64008. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64009. /**
  64010. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  64011. * @param x defines the x coordinate of the operand
  64012. * @param y defines the y coordinate of the operand
  64013. * @param z defines the z coordinate of the operand
  64014. * @returns the new Vector3
  64015. */
  64016. multiplyByFloats(x: number, y: number, z: number): Vector3;
  64017. /**
  64018. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  64019. * @param otherVector defines the second operand
  64020. * @returns the new Vector3
  64021. */
  64022. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  64023. /**
  64024. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  64025. * @param otherVector defines the second operand
  64026. * @param result defines the Vector3 object where to store the result
  64027. * @returns the current Vector3
  64028. */
  64029. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  64030. /**
  64031. * Divides the current Vector3 coordinates by the given ones.
  64032. * @param otherVector defines the second operand
  64033. * @returns the current updated Vector3
  64034. */
  64035. divideInPlace(otherVector: Vector3): Vector3;
  64036. /**
  64037. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  64038. * @param other defines the second operand
  64039. * @returns the current updated Vector3
  64040. */
  64041. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64042. /**
  64043. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64044. * @param other defines the second operand
  64045. * @returns the current updated Vector3
  64046. */
  64047. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64048. /**
  64049. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64050. * @param x defines the x coordinate of the operand
  64051. * @param y defines the y coordinate of the operand
  64052. * @param z defines the z coordinate of the operand
  64053. * @returns the current updated Vector3
  64054. */
  64055. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64056. /**
  64057. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64058. * @param x defines the x coordinate of the operand
  64059. * @param y defines the y coordinate of the operand
  64060. * @param z defines the z coordinate of the operand
  64061. * @returns the current updated Vector3
  64062. */
  64063. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64064. /**
  64065. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64066. * Check if is non uniform within a certain amount of decimal places to account for this
  64067. * @param epsilon the amount the values can differ
  64068. * @returns if the the vector is non uniform to a certain number of decimal places
  64069. */
  64070. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64071. /**
  64072. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64073. */
  64074. readonly isNonUniform: boolean;
  64075. /**
  64076. * Gets a new Vector3 from current Vector3 floored values
  64077. * @returns a new Vector3
  64078. */
  64079. floor(): Vector3;
  64080. /**
  64081. * Gets a new Vector3 from current Vector3 floored values
  64082. * @returns a new Vector3
  64083. */
  64084. fract(): Vector3;
  64085. /**
  64086. * Gets the length of the Vector3
  64087. * @returns the length of the Vector3
  64088. */
  64089. length(): number;
  64090. /**
  64091. * Gets the squared length of the Vector3
  64092. * @returns squared length of the Vector3
  64093. */
  64094. lengthSquared(): number;
  64095. /**
  64096. * Normalize the current Vector3.
  64097. * Please note that this is an in place operation.
  64098. * @returns the current updated Vector3
  64099. */
  64100. normalize(): Vector3;
  64101. /**
  64102. * Reorders the x y z properties of the vector in place
  64103. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64104. * @returns the current updated vector
  64105. */
  64106. reorderInPlace(order: string): this;
  64107. /**
  64108. * Rotates the vector around 0,0,0 by a quaternion
  64109. * @param quaternion the rotation quaternion
  64110. * @param result vector to store the result
  64111. * @returns the resulting vector
  64112. */
  64113. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64114. /**
  64115. * Rotates a vector around a given point
  64116. * @param quaternion the rotation quaternion
  64117. * @param point the point to rotate around
  64118. * @param result vector to store the result
  64119. * @returns the resulting vector
  64120. */
  64121. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64122. /**
  64123. * Normalize the current Vector3 with the given input length.
  64124. * Please note that this is an in place operation.
  64125. * @param len the length of the vector
  64126. * @returns the current updated Vector3
  64127. */
  64128. normalizeFromLength(len: number): Vector3;
  64129. /**
  64130. * Normalize the current Vector3 to a new vector
  64131. * @returns the new Vector3
  64132. */
  64133. normalizeToNew(): Vector3;
  64134. /**
  64135. * Normalize the current Vector3 to the reference
  64136. * @param reference define the Vector3 to update
  64137. * @returns the updated Vector3
  64138. */
  64139. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64140. /**
  64141. * Creates a new Vector3 copied from the current Vector3
  64142. * @returns the new Vector3
  64143. */
  64144. clone(): Vector3;
  64145. /**
  64146. * Copies the given vector coordinates to the current Vector3 ones
  64147. * @param source defines the source Vector3
  64148. * @returns the current updated Vector3
  64149. */
  64150. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64151. /**
  64152. * Copies the given floats to the current Vector3 coordinates
  64153. * @param x defines the x coordinate of the operand
  64154. * @param y defines the y coordinate of the operand
  64155. * @param z defines the z coordinate of the operand
  64156. * @returns the current updated Vector3
  64157. */
  64158. copyFromFloats(x: number, y: number, z: number): Vector3;
  64159. /**
  64160. * Copies the given floats to the current Vector3 coordinates
  64161. * @param x defines the x coordinate of the operand
  64162. * @param y defines the y coordinate of the operand
  64163. * @param z defines the z coordinate of the operand
  64164. * @returns the current updated Vector3
  64165. */
  64166. set(x: number, y: number, z: number): Vector3;
  64167. /**
  64168. * Copies the given float to the current Vector3 coordinates
  64169. * @param v defines the x, y and z coordinates of the operand
  64170. * @returns the current updated Vector3
  64171. */
  64172. setAll(v: number): Vector3;
  64173. /**
  64174. * Get the clip factor between two vectors
  64175. * @param vector0 defines the first operand
  64176. * @param vector1 defines the second operand
  64177. * @param axis defines the axis to use
  64178. * @param size defines the size along the axis
  64179. * @returns the clip factor
  64180. */
  64181. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64182. /**
  64183. * Get angle between two vectors
  64184. * @param vector0 angle between vector0 and vector1
  64185. * @param vector1 angle between vector0 and vector1
  64186. * @param normal direction of the normal
  64187. * @return the angle between vector0 and vector1
  64188. */
  64189. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64190. /**
  64191. * Returns a new Vector3 set from the index "offset" of the given array
  64192. * @param array defines the source array
  64193. * @param offset defines the offset in the source array
  64194. * @returns the new Vector3
  64195. */
  64196. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64197. /**
  64198. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64199. * This function is deprecated. Use FromArray instead
  64200. * @param array defines the source array
  64201. * @param offset defines the offset in the source array
  64202. * @returns the new Vector3
  64203. */
  64204. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64205. /**
  64206. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64207. * @param array defines the source array
  64208. * @param offset defines the offset in the source array
  64209. * @param result defines the Vector3 where to store the result
  64210. */
  64211. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64212. /**
  64213. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64214. * This function is deprecated. Use FromArrayToRef instead.
  64215. * @param array defines the source array
  64216. * @param offset defines the offset in the source array
  64217. * @param result defines the Vector3 where to store the result
  64218. */
  64219. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64220. /**
  64221. * Sets the given vector "result" with the given floats.
  64222. * @param x defines the x coordinate of the source
  64223. * @param y defines the y coordinate of the source
  64224. * @param z defines the z coordinate of the source
  64225. * @param result defines the Vector3 where to store the result
  64226. */
  64227. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64228. /**
  64229. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64230. * @returns a new empty Vector3
  64231. */
  64232. static Zero(): Vector3;
  64233. /**
  64234. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64235. * @returns a new unit Vector3
  64236. */
  64237. static One(): Vector3;
  64238. /**
  64239. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64240. * @returns a new up Vector3
  64241. */
  64242. static Up(): Vector3;
  64243. /**
  64244. * Gets a up Vector3 that must not be updated
  64245. */
  64246. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64247. /**
  64248. * Gets a zero Vector3 that must not be updated
  64249. */
  64250. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64251. /**
  64252. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64253. * @returns a new down Vector3
  64254. */
  64255. static Down(): Vector3;
  64256. /**
  64257. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64258. * @returns a new forward Vector3
  64259. */
  64260. static Forward(): Vector3;
  64261. /**
  64262. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64263. * @returns a new forward Vector3
  64264. */
  64265. static Backward(): Vector3;
  64266. /**
  64267. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64268. * @returns a new right Vector3
  64269. */
  64270. static Right(): Vector3;
  64271. /**
  64272. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64273. * @returns a new left Vector3
  64274. */
  64275. static Left(): Vector3;
  64276. /**
  64277. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64278. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64279. * @param vector defines the Vector3 to transform
  64280. * @param transformation defines the transformation matrix
  64281. * @returns the transformed Vector3
  64282. */
  64283. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64284. /**
  64285. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64286. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64287. * @param vector defines the Vector3 to transform
  64288. * @param transformation defines the transformation matrix
  64289. * @param result defines the Vector3 where to store the result
  64290. */
  64291. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64292. /**
  64293. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64294. * This method computes tranformed coordinates only, not transformed direction vectors
  64295. * @param x define the x coordinate of the source vector
  64296. * @param y define the y coordinate of the source vector
  64297. * @param z define the z coordinate of the source vector
  64298. * @param transformation defines the transformation matrix
  64299. * @param result defines the Vector3 where to store the result
  64300. */
  64301. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64302. /**
  64303. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64304. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64305. * @param vector defines the Vector3 to transform
  64306. * @param transformation defines the transformation matrix
  64307. * @returns the new Vector3
  64308. */
  64309. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64310. /**
  64311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64312. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64313. * @param vector defines the Vector3 to transform
  64314. * @param transformation defines the transformation matrix
  64315. * @param result defines the Vector3 where to store the result
  64316. */
  64317. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64318. /**
  64319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64320. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64321. * @param x define the x coordinate of the source vector
  64322. * @param y define the y coordinate of the source vector
  64323. * @param z define the z coordinate of the source vector
  64324. * @param transformation defines the transformation matrix
  64325. * @param result defines the Vector3 where to store the result
  64326. */
  64327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64328. /**
  64329. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64330. * @param value1 defines the first control point
  64331. * @param value2 defines the second control point
  64332. * @param value3 defines the third control point
  64333. * @param value4 defines the fourth control point
  64334. * @param amount defines the amount on the spline to use
  64335. * @returns the new Vector3
  64336. */
  64337. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64338. /**
  64339. * 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"
  64340. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64341. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64342. * @param value defines the current value
  64343. * @param min defines the lower range value
  64344. * @param max defines the upper range value
  64345. * @returns the new Vector3
  64346. */
  64347. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64348. /**
  64349. * 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"
  64350. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64351. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64352. * @param value defines the current value
  64353. * @param min defines the lower range value
  64354. * @param max defines the upper range value
  64355. * @param result defines the Vector3 where to store the result
  64356. */
  64357. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64358. /**
  64359. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64360. * @param value1 defines the first control point
  64361. * @param tangent1 defines the first tangent vector
  64362. * @param value2 defines the second control point
  64363. * @param tangent2 defines the second tangent vector
  64364. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64365. * @returns the new Vector3
  64366. */
  64367. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64368. /**
  64369. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64370. * @param start defines the start value
  64371. * @param end defines the end value
  64372. * @param amount max defines amount between both (between 0 and 1)
  64373. * @returns the new Vector3
  64374. */
  64375. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64376. /**
  64377. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64378. * @param start defines the start value
  64379. * @param end defines the end value
  64380. * @param amount max defines amount between both (between 0 and 1)
  64381. * @param result defines the Vector3 where to store the result
  64382. */
  64383. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64384. /**
  64385. * Returns the dot product (float) between the vectors "left" and "right"
  64386. * @param left defines the left operand
  64387. * @param right defines the right operand
  64388. * @returns the dot product
  64389. */
  64390. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64391. /**
  64392. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64393. * The cross product is then orthogonal to both "left" and "right"
  64394. * @param left defines the left operand
  64395. * @param right defines the right operand
  64396. * @returns the cross product
  64397. */
  64398. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64399. /**
  64400. * Sets the given vector "result" with the cross product of "left" and "right"
  64401. * The cross product is then orthogonal to both "left" and "right"
  64402. * @param left defines the left operand
  64403. * @param right defines the right operand
  64404. * @param result defines the Vector3 where to store the result
  64405. */
  64406. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64407. /**
  64408. * Returns a new Vector3 as the normalization of the given vector
  64409. * @param vector defines the Vector3 to normalize
  64410. * @returns the new Vector3
  64411. */
  64412. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64413. /**
  64414. * Sets the given vector "result" with the normalization of the given first vector
  64415. * @param vector defines the Vector3 to normalize
  64416. * @param result defines the Vector3 where to store the result
  64417. */
  64418. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64419. /**
  64420. * Project a Vector3 onto screen space
  64421. * @param vector defines the Vector3 to project
  64422. * @param world defines the world matrix to use
  64423. * @param transform defines the transform (view x projection) matrix to use
  64424. * @param viewport defines the screen viewport to use
  64425. * @returns the new Vector3
  64426. */
  64427. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64428. /** @hidden */
  64429. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64430. /**
  64431. * Unproject from screen space to object space
  64432. * @param source defines the screen space Vector3 to use
  64433. * @param viewportWidth defines the current width of the viewport
  64434. * @param viewportHeight defines the current height of the viewport
  64435. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64436. * @param transform defines the transform (view x projection) matrix to use
  64437. * @returns the new Vector3
  64438. */
  64439. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64440. /**
  64441. * Unproject from screen space to object space
  64442. * @param source defines the screen space Vector3 to use
  64443. * @param viewportWidth defines the current width of the viewport
  64444. * @param viewportHeight defines the current height of the viewport
  64445. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64446. * @param view defines the view matrix to use
  64447. * @param projection defines the projection matrix to use
  64448. * @returns the new Vector3
  64449. */
  64450. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64451. /**
  64452. * Unproject from screen space to object space
  64453. * @param source defines the screen space Vector3 to use
  64454. * @param viewportWidth defines the current width of the viewport
  64455. * @param viewportHeight defines the current height of the viewport
  64456. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64457. * @param view defines the view matrix to use
  64458. * @param projection defines the projection matrix to use
  64459. * @param result defines the Vector3 where to store the result
  64460. */
  64461. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64462. /**
  64463. * Unproject from screen space to object space
  64464. * @param sourceX defines the screen space x coordinate to use
  64465. * @param sourceY defines the screen space y coordinate to use
  64466. * @param sourceZ defines the screen space z coordinate 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. * @param result defines the Vector3 where to store the result
  64473. */
  64474. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64475. /**
  64476. * Gets the minimal coordinate values between two Vector3
  64477. * @param left defines the first operand
  64478. * @param right defines the second operand
  64479. * @returns the new Vector3
  64480. */
  64481. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64482. /**
  64483. * Gets the maximal coordinate values between two Vector3
  64484. * @param left defines the first operand
  64485. * @param right defines the second operand
  64486. * @returns the new Vector3
  64487. */
  64488. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64489. /**
  64490. * Returns the distance between the vectors "value1" and "value2"
  64491. * @param value1 defines the first operand
  64492. * @param value2 defines the second operand
  64493. * @returns the distance
  64494. */
  64495. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64496. /**
  64497. * Returns the squared distance between the vectors "value1" and "value2"
  64498. * @param value1 defines the first operand
  64499. * @param value2 defines the second operand
  64500. * @returns the squared distance
  64501. */
  64502. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64503. /**
  64504. * Returns a new Vector3 located at the center between "value1" and "value2"
  64505. * @param value1 defines the first operand
  64506. * @param value2 defines the second operand
  64507. * @returns the new Vector3
  64508. */
  64509. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64510. /**
  64511. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64512. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64513. * to something in order to rotate it from its local system to the given target system
  64514. * Note: axis1, axis2 and axis3 are normalized during this operation
  64515. * @param axis1 defines the first axis
  64516. * @param axis2 defines the second axis
  64517. * @param axis3 defines the third axis
  64518. * @returns a new Vector3
  64519. */
  64520. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64521. /**
  64522. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64523. * @param axis1 defines the first axis
  64524. * @param axis2 defines the second axis
  64525. * @param axis3 defines the third axis
  64526. * @param ref defines the Vector3 where to store the result
  64527. */
  64528. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64529. }
  64530. /**
  64531. * Vector4 class created for EulerAngle class conversion to Quaternion
  64532. */
  64533. export class Vector4 {
  64534. /** x value of the vector */
  64535. x: number;
  64536. /** y value of the vector */
  64537. y: number;
  64538. /** z value of the vector */
  64539. z: number;
  64540. /** w value of the vector */
  64541. w: number;
  64542. /**
  64543. * Creates a Vector4 object from the given floats.
  64544. * @param x x value of the vector
  64545. * @param y y value of the vector
  64546. * @param z z value of the vector
  64547. * @param w w value of the vector
  64548. */
  64549. constructor(
  64550. /** x value of the vector */
  64551. x: number,
  64552. /** y value of the vector */
  64553. y: number,
  64554. /** z value of the vector */
  64555. z: number,
  64556. /** w value of the vector */
  64557. w: number);
  64558. /**
  64559. * Returns the string with the Vector4 coordinates.
  64560. * @returns a string containing all the vector values
  64561. */
  64562. toString(): string;
  64563. /**
  64564. * Returns the string "Vector4".
  64565. * @returns "Vector4"
  64566. */
  64567. getClassName(): string;
  64568. /**
  64569. * Returns the Vector4 hash code.
  64570. * @returns a unique hash code
  64571. */
  64572. getHashCode(): number;
  64573. /**
  64574. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64575. * @returns the resulting array
  64576. */
  64577. asArray(): number[];
  64578. /**
  64579. * Populates the given array from the given index with the Vector4 coordinates.
  64580. * @param array array to populate
  64581. * @param index index of the array to start at (default: 0)
  64582. * @returns the Vector4.
  64583. */
  64584. toArray(array: FloatArray, index?: number): Vector4;
  64585. /**
  64586. * Adds the given vector to the current Vector4.
  64587. * @param otherVector the vector to add
  64588. * @returns the updated Vector4.
  64589. */
  64590. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64591. /**
  64592. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64593. * @param otherVector the vector to add
  64594. * @returns the resulting vector
  64595. */
  64596. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64597. /**
  64598. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64599. * @param otherVector the vector to add
  64600. * @param result the vector to store the result
  64601. * @returns the current Vector4.
  64602. */
  64603. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64604. /**
  64605. * Subtract in place the given vector from the current Vector4.
  64606. * @param otherVector the vector to subtract
  64607. * @returns the updated Vector4.
  64608. */
  64609. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64610. /**
  64611. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64612. * @param otherVector the vector to add
  64613. * @returns the new vector with the result
  64614. */
  64615. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64616. /**
  64617. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64618. * @param otherVector the vector to subtract
  64619. * @param result the vector to store the result
  64620. * @returns the current Vector4.
  64621. */
  64622. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64623. /**
  64624. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64625. */
  64626. /**
  64627. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64628. * @param x value to subtract
  64629. * @param y value to subtract
  64630. * @param z value to subtract
  64631. * @param w value to subtract
  64632. * @returns new vector containing the result
  64633. */
  64634. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64635. /**
  64636. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64637. * @param x value to subtract
  64638. * @param y value to subtract
  64639. * @param z value to subtract
  64640. * @param w value to subtract
  64641. * @param result the vector to store the result in
  64642. * @returns the current Vector4.
  64643. */
  64644. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64645. /**
  64646. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64647. * @returns a new vector with the negated values
  64648. */
  64649. negate(): Vector4;
  64650. /**
  64651. * Multiplies the current Vector4 coordinates by scale (float).
  64652. * @param scale the number to scale with
  64653. * @returns the updated Vector4.
  64654. */
  64655. scaleInPlace(scale: number): Vector4;
  64656. /**
  64657. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64658. * @param scale the number to scale with
  64659. * @returns a new vector with the result
  64660. */
  64661. scale(scale: number): Vector4;
  64662. /**
  64663. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64664. * @param scale the number to scale with
  64665. * @param result a vector to store the result in
  64666. * @returns the current Vector4.
  64667. */
  64668. scaleToRef(scale: number, result: Vector4): Vector4;
  64669. /**
  64670. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64671. * @param scale defines the scale factor
  64672. * @param result defines the Vector4 object where to store the result
  64673. * @returns the unmodified current Vector4
  64674. */
  64675. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64676. /**
  64677. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64678. * @param otherVector the vector to compare against
  64679. * @returns true if they are equal
  64680. */
  64681. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64682. /**
  64683. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64684. * @param otherVector vector to compare against
  64685. * @param epsilon (Default: very small number)
  64686. * @returns true if they are equal
  64687. */
  64688. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64689. /**
  64690. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64691. * @param x x value to compare against
  64692. * @param y y value to compare against
  64693. * @param z z value to compare against
  64694. * @param w w value to compare against
  64695. * @returns true if equal
  64696. */
  64697. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64698. /**
  64699. * Multiplies in place the current Vector4 by the given one.
  64700. * @param otherVector vector to multiple with
  64701. * @returns the updated Vector4.
  64702. */
  64703. multiplyInPlace(otherVector: Vector4): Vector4;
  64704. /**
  64705. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64706. * @param otherVector vector to multiple with
  64707. * @returns resulting new vector
  64708. */
  64709. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64710. /**
  64711. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64712. * @param otherVector vector to multiple with
  64713. * @param result vector to store the result
  64714. * @returns the current Vector4.
  64715. */
  64716. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64717. /**
  64718. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64719. * @param x x value multiply with
  64720. * @param y y value multiply with
  64721. * @param z z value multiply with
  64722. * @param w w value multiply with
  64723. * @returns resulting new vector
  64724. */
  64725. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64726. /**
  64727. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64728. * @param otherVector vector to devide with
  64729. * @returns resulting new vector
  64730. */
  64731. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64732. /**
  64733. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64734. * @param otherVector vector to devide with
  64735. * @param result vector to store the result
  64736. * @returns the current Vector4.
  64737. */
  64738. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64739. /**
  64740. * Divides the current Vector3 coordinates by the given ones.
  64741. * @param otherVector vector to devide with
  64742. * @returns the updated Vector3.
  64743. */
  64744. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64745. /**
  64746. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64747. * @param other defines the second operand
  64748. * @returns the current updated Vector4
  64749. */
  64750. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64751. /**
  64752. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64753. * @param other defines the second operand
  64754. * @returns the current updated Vector4
  64755. */
  64756. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64757. /**
  64758. * Gets a new Vector4 from current Vector4 floored values
  64759. * @returns a new Vector4
  64760. */
  64761. floor(): Vector4;
  64762. /**
  64763. * Gets a new Vector4 from current Vector3 floored values
  64764. * @returns a new Vector4
  64765. */
  64766. fract(): Vector4;
  64767. /**
  64768. * Returns the Vector4 length (float).
  64769. * @returns the length
  64770. */
  64771. length(): number;
  64772. /**
  64773. * Returns the Vector4 squared length (float).
  64774. * @returns the length squared
  64775. */
  64776. lengthSquared(): number;
  64777. /**
  64778. * Normalizes in place the Vector4.
  64779. * @returns the updated Vector4.
  64780. */
  64781. normalize(): Vector4;
  64782. /**
  64783. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64784. * @returns this converted to a new vector3
  64785. */
  64786. toVector3(): Vector3;
  64787. /**
  64788. * Returns a new Vector4 copied from the current one.
  64789. * @returns the new cloned vector
  64790. */
  64791. clone(): Vector4;
  64792. /**
  64793. * Updates the current Vector4 with the given one coordinates.
  64794. * @param source the source vector to copy from
  64795. * @returns the updated Vector4.
  64796. */
  64797. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64798. /**
  64799. * Updates the current Vector4 coordinates with the given floats.
  64800. * @param x float to copy from
  64801. * @param y float to copy from
  64802. * @param z float to copy from
  64803. * @param w float to copy from
  64804. * @returns the updated Vector4.
  64805. */
  64806. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64807. /**
  64808. * Updates the current Vector4 coordinates with the given floats.
  64809. * @param x float to set from
  64810. * @param y float to set from
  64811. * @param z float to set from
  64812. * @param w float to set from
  64813. * @returns the updated Vector4.
  64814. */
  64815. set(x: number, y: number, z: number, w: number): Vector4;
  64816. /**
  64817. * Copies the given float to the current Vector3 coordinates
  64818. * @param v defines the x, y, z and w coordinates of the operand
  64819. * @returns the current updated Vector3
  64820. */
  64821. setAll(v: number): Vector4;
  64822. /**
  64823. * Returns a new Vector4 set from the starting index of the given array.
  64824. * @param array the array to pull values from
  64825. * @param offset the offset into the array to start at
  64826. * @returns the new vector
  64827. */
  64828. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64829. /**
  64830. * Updates the given vector "result" from the starting index of the given array.
  64831. * @param array the array to pull values from
  64832. * @param offset the offset into the array to start at
  64833. * @param result the vector to store the result in
  64834. */
  64835. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64836. /**
  64837. * Updates the given vector "result" from the starting index of the given Float32Array.
  64838. * @param array the array to pull values from
  64839. * @param offset the offset into the array to start at
  64840. * @param result the vector to store the result in
  64841. */
  64842. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64843. /**
  64844. * Updates the given vector "result" coordinates from the given floats.
  64845. * @param x float to set from
  64846. * @param y float to set from
  64847. * @param z float to set from
  64848. * @param w float to set from
  64849. * @param result the vector to the floats in
  64850. */
  64851. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64852. /**
  64853. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64854. * @returns the new vector
  64855. */
  64856. static Zero(): Vector4;
  64857. /**
  64858. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64859. * @returns the new vector
  64860. */
  64861. static One(): Vector4;
  64862. /**
  64863. * Returns a new normalized Vector4 from the given one.
  64864. * @param vector the vector to normalize
  64865. * @returns the vector
  64866. */
  64867. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64868. /**
  64869. * Updates the given vector "result" from the normalization of the given one.
  64870. * @param vector the vector to normalize
  64871. * @param result the vector to store the result in
  64872. */
  64873. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64874. /**
  64875. * Returns a vector with the minimum values from the left and right vectors
  64876. * @param left left vector to minimize
  64877. * @param right right vector to minimize
  64878. * @returns a new vector with the minimum of the left and right vector values
  64879. */
  64880. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64881. /**
  64882. * Returns a vector with the maximum values from the left and right vectors
  64883. * @param left left vector to maximize
  64884. * @param right right vector to maximize
  64885. * @returns a new vector with the maximum of the left and right vector values
  64886. */
  64887. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64888. /**
  64889. * Returns the distance (float) between the vectors "value1" and "value2".
  64890. * @param value1 value to calulate the distance between
  64891. * @param value2 value to calulate the distance between
  64892. * @return the distance between the two vectors
  64893. */
  64894. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64895. /**
  64896. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64897. * @param value1 value to calulate the distance between
  64898. * @param value2 value to calulate the distance between
  64899. * @return the distance between the two vectors squared
  64900. */
  64901. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64902. /**
  64903. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64904. * @param value1 value to calulate the center between
  64905. * @param value2 value to calulate the center between
  64906. * @return the center between the two vectors
  64907. */
  64908. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64909. /**
  64910. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64911. * This methods computes transformed normalized direction vectors only.
  64912. * @param vector the vector to transform
  64913. * @param transformation the transformation matrix to apply
  64914. * @returns the new vector
  64915. */
  64916. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64917. /**
  64918. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64919. * This methods computes transformed normalized direction vectors only.
  64920. * @param vector the vector to transform
  64921. * @param transformation the transformation matrix to apply
  64922. * @param result the vector to store the result in
  64923. */
  64924. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64925. /**
  64926. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64927. * This methods computes transformed normalized direction vectors only.
  64928. * @param x value to transform
  64929. * @param y value to transform
  64930. * @param z value to transform
  64931. * @param w value to transform
  64932. * @param transformation the transformation matrix to apply
  64933. * @param result the vector to store the results in
  64934. */
  64935. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64936. /**
  64937. * Creates a new Vector4 from a Vector3
  64938. * @param source defines the source data
  64939. * @param w defines the 4th component (default is 0)
  64940. * @returns a new Vector4
  64941. */
  64942. static FromVector3(source: Vector3, w?: number): Vector4;
  64943. }
  64944. /**
  64945. * Interface for the size containing width and height
  64946. */
  64947. export interface ISize {
  64948. /**
  64949. * Width
  64950. */
  64951. width: number;
  64952. /**
  64953. * Heighht
  64954. */
  64955. height: number;
  64956. }
  64957. /**
  64958. * Size containing widht and height
  64959. */
  64960. export class Size implements ISize {
  64961. /**
  64962. * Width
  64963. */
  64964. width: number;
  64965. /**
  64966. * Height
  64967. */
  64968. height: number;
  64969. /**
  64970. * Creates a Size object from the given width and height (floats).
  64971. * @param width width of the new size
  64972. * @param height height of the new size
  64973. */
  64974. constructor(width: number, height: number);
  64975. /**
  64976. * Returns a string with the Size width and height
  64977. * @returns a string with the Size width and height
  64978. */
  64979. toString(): string;
  64980. /**
  64981. * "Size"
  64982. * @returns the string "Size"
  64983. */
  64984. getClassName(): string;
  64985. /**
  64986. * Returns the Size hash code.
  64987. * @returns a hash code for a unique width and height
  64988. */
  64989. getHashCode(): number;
  64990. /**
  64991. * Updates the current size from the given one.
  64992. * @param src the given size
  64993. */
  64994. copyFrom(src: Size): void;
  64995. /**
  64996. * Updates in place the current Size from the given floats.
  64997. * @param width width of the new size
  64998. * @param height height of the new size
  64999. * @returns the updated Size.
  65000. */
  65001. copyFromFloats(width: number, height: number): Size;
  65002. /**
  65003. * Updates in place the current Size from the given floats.
  65004. * @param width width to set
  65005. * @param height height to set
  65006. * @returns the updated Size.
  65007. */
  65008. set(width: number, height: number): Size;
  65009. /**
  65010. * Multiplies the width and height by numbers
  65011. * @param w factor to multiple the width by
  65012. * @param h factor to multiple the height by
  65013. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  65014. */
  65015. multiplyByFloats(w: number, h: number): Size;
  65016. /**
  65017. * Clones the size
  65018. * @returns a new Size copied from the given one.
  65019. */
  65020. clone(): Size;
  65021. /**
  65022. * True if the current Size and the given one width and height are strictly equal.
  65023. * @param other the other size to compare against
  65024. * @returns True if the current Size and the given one width and height are strictly equal.
  65025. */
  65026. equals(other: Size): boolean;
  65027. /**
  65028. * The surface of the Size : width * height (float).
  65029. */
  65030. readonly surface: number;
  65031. /**
  65032. * Create a new size of zero
  65033. * @returns a new Size set to (0.0, 0.0)
  65034. */
  65035. static Zero(): Size;
  65036. /**
  65037. * Sums the width and height of two sizes
  65038. * @param otherSize size to add to this size
  65039. * @returns a new Size set as the addition result of the current Size and the given one.
  65040. */
  65041. add(otherSize: Size): Size;
  65042. /**
  65043. * Subtracts the width and height of two
  65044. * @param otherSize size to subtract to this size
  65045. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65046. */
  65047. subtract(otherSize: Size): Size;
  65048. /**
  65049. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65050. * @param start starting size to lerp between
  65051. * @param end end size to lerp between
  65052. * @param amount amount to lerp between the start and end values
  65053. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65054. */
  65055. static Lerp(start: Size, end: Size, amount: number): Size;
  65056. }
  65057. /**
  65058. * Class used to store quaternion data
  65059. * @see https://en.wikipedia.org/wiki/Quaternion
  65060. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65061. */
  65062. export class Quaternion {
  65063. /** defines the first component (0 by default) */
  65064. x: number;
  65065. /** defines the second component (0 by default) */
  65066. y: number;
  65067. /** defines the third component (0 by default) */
  65068. z: number;
  65069. /** defines the fourth component (1.0 by default) */
  65070. w: number;
  65071. /**
  65072. * Creates a new Quaternion from the given floats
  65073. * @param x defines the first component (0 by default)
  65074. * @param y defines the second component (0 by default)
  65075. * @param z defines the third component (0 by default)
  65076. * @param w defines the fourth component (1.0 by default)
  65077. */
  65078. constructor(
  65079. /** defines the first component (0 by default) */
  65080. x?: number,
  65081. /** defines the second component (0 by default) */
  65082. y?: number,
  65083. /** defines the third component (0 by default) */
  65084. z?: number,
  65085. /** defines the fourth component (1.0 by default) */
  65086. w?: number);
  65087. /**
  65088. * Gets a string representation for the current quaternion
  65089. * @returns a string with the Quaternion coordinates
  65090. */
  65091. toString(): string;
  65092. /**
  65093. * Gets the class name of the quaternion
  65094. * @returns the string "Quaternion"
  65095. */
  65096. getClassName(): string;
  65097. /**
  65098. * Gets a hash code for this quaternion
  65099. * @returns the quaternion hash code
  65100. */
  65101. getHashCode(): number;
  65102. /**
  65103. * Copy the quaternion to an array
  65104. * @returns a new array populated with 4 elements from the quaternion coordinates
  65105. */
  65106. asArray(): number[];
  65107. /**
  65108. * Check if two quaternions are equals
  65109. * @param otherQuaternion defines the second operand
  65110. * @return true if the current quaternion and the given one coordinates are strictly equals
  65111. */
  65112. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65113. /**
  65114. * Clone the current quaternion
  65115. * @returns a new quaternion copied from the current one
  65116. */
  65117. clone(): Quaternion;
  65118. /**
  65119. * Copy a quaternion to the current one
  65120. * @param other defines the other quaternion
  65121. * @returns the updated current quaternion
  65122. */
  65123. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65124. /**
  65125. * Updates the current quaternion with the given float coordinates
  65126. * @param x defines the x coordinate
  65127. * @param y defines the y coordinate
  65128. * @param z defines the z coordinate
  65129. * @param w defines the w coordinate
  65130. * @returns the updated current quaternion
  65131. */
  65132. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65133. /**
  65134. * Updates the current quaternion from the given float coordinates
  65135. * @param x defines the x coordinate
  65136. * @param y defines the y coordinate
  65137. * @param z defines the z coordinate
  65138. * @param w defines the w coordinate
  65139. * @returns the updated current quaternion
  65140. */
  65141. set(x: number, y: number, z: number, w: number): Quaternion;
  65142. /**
  65143. * Adds two quaternions
  65144. * @param other defines the second operand
  65145. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65146. */
  65147. add(other: DeepImmutable<Quaternion>): Quaternion;
  65148. /**
  65149. * Add a quaternion to the current one
  65150. * @param other defines the quaternion to add
  65151. * @returns the current quaternion
  65152. */
  65153. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65154. /**
  65155. * Subtract two quaternions
  65156. * @param other defines the second operand
  65157. * @returns a new quaternion as the subtraction result of the given one from the current one
  65158. */
  65159. subtract(other: Quaternion): Quaternion;
  65160. /**
  65161. * Multiplies the current quaternion by a scale factor
  65162. * @param value defines the scale factor
  65163. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65164. */
  65165. scale(value: number): Quaternion;
  65166. /**
  65167. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65168. * @param scale defines the scale factor
  65169. * @param result defines the Quaternion object where to store the result
  65170. * @returns the unmodified current quaternion
  65171. */
  65172. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65173. /**
  65174. * Multiplies in place the current quaternion by a scale factor
  65175. * @param value defines the scale factor
  65176. * @returns the current modified quaternion
  65177. */
  65178. scaleInPlace(value: number): Quaternion;
  65179. /**
  65180. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65181. * @param scale defines the scale factor
  65182. * @param result defines the Quaternion object where to store the result
  65183. * @returns the unmodified current quaternion
  65184. */
  65185. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65186. /**
  65187. * Multiplies two quaternions
  65188. * @param q1 defines the second operand
  65189. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65190. */
  65191. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65192. /**
  65193. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65194. * @param q1 defines the second operand
  65195. * @param result defines the target quaternion
  65196. * @returns the current quaternion
  65197. */
  65198. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65199. /**
  65200. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65201. * @param q1 defines the second operand
  65202. * @returns the currentupdated quaternion
  65203. */
  65204. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65205. /**
  65206. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65207. * @param ref defines the target quaternion
  65208. * @returns the current quaternion
  65209. */
  65210. conjugateToRef(ref: Quaternion): Quaternion;
  65211. /**
  65212. * Conjugates in place (1-q) the current quaternion
  65213. * @returns the current updated quaternion
  65214. */
  65215. conjugateInPlace(): Quaternion;
  65216. /**
  65217. * Conjugates in place (1-q) the current quaternion
  65218. * @returns a new quaternion
  65219. */
  65220. conjugate(): Quaternion;
  65221. /**
  65222. * Gets length of current quaternion
  65223. * @returns the quaternion length (float)
  65224. */
  65225. length(): number;
  65226. /**
  65227. * Normalize in place the current quaternion
  65228. * @returns the current updated quaternion
  65229. */
  65230. normalize(): Quaternion;
  65231. /**
  65232. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65233. * @param order is a reserved parameter and is ignore for now
  65234. * @returns a new Vector3 containing the Euler angles
  65235. */
  65236. toEulerAngles(order?: string): Vector3;
  65237. /**
  65238. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65239. * @param result defines the vector which will be filled with the Euler angles
  65240. * @param order is a reserved parameter and is ignore for now
  65241. * @returns the current unchanged quaternion
  65242. */
  65243. toEulerAnglesToRef(result: Vector3): Quaternion;
  65244. /**
  65245. * Updates the given rotation matrix with the current quaternion values
  65246. * @param result defines the target matrix
  65247. * @returns the current unchanged quaternion
  65248. */
  65249. toRotationMatrix(result: Matrix): Quaternion;
  65250. /**
  65251. * Updates the current quaternion from the given rotation matrix values
  65252. * @param matrix defines the source matrix
  65253. * @returns the current updated quaternion
  65254. */
  65255. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65256. /**
  65257. * Creates a new quaternion from a rotation matrix
  65258. * @param matrix defines the source matrix
  65259. * @returns a new quaternion created from the given rotation matrix values
  65260. */
  65261. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65262. /**
  65263. * Updates the given quaternion with the given rotation matrix values
  65264. * @param matrix defines the source matrix
  65265. * @param result defines the target quaternion
  65266. */
  65267. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65268. /**
  65269. * Returns the dot product (float) between the quaternions "left" and "right"
  65270. * @param left defines the left operand
  65271. * @param right defines the right operand
  65272. * @returns the dot product
  65273. */
  65274. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65275. /**
  65276. * Checks if the two quaternions are close to each other
  65277. * @param quat0 defines the first quaternion to check
  65278. * @param quat1 defines the second quaternion to check
  65279. * @returns true if the two quaternions are close to each other
  65280. */
  65281. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65282. /**
  65283. * Creates an empty quaternion
  65284. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65285. */
  65286. static Zero(): Quaternion;
  65287. /**
  65288. * Inverse a given quaternion
  65289. * @param q defines the source quaternion
  65290. * @returns a new quaternion as the inverted current quaternion
  65291. */
  65292. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65293. /**
  65294. * Inverse a given quaternion
  65295. * @param q defines the source quaternion
  65296. * @param result the quaternion the result will be stored in
  65297. * @returns the result quaternion
  65298. */
  65299. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65300. /**
  65301. * Creates an identity quaternion
  65302. * @returns the identity quaternion
  65303. */
  65304. static Identity(): Quaternion;
  65305. /**
  65306. * Gets a boolean indicating if the given quaternion is identity
  65307. * @param quaternion defines the quaternion to check
  65308. * @returns true if the quaternion is identity
  65309. */
  65310. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65311. /**
  65312. * Creates a quaternion from a rotation around an axis
  65313. * @param axis defines the axis to use
  65314. * @param angle defines the angle to use
  65315. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65316. */
  65317. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65318. /**
  65319. * Creates a rotation around an axis and stores it into the given quaternion
  65320. * @param axis defines the axis to use
  65321. * @param angle defines the angle to use
  65322. * @param result defines the target quaternion
  65323. * @returns the target quaternion
  65324. */
  65325. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65326. /**
  65327. * Creates a new quaternion from data stored into an array
  65328. * @param array defines the data source
  65329. * @param offset defines the offset in the source array where the data starts
  65330. * @returns a new quaternion
  65331. */
  65332. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65333. /**
  65334. * Create a quaternion from Euler rotation angles
  65335. * @param x Pitch
  65336. * @param y Yaw
  65337. * @param z Roll
  65338. * @returns the new Quaternion
  65339. */
  65340. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65341. /**
  65342. * Updates a quaternion from Euler rotation angles
  65343. * @param x Pitch
  65344. * @param y Yaw
  65345. * @param z Roll
  65346. * @param result the quaternion to store the result
  65347. * @returns the updated quaternion
  65348. */
  65349. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65350. /**
  65351. * Create a quaternion from Euler rotation vector
  65352. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65353. * @returns the new Quaternion
  65354. */
  65355. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65356. /**
  65357. * Updates a quaternion from Euler rotation vector
  65358. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65359. * @param result the quaternion to store the result
  65360. * @returns the updated quaternion
  65361. */
  65362. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65363. /**
  65364. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65365. * @param yaw defines the rotation around Y axis
  65366. * @param pitch defines the rotation around X axis
  65367. * @param roll defines the rotation around Z axis
  65368. * @returns the new quaternion
  65369. */
  65370. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65371. /**
  65372. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65373. * @param yaw defines the rotation around Y axis
  65374. * @param pitch defines the rotation around X axis
  65375. * @param roll defines the rotation around Z axis
  65376. * @param result defines the target quaternion
  65377. */
  65378. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65379. /**
  65380. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65381. * @param alpha defines the rotation around first axis
  65382. * @param beta defines the rotation around second axis
  65383. * @param gamma defines the rotation around third axis
  65384. * @returns the new quaternion
  65385. */
  65386. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65387. /**
  65388. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65389. * @param alpha defines the rotation around first axis
  65390. * @param beta defines the rotation around second axis
  65391. * @param gamma defines the rotation around third axis
  65392. * @param result defines the target quaternion
  65393. */
  65394. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65395. /**
  65396. * 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)
  65397. * @param axis1 defines the first axis
  65398. * @param axis2 defines the second axis
  65399. * @param axis3 defines the third axis
  65400. * @returns the new quaternion
  65401. */
  65402. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65403. /**
  65404. * 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
  65405. * @param axis1 defines the first axis
  65406. * @param axis2 defines the second axis
  65407. * @param axis3 defines the third axis
  65408. * @param ref defines the target quaternion
  65409. */
  65410. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65411. /**
  65412. * Interpolates between two quaternions
  65413. * @param left defines first quaternion
  65414. * @param right defines second quaternion
  65415. * @param amount defines the gradient to use
  65416. * @returns the new interpolated quaternion
  65417. */
  65418. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65419. /**
  65420. * Interpolates between two quaternions and stores it into a target quaternion
  65421. * @param left defines first quaternion
  65422. * @param right defines second quaternion
  65423. * @param amount defines the gradient to use
  65424. * @param result defines the target quaternion
  65425. */
  65426. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65427. /**
  65428. * Interpolate between two quaternions using Hermite interpolation
  65429. * @param value1 defines first quaternion
  65430. * @param tangent1 defines the incoming tangent
  65431. * @param value2 defines second quaternion
  65432. * @param tangent2 defines the outgoing tangent
  65433. * @param amount defines the target quaternion
  65434. * @returns the new interpolated quaternion
  65435. */
  65436. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65437. }
  65438. /**
  65439. * Class used to store matrix data (4x4)
  65440. */
  65441. export class Matrix {
  65442. private static _updateFlagSeed;
  65443. private static _identityReadOnly;
  65444. private _isIdentity;
  65445. private _isIdentityDirty;
  65446. private _isIdentity3x2;
  65447. private _isIdentity3x2Dirty;
  65448. /**
  65449. * Gets the update flag of the matrix which is an unique number for the matrix.
  65450. * It will be incremented every time the matrix data change.
  65451. * You can use it to speed the comparison between two versions of the same matrix.
  65452. */
  65453. updateFlag: number;
  65454. private readonly _m;
  65455. /**
  65456. * Gets the internal data of the matrix
  65457. */
  65458. readonly m: DeepImmutable<Float32Array>;
  65459. /** @hidden */
  65460. _markAsUpdated(): void;
  65461. /** @hidden */
  65462. private _updateIdentityStatus;
  65463. /**
  65464. * Creates an empty matrix (filled with zeros)
  65465. */
  65466. constructor();
  65467. /**
  65468. * Check if the current matrix is identity
  65469. * @returns true is the matrix is the identity matrix
  65470. */
  65471. isIdentity(): boolean;
  65472. /**
  65473. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65474. * @returns true is the matrix is the identity matrix
  65475. */
  65476. isIdentityAs3x2(): boolean;
  65477. /**
  65478. * Gets the determinant of the matrix
  65479. * @returns the matrix determinant
  65480. */
  65481. determinant(): number;
  65482. /**
  65483. * Returns the matrix as a Float32Array
  65484. * @returns the matrix underlying array
  65485. */
  65486. toArray(): DeepImmutable<Float32Array>;
  65487. /**
  65488. * Returns the matrix as a Float32Array
  65489. * @returns the matrix underlying array.
  65490. */
  65491. asArray(): DeepImmutable<Float32Array>;
  65492. /**
  65493. * Inverts the current matrix in place
  65494. * @returns the current inverted matrix
  65495. */
  65496. invert(): Matrix;
  65497. /**
  65498. * Sets all the matrix elements to zero
  65499. * @returns the current matrix
  65500. */
  65501. reset(): Matrix;
  65502. /**
  65503. * Adds the current matrix with a second one
  65504. * @param other defines the matrix to add
  65505. * @returns a new matrix as the addition of the current matrix and the given one
  65506. */
  65507. add(other: DeepImmutable<Matrix>): Matrix;
  65508. /**
  65509. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65510. * @param other defines the matrix to add
  65511. * @param result defines the target matrix
  65512. * @returns the current matrix
  65513. */
  65514. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65515. /**
  65516. * Adds in place the given matrix to the current matrix
  65517. * @param other defines the second operand
  65518. * @returns the current updated matrix
  65519. */
  65520. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65521. /**
  65522. * Sets the given matrix to the current inverted Matrix
  65523. * @param other defines the target matrix
  65524. * @returns the unmodified current matrix
  65525. */
  65526. invertToRef(other: Matrix): Matrix;
  65527. /**
  65528. * add a value at the specified position in the current Matrix
  65529. * @param index the index of the value within the matrix. between 0 and 15.
  65530. * @param value the value to be added
  65531. * @returns the current updated matrix
  65532. */
  65533. addAtIndex(index: number, value: number): Matrix;
  65534. /**
  65535. * mutiply the specified position in the current Matrix by a value
  65536. * @param index the index of the value within the matrix. between 0 and 15.
  65537. * @param value the value to be added
  65538. * @returns the current updated matrix
  65539. */
  65540. multiplyAtIndex(index: number, value: number): Matrix;
  65541. /**
  65542. * Inserts the translation vector (using 3 floats) in the current matrix
  65543. * @param x defines the 1st component of the translation
  65544. * @param y defines the 2nd component of the translation
  65545. * @param z defines the 3rd component of the translation
  65546. * @returns the current updated matrix
  65547. */
  65548. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65549. /**
  65550. * Adds the translation vector (using 3 floats) in the current matrix
  65551. * @param x defines the 1st component of the translation
  65552. * @param y defines the 2nd component of the translation
  65553. * @param z defines the 3rd component of the translation
  65554. * @returns the current updated matrix
  65555. */
  65556. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65557. /**
  65558. * Inserts the translation vector in the current matrix
  65559. * @param vector3 defines the translation to insert
  65560. * @returns the current updated matrix
  65561. */
  65562. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65563. /**
  65564. * Gets the translation value of the current matrix
  65565. * @returns a new Vector3 as the extracted translation from the matrix
  65566. */
  65567. getTranslation(): Vector3;
  65568. /**
  65569. * Fill a Vector3 with the extracted translation from the matrix
  65570. * @param result defines the Vector3 where to store the translation
  65571. * @returns the current matrix
  65572. */
  65573. getTranslationToRef(result: Vector3): Matrix;
  65574. /**
  65575. * Remove rotation and scaling part from the matrix
  65576. * @returns the updated matrix
  65577. */
  65578. removeRotationAndScaling(): Matrix;
  65579. /**
  65580. * Multiply two matrices
  65581. * @param other defines the second operand
  65582. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65583. */
  65584. multiply(other: DeepImmutable<Matrix>): Matrix;
  65585. /**
  65586. * Copy the current matrix from the given one
  65587. * @param other defines the source matrix
  65588. * @returns the current updated matrix
  65589. */
  65590. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65591. /**
  65592. * Populates the given array from the starting index with the current matrix values
  65593. * @param array defines the target array
  65594. * @param offset defines the offset in the target array where to start storing values
  65595. * @returns the current matrix
  65596. */
  65597. copyToArray(array: Float32Array, offset?: number): Matrix;
  65598. /**
  65599. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65600. * @param other defines the second operand
  65601. * @param result defines the matrix where to store the multiplication
  65602. * @returns the current matrix
  65603. */
  65604. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65605. /**
  65606. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65607. * @param other defines the second operand
  65608. * @param result defines the array where to store the multiplication
  65609. * @param offset defines the offset in the target array where to start storing values
  65610. * @returns the current matrix
  65611. */
  65612. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65613. /**
  65614. * Check equality between this matrix and a second one
  65615. * @param value defines the second matrix to compare
  65616. * @returns true is the current matrix and the given one values are strictly equal
  65617. */
  65618. equals(value: DeepImmutable<Matrix>): boolean;
  65619. /**
  65620. * Clone the current matrix
  65621. * @returns a new matrix from the current matrix
  65622. */
  65623. clone(): Matrix;
  65624. /**
  65625. * Returns the name of the current matrix class
  65626. * @returns the string "Matrix"
  65627. */
  65628. getClassName(): string;
  65629. /**
  65630. * Gets the hash code of the current matrix
  65631. * @returns the hash code
  65632. */
  65633. getHashCode(): number;
  65634. /**
  65635. * Decomposes the current Matrix into a translation, rotation and scaling components
  65636. * @param scale defines the scale vector3 given as a reference to update
  65637. * @param rotation defines the rotation quaternion given as a reference to update
  65638. * @param translation defines the translation vector3 given as a reference to update
  65639. * @returns true if operation was successful
  65640. */
  65641. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65642. /**
  65643. * Gets specific row of the matrix
  65644. * @param index defines the number of the row to get
  65645. * @returns the index-th row of the current matrix as a new Vector4
  65646. */
  65647. getRow(index: number): Nullable<Vector4>;
  65648. /**
  65649. * Sets the index-th row of the current matrix to the vector4 values
  65650. * @param index defines the number of the row to set
  65651. * @param row defines the target vector4
  65652. * @returns the updated current matrix
  65653. */
  65654. setRow(index: number, row: Vector4): Matrix;
  65655. /**
  65656. * Compute the transpose of the matrix
  65657. * @returns the new transposed matrix
  65658. */
  65659. transpose(): Matrix;
  65660. /**
  65661. * Compute the transpose of the matrix and store it in a given matrix
  65662. * @param result defines the target matrix
  65663. * @returns the current matrix
  65664. */
  65665. transposeToRef(result: Matrix): Matrix;
  65666. /**
  65667. * Sets the index-th row of the current matrix with the given 4 x float values
  65668. * @param index defines the row index
  65669. * @param x defines the x component to set
  65670. * @param y defines the y component to set
  65671. * @param z defines the z component to set
  65672. * @param w defines the w component to set
  65673. * @returns the updated current matrix
  65674. */
  65675. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65676. /**
  65677. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65678. * @param scale defines the scale factor
  65679. * @returns a new matrix
  65680. */
  65681. scale(scale: number): Matrix;
  65682. /**
  65683. * Scale the current matrix values by a factor to a given result matrix
  65684. * @param scale defines the scale factor
  65685. * @param result defines the matrix to store the result
  65686. * @returns the current matrix
  65687. */
  65688. scaleToRef(scale: number, result: Matrix): Matrix;
  65689. /**
  65690. * Scale the current matrix values by a factor and add the result to a given matrix
  65691. * @param scale defines the scale factor
  65692. * @param result defines the Matrix to store the result
  65693. * @returns the current matrix
  65694. */
  65695. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65696. /**
  65697. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65698. * @param ref matrix to store the result
  65699. */
  65700. toNormalMatrix(ref: Matrix): void;
  65701. /**
  65702. * Gets only rotation part of the current matrix
  65703. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65704. */
  65705. getRotationMatrix(): Matrix;
  65706. /**
  65707. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65708. * @param result defines the target matrix to store data to
  65709. * @returns the current matrix
  65710. */
  65711. getRotationMatrixToRef(result: Matrix): Matrix;
  65712. /**
  65713. * Toggles model matrix from being right handed to left handed in place and vice versa
  65714. */
  65715. toggleModelMatrixHandInPlace(): void;
  65716. /**
  65717. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65718. */
  65719. toggleProjectionMatrixHandInPlace(): void;
  65720. /**
  65721. * Creates a matrix from an array
  65722. * @param array defines the source array
  65723. * @param offset defines an offset in the source array
  65724. * @returns a new Matrix set from the starting index of the given array
  65725. */
  65726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65727. /**
  65728. * Copy the content of an array into a given matrix
  65729. * @param array defines the source array
  65730. * @param offset defines an offset in the source array
  65731. * @param result defines the target matrix
  65732. */
  65733. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65734. /**
  65735. * Stores an array into a matrix after having multiplied each component by a given factor
  65736. * @param array defines the source array
  65737. * @param offset defines the offset in the source array
  65738. * @param scale defines the scaling factor
  65739. * @param result defines the target matrix
  65740. */
  65741. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65742. /**
  65743. * Gets an identity matrix that must not be updated
  65744. */
  65745. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65746. /**
  65747. * Stores a list of values (16) inside a given matrix
  65748. * @param initialM11 defines 1st value of 1st row
  65749. * @param initialM12 defines 2nd value of 1st row
  65750. * @param initialM13 defines 3rd value of 1st row
  65751. * @param initialM14 defines 4th value of 1st row
  65752. * @param initialM21 defines 1st value of 2nd row
  65753. * @param initialM22 defines 2nd value of 2nd row
  65754. * @param initialM23 defines 3rd value of 2nd row
  65755. * @param initialM24 defines 4th value of 2nd row
  65756. * @param initialM31 defines 1st value of 3rd row
  65757. * @param initialM32 defines 2nd value of 3rd row
  65758. * @param initialM33 defines 3rd value of 3rd row
  65759. * @param initialM34 defines 4th value of 3rd row
  65760. * @param initialM41 defines 1st value of 4th row
  65761. * @param initialM42 defines 2nd value of 4th row
  65762. * @param initialM43 defines 3rd value of 4th row
  65763. * @param initialM44 defines 4th value of 4th row
  65764. * @param result defines the target matrix
  65765. */
  65766. 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;
  65767. /**
  65768. * Creates new matrix from a list of values (16)
  65769. * @param initialM11 defines 1st value of 1st row
  65770. * @param initialM12 defines 2nd value of 1st row
  65771. * @param initialM13 defines 3rd value of 1st row
  65772. * @param initialM14 defines 4th value of 1st row
  65773. * @param initialM21 defines 1st value of 2nd row
  65774. * @param initialM22 defines 2nd value of 2nd row
  65775. * @param initialM23 defines 3rd value of 2nd row
  65776. * @param initialM24 defines 4th value of 2nd row
  65777. * @param initialM31 defines 1st value of 3rd row
  65778. * @param initialM32 defines 2nd value of 3rd row
  65779. * @param initialM33 defines 3rd value of 3rd row
  65780. * @param initialM34 defines 4th value of 3rd row
  65781. * @param initialM41 defines 1st value of 4th row
  65782. * @param initialM42 defines 2nd value of 4th row
  65783. * @param initialM43 defines 3rd value of 4th row
  65784. * @param initialM44 defines 4th value of 4th row
  65785. * @returns the new matrix
  65786. */
  65787. 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;
  65788. /**
  65789. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65790. * @param scale defines the scale vector3
  65791. * @param rotation defines the rotation quaternion
  65792. * @param translation defines the translation vector3
  65793. * @returns a new matrix
  65794. */
  65795. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65796. /**
  65797. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65798. * @param scale defines the scale vector3
  65799. * @param rotation defines the rotation quaternion
  65800. * @param translation defines the translation vector3
  65801. * @param result defines the target matrix
  65802. */
  65803. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65804. /**
  65805. * Creates a new identity matrix
  65806. * @returns a new identity matrix
  65807. */
  65808. static Identity(): Matrix;
  65809. /**
  65810. * Creates a new identity matrix and stores the result in a given matrix
  65811. * @param result defines the target matrix
  65812. */
  65813. static IdentityToRef(result: Matrix): void;
  65814. /**
  65815. * Creates a new zero matrix
  65816. * @returns a new zero matrix
  65817. */
  65818. static Zero(): Matrix;
  65819. /**
  65820. * Creates a new rotation matrix for "angle" radians around the X axis
  65821. * @param angle defines the angle (in radians) to use
  65822. * @return the new matrix
  65823. */
  65824. static RotationX(angle: number): Matrix;
  65825. /**
  65826. * Creates a new matrix as the invert of a given matrix
  65827. * @param source defines the source matrix
  65828. * @returns the new matrix
  65829. */
  65830. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65831. /**
  65832. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65833. * @param angle defines the angle (in radians) to use
  65834. * @param result defines the target matrix
  65835. */
  65836. static RotationXToRef(angle: number, result: Matrix): void;
  65837. /**
  65838. * Creates a new rotation matrix for "angle" radians around the Y axis
  65839. * @param angle defines the angle (in radians) to use
  65840. * @return the new matrix
  65841. */
  65842. static RotationY(angle: number): Matrix;
  65843. /**
  65844. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65845. * @param angle defines the angle (in radians) to use
  65846. * @param result defines the target matrix
  65847. */
  65848. static RotationYToRef(angle: number, result: Matrix): void;
  65849. /**
  65850. * Creates a new rotation matrix for "angle" radians around the Z axis
  65851. * @param angle defines the angle (in radians) to use
  65852. * @return the new matrix
  65853. */
  65854. static RotationZ(angle: number): Matrix;
  65855. /**
  65856. * Creates a new rotation matrix for "angle" radians around the Z 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 RotationZToRef(angle: number, result: Matrix): void;
  65861. /**
  65862. * Creates a new rotation matrix for "angle" radians around the given axis
  65863. * @param axis defines the axis to use
  65864. * @param angle defines the angle (in radians) to use
  65865. * @return the new matrix
  65866. */
  65867. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65868. /**
  65869. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65870. * @param axis defines the axis to use
  65871. * @param angle defines the angle (in radians) to use
  65872. * @param result defines the target matrix
  65873. */
  65874. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65875. /**
  65876. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65877. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65878. * @param from defines the vector to align
  65879. * @param to defines the vector to align to
  65880. * @param result defines the target matrix
  65881. */
  65882. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65883. /**
  65884. * Creates a rotation matrix
  65885. * @param yaw defines the yaw angle in radians (Y axis)
  65886. * @param pitch defines the pitch angle in radians (X axis)
  65887. * @param roll defines the roll angle in radians (X axis)
  65888. * @returns the new rotation matrix
  65889. */
  65890. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65891. /**
  65892. * Creates a rotation matrix and stores it in a given matrix
  65893. * @param yaw defines the yaw angle in radians (Y axis)
  65894. * @param pitch defines the pitch angle in radians (X axis)
  65895. * @param roll defines the roll angle in radians (X axis)
  65896. * @param result defines the target matrix
  65897. */
  65898. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65899. /**
  65900. * Creates a scaling matrix
  65901. * @param x defines the scale factor on X axis
  65902. * @param y defines the scale factor on Y axis
  65903. * @param z defines the scale factor on Z axis
  65904. * @returns the new matrix
  65905. */
  65906. static Scaling(x: number, y: number, z: number): Matrix;
  65907. /**
  65908. * Creates a scaling matrix and stores it in a given matrix
  65909. * @param x defines the scale factor on X axis
  65910. * @param y defines the scale factor on Y axis
  65911. * @param z defines the scale factor on Z axis
  65912. * @param result defines the target matrix
  65913. */
  65914. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65915. /**
  65916. * Creates a translation matrix
  65917. * @param x defines the translation on X axis
  65918. * @param y defines the translation on Y axis
  65919. * @param z defines the translationon Z axis
  65920. * @returns the new matrix
  65921. */
  65922. static Translation(x: number, y: number, z: number): Matrix;
  65923. /**
  65924. * Creates a translation matrix and stores it in a given matrix
  65925. * @param x defines the translation on X axis
  65926. * @param y defines the translation on Y axis
  65927. * @param z defines the translationon Z axis
  65928. * @param result defines the target matrix
  65929. */
  65930. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65931. /**
  65932. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65933. * @param startValue defines the start value
  65934. * @param endValue defines the end value
  65935. * @param gradient defines the gradient factor
  65936. * @returns the new matrix
  65937. */
  65938. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65939. /**
  65940. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65941. * @param startValue defines the start value
  65942. * @param endValue defines the end value
  65943. * @param gradient defines the gradient factor
  65944. * @param result defines the Matrix object where to store data
  65945. */
  65946. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65947. /**
  65948. * Builds a new matrix whose values are computed by:
  65949. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65950. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65951. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65952. * @param startValue defines the first matrix
  65953. * @param endValue defines the second matrix
  65954. * @param gradient defines the gradient between the two matrices
  65955. * @returns the new matrix
  65956. */
  65957. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65958. /**
  65959. * Update a matrix to values which are computed by:
  65960. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65961. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65962. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65963. * @param startValue defines the first matrix
  65964. * @param endValue defines the second matrix
  65965. * @param gradient defines the gradient between the two matrices
  65966. * @param result defines the target matrix
  65967. */
  65968. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65969. /**
  65970. * 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"
  65971. * This function works in left handed mode
  65972. * @param eye defines the final position of the entity
  65973. * @param target defines where the entity should look at
  65974. * @param up defines the up vector for the entity
  65975. * @returns the new matrix
  65976. */
  65977. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65978. /**
  65979. * 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".
  65980. * This function works in left handed mode
  65981. * @param eye defines the final position of the entity
  65982. * @param target defines where the entity should look at
  65983. * @param up defines the up vector for the entity
  65984. * @param result defines the target matrix
  65985. */
  65986. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65987. /**
  65988. * 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"
  65989. * This function works in right handed mode
  65990. * @param eye defines the final position of the entity
  65991. * @param target defines where the entity should look at
  65992. * @param up defines the up vector for the entity
  65993. * @returns the new matrix
  65994. */
  65995. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65996. /**
  65997. * 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".
  65998. * This function works in right handed mode
  65999. * @param eye defines the final position of the entity
  66000. * @param target defines where the entity should look at
  66001. * @param up defines the up vector for the entity
  66002. * @param result defines the target matrix
  66003. */
  66004. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  66005. /**
  66006. * Create a left-handed orthographic projection matrix
  66007. * @param width defines the viewport width
  66008. * @param height defines the viewport height
  66009. * @param znear defines the near clip plane
  66010. * @param zfar defines the far clip plane
  66011. * @returns a new matrix as a left-handed orthographic projection matrix
  66012. */
  66013. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66014. /**
  66015. * Store a left-handed orthographic projection to a given matrix
  66016. * @param width defines the viewport width
  66017. * @param height defines the viewport height
  66018. * @param znear defines the near clip plane
  66019. * @param zfar defines the far clip plane
  66020. * @param result defines the target matrix
  66021. */
  66022. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  66023. /**
  66024. * Create a left-handed orthographic projection matrix
  66025. * @param left defines the viewport left coordinate
  66026. * @param right defines the viewport right coordinate
  66027. * @param bottom defines the viewport bottom coordinate
  66028. * @param top defines the viewport top coordinate
  66029. * @param znear defines the near clip plane
  66030. * @param zfar defines the far clip plane
  66031. * @returns a new matrix as a left-handed orthographic projection matrix
  66032. */
  66033. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66034. /**
  66035. * Stores a left-handed orthographic projection into a given matrix
  66036. * @param left defines the viewport left coordinate
  66037. * @param right defines the viewport right coordinate
  66038. * @param bottom defines the viewport bottom coordinate
  66039. * @param top defines the viewport top coordinate
  66040. * @param znear defines the near clip plane
  66041. * @param zfar defines the far clip plane
  66042. * @param result defines the target matrix
  66043. */
  66044. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66045. /**
  66046. * Creates a right-handed orthographic projection matrix
  66047. * @param left defines the viewport left coordinate
  66048. * @param right defines the viewport right coordinate
  66049. * @param bottom defines the viewport bottom coordinate
  66050. * @param top defines the viewport top coordinate
  66051. * @param znear defines the near clip plane
  66052. * @param zfar defines the far clip plane
  66053. * @returns a new matrix as a right-handed orthographic projection matrix
  66054. */
  66055. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66056. /**
  66057. * Stores a right-handed orthographic projection into a given matrix
  66058. * @param left defines the viewport left coordinate
  66059. * @param right defines the viewport right coordinate
  66060. * @param bottom defines the viewport bottom coordinate
  66061. * @param top defines the viewport top coordinate
  66062. * @param znear defines the near clip plane
  66063. * @param zfar defines the far clip plane
  66064. * @param result defines the target matrix
  66065. */
  66066. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66067. /**
  66068. * Creates a left-handed perspective projection matrix
  66069. * @param width defines the viewport width
  66070. * @param height defines the viewport height
  66071. * @param znear defines the near clip plane
  66072. * @param zfar defines the far clip plane
  66073. * @returns a new matrix as a left-handed perspective projection matrix
  66074. */
  66075. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66076. /**
  66077. * Creates a left-handed perspective projection matrix
  66078. * @param fov defines the horizontal field of view
  66079. * @param aspect defines the aspect ratio
  66080. * @param znear defines the near clip plane
  66081. * @param zfar defines the far clip plane
  66082. * @returns a new matrix as a left-handed perspective projection matrix
  66083. */
  66084. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66085. /**
  66086. * Stores a left-handed perspective projection into a given matrix
  66087. * @param fov defines the horizontal field of view
  66088. * @param aspect defines the aspect ratio
  66089. * @param znear defines the near clip plane
  66090. * @param zfar defines the far clip plane
  66091. * @param result defines the target matrix
  66092. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66093. */
  66094. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66095. /**
  66096. * Creates a right-handed perspective projection matrix
  66097. * @param fov defines the horizontal field of view
  66098. * @param aspect defines the aspect ratio
  66099. * @param znear defines the near clip plane
  66100. * @param zfar defines the far clip plane
  66101. * @returns a new matrix as a right-handed perspective projection matrix
  66102. */
  66103. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66104. /**
  66105. * Stores a right-handed perspective projection into a given matrix
  66106. * @param fov defines the horizontal field of view
  66107. * @param aspect defines the aspect ratio
  66108. * @param znear defines the near clip plane
  66109. * @param zfar defines the far clip plane
  66110. * @param result defines the target matrix
  66111. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66112. */
  66113. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66114. /**
  66115. * Stores a perspective projection for WebVR info a given matrix
  66116. * @param fov defines the field of view
  66117. * @param znear defines the near clip plane
  66118. * @param zfar defines the far clip plane
  66119. * @param result defines the target matrix
  66120. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66121. */
  66122. static PerspectiveFovWebVRToRef(fov: {
  66123. upDegrees: number;
  66124. downDegrees: number;
  66125. leftDegrees: number;
  66126. rightDegrees: number;
  66127. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66128. /**
  66129. * Computes a complete transformation matrix
  66130. * @param viewport defines the viewport to use
  66131. * @param world defines the world matrix
  66132. * @param view defines the view matrix
  66133. * @param projection defines the projection matrix
  66134. * @param zmin defines the near clip plane
  66135. * @param zmax defines the far clip plane
  66136. * @returns the transformation matrix
  66137. */
  66138. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66139. /**
  66140. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66141. * @param matrix defines the matrix to use
  66142. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66143. */
  66144. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66145. /**
  66146. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66147. * @param matrix defines the matrix to use
  66148. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66149. */
  66150. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66151. /**
  66152. * Compute the transpose of a given matrix
  66153. * @param matrix defines the matrix to transpose
  66154. * @returns the new matrix
  66155. */
  66156. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66157. /**
  66158. * Compute the transpose of a matrix and store it in a target matrix
  66159. * @param matrix defines the matrix to transpose
  66160. * @param result defines the target matrix
  66161. */
  66162. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66163. /**
  66164. * Computes a reflection matrix from a plane
  66165. * @param plane defines the reflection plane
  66166. * @returns a new matrix
  66167. */
  66168. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66169. /**
  66170. * Computes a reflection matrix from a plane
  66171. * @param plane defines the reflection plane
  66172. * @param result defines the target matrix
  66173. */
  66174. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66175. /**
  66176. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66177. * @param xaxis defines the value of the 1st axis
  66178. * @param yaxis defines the value of the 2nd axis
  66179. * @param zaxis defines the value of the 3rd axis
  66180. * @param result defines the target matrix
  66181. */
  66182. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66183. /**
  66184. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66185. * @param quat defines the quaternion to use
  66186. * @param result defines the target matrix
  66187. */
  66188. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66189. }
  66190. /**
  66191. * Represens a plane by the equation ax + by + cz + d = 0
  66192. */
  66193. export class Plane {
  66194. /**
  66195. * Normal of the plane (a,b,c)
  66196. */
  66197. normal: Vector3;
  66198. /**
  66199. * d component of the plane
  66200. */
  66201. d: number;
  66202. /**
  66203. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66204. * @param a a component of the plane
  66205. * @param b b component of the plane
  66206. * @param c c component of the plane
  66207. * @param d d component of the plane
  66208. */
  66209. constructor(a: number, b: number, c: number, d: number);
  66210. /**
  66211. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66212. */
  66213. asArray(): number[];
  66214. /**
  66215. * @returns a new plane copied from the current Plane.
  66216. */
  66217. clone(): Plane;
  66218. /**
  66219. * @returns the string "Plane".
  66220. */
  66221. getClassName(): string;
  66222. /**
  66223. * @returns the Plane hash code.
  66224. */
  66225. getHashCode(): number;
  66226. /**
  66227. * Normalize the current Plane in place.
  66228. * @returns the updated Plane.
  66229. */
  66230. normalize(): Plane;
  66231. /**
  66232. * Applies a transformation the plane and returns the result
  66233. * @param transformation the transformation matrix to be applied to the plane
  66234. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66235. */
  66236. transform(transformation: DeepImmutable<Matrix>): Plane;
  66237. /**
  66238. * Calcualtte the dot product between the point and the plane normal
  66239. * @param point point to calculate the dot product with
  66240. * @returns the dot product (float) of the point coordinates and the plane normal.
  66241. */
  66242. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66243. /**
  66244. * Updates the current Plane from the plane defined by the three given points.
  66245. * @param point1 one of the points used to contruct the plane
  66246. * @param point2 one of the points used to contruct the plane
  66247. * @param point3 one of the points used to contruct the plane
  66248. * @returns the updated Plane.
  66249. */
  66250. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66251. /**
  66252. * Checks if the plane is facing a given direction
  66253. * @param direction the direction to check if the plane is facing
  66254. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66255. * @returns True is the vector "direction" is the same side than the plane normal.
  66256. */
  66257. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66258. /**
  66259. * Calculates the distance to a point
  66260. * @param point point to calculate distance to
  66261. * @returns the signed distance (float) from the given point to the Plane.
  66262. */
  66263. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66264. /**
  66265. * Creates a plane from an array
  66266. * @param array the array to create a plane from
  66267. * @returns a new Plane from the given array.
  66268. */
  66269. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66270. /**
  66271. * Creates a plane from three points
  66272. * @param point1 point used to create the plane
  66273. * @param point2 point used to create the plane
  66274. * @param point3 point used to create the plane
  66275. * @returns a new Plane defined by the three given points.
  66276. */
  66277. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66278. /**
  66279. * Creates a plane from an origin point and a normal
  66280. * @param origin origin of the plane to be constructed
  66281. * @param normal normal of the plane to be constructed
  66282. * @returns a new Plane the normal vector to this plane at the given origin point.
  66283. * Note : the vector "normal" is updated because normalized.
  66284. */
  66285. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66286. /**
  66287. * Calculates the distance from a plane and a point
  66288. * @param origin origin of the plane to be constructed
  66289. * @param normal normal of the plane to be constructed
  66290. * @param point point to calculate distance to
  66291. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66292. */
  66293. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66294. }
  66295. /**
  66296. * Class used to represent a viewport on screen
  66297. */
  66298. export class Viewport {
  66299. /** viewport left coordinate */
  66300. x: number;
  66301. /** viewport top coordinate */
  66302. y: number;
  66303. /**viewport width */
  66304. width: number;
  66305. /** viewport height */
  66306. height: number;
  66307. /**
  66308. * Creates a Viewport object located at (x, y) and sized (width, height)
  66309. * @param x defines viewport left coordinate
  66310. * @param y defines viewport top coordinate
  66311. * @param width defines the viewport width
  66312. * @param height defines the viewport height
  66313. */
  66314. constructor(
  66315. /** viewport left coordinate */
  66316. x: number,
  66317. /** viewport top coordinate */
  66318. y: number,
  66319. /**viewport width */
  66320. width: number,
  66321. /** viewport height */
  66322. height: number);
  66323. /**
  66324. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66325. * @param renderWidth defines the rendering width
  66326. * @param renderHeight defines the rendering height
  66327. * @returns a new Viewport
  66328. */
  66329. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66330. /**
  66331. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66332. * @param renderWidth defines the rendering width
  66333. * @param renderHeight defines the rendering height
  66334. * @param ref defines the target viewport
  66335. * @returns the current viewport
  66336. */
  66337. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66338. /**
  66339. * Returns a new Viewport copied from the current one
  66340. * @returns a new Viewport
  66341. */
  66342. clone(): Viewport;
  66343. }
  66344. /**
  66345. * Reprasents a camera frustum
  66346. */
  66347. export class Frustum {
  66348. /**
  66349. * Gets the planes representing the frustum
  66350. * @param transform matrix to be applied to the returned planes
  66351. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66352. */
  66353. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66354. /**
  66355. * Gets the near frustum plane transformed by the transform matrix
  66356. * @param transform transformation matrix to be applied to the resulting frustum plane
  66357. * @param frustumPlane the resuling frustum plane
  66358. */
  66359. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66360. /**
  66361. * Gets the far frustum plane transformed by the transform matrix
  66362. * @param transform transformation matrix to be applied to the resulting frustum plane
  66363. * @param frustumPlane the resuling frustum plane
  66364. */
  66365. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66366. /**
  66367. * Gets the left frustum plane transformed by the transform matrix
  66368. * @param transform transformation matrix to be applied to the resulting frustum plane
  66369. * @param frustumPlane the resuling frustum plane
  66370. */
  66371. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66372. /**
  66373. * Gets the right frustum plane transformed by the transform matrix
  66374. * @param transform transformation matrix to be applied to the resulting frustum plane
  66375. * @param frustumPlane the resuling frustum plane
  66376. */
  66377. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66378. /**
  66379. * Gets the top 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 GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66384. /**
  66385. * Gets the bottom 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 GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66390. /**
  66391. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66392. * @param transform transformation matrix to be applied to the resulting frustum planes
  66393. * @param frustumPlanes the resuling frustum planes
  66394. */
  66395. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66396. }
  66397. /** Defines supported spaces */
  66398. export enum Space {
  66399. /** Local (object) space */
  66400. LOCAL = 0,
  66401. /** World space */
  66402. WORLD = 1,
  66403. /** Bone space */
  66404. BONE = 2
  66405. }
  66406. /** Defines the 3 main axes */
  66407. export class Axis {
  66408. /** X axis */
  66409. static X: Vector3;
  66410. /** Y axis */
  66411. static Y: Vector3;
  66412. /** Z axis */
  66413. static Z: Vector3;
  66414. }
  66415. /** Class used to represent a Bezier curve */
  66416. export class BezierCurve {
  66417. /**
  66418. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66419. * @param t defines the time
  66420. * @param x1 defines the left coordinate on X axis
  66421. * @param y1 defines the left coordinate on Y axis
  66422. * @param x2 defines the right coordinate on X axis
  66423. * @param y2 defines the right coordinate on Y axis
  66424. * @returns the interpolated value
  66425. */
  66426. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66427. }
  66428. /**
  66429. * Defines potential orientation for back face culling
  66430. */
  66431. export enum Orientation {
  66432. /**
  66433. * Clockwise
  66434. */
  66435. CW = 0,
  66436. /** Counter clockwise */
  66437. CCW = 1
  66438. }
  66439. /**
  66440. * Defines angle representation
  66441. */
  66442. export class Angle {
  66443. private _radians;
  66444. /**
  66445. * Creates an Angle object of "radians" radians (float).
  66446. * @param radians the angle in radians
  66447. */
  66448. constructor(radians: number);
  66449. /**
  66450. * Get value in degrees
  66451. * @returns the Angle value in degrees (float)
  66452. */
  66453. degrees(): number;
  66454. /**
  66455. * Get value in radians
  66456. * @returns the Angle value in radians (float)
  66457. */
  66458. radians(): number;
  66459. /**
  66460. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66461. * @param a defines first vector
  66462. * @param b defines second vector
  66463. * @returns a new Angle
  66464. */
  66465. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66466. /**
  66467. * Gets a new Angle object from the given float in radians
  66468. * @param radians defines the angle value in radians
  66469. * @returns a new Angle
  66470. */
  66471. static FromRadians(radians: number): Angle;
  66472. /**
  66473. * Gets a new Angle object from the given float in degrees
  66474. * @param degrees defines the angle value in degrees
  66475. * @returns a new Angle
  66476. */
  66477. static FromDegrees(degrees: number): Angle;
  66478. }
  66479. /**
  66480. * This represents an arc in a 2d space.
  66481. */
  66482. export class Arc2 {
  66483. /** Defines the start point of the arc */
  66484. startPoint: Vector2;
  66485. /** Defines the mid point of the arc */
  66486. midPoint: Vector2;
  66487. /** Defines the end point of the arc */
  66488. endPoint: Vector2;
  66489. /**
  66490. * Defines the center point of the arc.
  66491. */
  66492. centerPoint: Vector2;
  66493. /**
  66494. * Defines the radius of the arc.
  66495. */
  66496. radius: number;
  66497. /**
  66498. * Defines the angle of the arc (from mid point to end point).
  66499. */
  66500. angle: Angle;
  66501. /**
  66502. * Defines the start angle of the arc (from start point to middle point).
  66503. */
  66504. startAngle: Angle;
  66505. /**
  66506. * Defines the orientation of the arc (clock wise/counter clock wise).
  66507. */
  66508. orientation: Orientation;
  66509. /**
  66510. * Creates an Arc object from the three given points : start, middle and end.
  66511. * @param startPoint Defines the start point of the arc
  66512. * @param midPoint Defines the midlle point of the arc
  66513. * @param endPoint Defines the end point of the arc
  66514. */
  66515. constructor(
  66516. /** Defines the start point of the arc */
  66517. startPoint: Vector2,
  66518. /** Defines the mid point of the arc */
  66519. midPoint: Vector2,
  66520. /** Defines the end point of the arc */
  66521. endPoint: Vector2);
  66522. }
  66523. /**
  66524. * Represents a 2D path made up of multiple 2D points
  66525. */
  66526. export class Path2 {
  66527. private _points;
  66528. private _length;
  66529. /**
  66530. * If the path start and end point are the same
  66531. */
  66532. closed: boolean;
  66533. /**
  66534. * Creates a Path2 object from the starting 2D coordinates x and y.
  66535. * @param x the starting points x value
  66536. * @param y the starting points y value
  66537. */
  66538. constructor(x: number, y: number);
  66539. /**
  66540. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66541. * @param x the added points x value
  66542. * @param y the added points y value
  66543. * @returns the updated Path2.
  66544. */
  66545. addLineTo(x: number, y: number): Path2;
  66546. /**
  66547. * 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.
  66548. * @param midX middle point x value
  66549. * @param midY middle point y value
  66550. * @param endX end point x value
  66551. * @param endY end point y value
  66552. * @param numberOfSegments (default: 36)
  66553. * @returns the updated Path2.
  66554. */
  66555. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66556. /**
  66557. * Closes the Path2.
  66558. * @returns the Path2.
  66559. */
  66560. close(): Path2;
  66561. /**
  66562. * Gets the sum of the distance between each sequential point in the path
  66563. * @returns the Path2 total length (float).
  66564. */
  66565. length(): number;
  66566. /**
  66567. * Gets the points which construct the path
  66568. * @returns the Path2 internal array of points.
  66569. */
  66570. getPoints(): Vector2[];
  66571. /**
  66572. * Retreives the point at the distance aways from the starting point
  66573. * @param normalizedLengthPosition the length along the path to retreive the point from
  66574. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66575. */
  66576. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66577. /**
  66578. * Creates a new path starting from an x and y position
  66579. * @param x starting x value
  66580. * @param y starting y value
  66581. * @returns a new Path2 starting at the coordinates (x, y).
  66582. */
  66583. static StartingAt(x: number, y: number): Path2;
  66584. }
  66585. /**
  66586. * Represents a 3D path made up of multiple 3D points
  66587. */
  66588. export class Path3D {
  66589. /**
  66590. * an array of Vector3, the curve axis of the Path3D
  66591. */
  66592. path: Vector3[];
  66593. private _curve;
  66594. private _distances;
  66595. private _tangents;
  66596. private _normals;
  66597. private _binormals;
  66598. private _raw;
  66599. /**
  66600. * new Path3D(path, normal, raw)
  66601. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66602. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66603. * @param path an array of Vector3, the curve axis of the Path3D
  66604. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66605. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66606. */
  66607. constructor(
  66608. /**
  66609. * an array of Vector3, the curve axis of the Path3D
  66610. */
  66611. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66612. /**
  66613. * Returns the Path3D array of successive Vector3 designing its curve.
  66614. * @returns the Path3D array of successive Vector3 designing its curve.
  66615. */
  66616. getCurve(): Vector3[];
  66617. /**
  66618. * Returns an array populated with tangent vectors on each Path3D curve point.
  66619. * @returns an array populated with tangent vectors on each Path3D curve point.
  66620. */
  66621. getTangents(): Vector3[];
  66622. /**
  66623. * Returns an array populated with normal vectors on each Path3D curve point.
  66624. * @returns an array populated with normal vectors on each Path3D curve point.
  66625. */
  66626. getNormals(): Vector3[];
  66627. /**
  66628. * Returns an array populated with binormal vectors on each Path3D curve point.
  66629. * @returns an array populated with binormal vectors on each Path3D curve point.
  66630. */
  66631. getBinormals(): Vector3[];
  66632. /**
  66633. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66634. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66635. */
  66636. getDistances(): number[];
  66637. /**
  66638. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66639. * @param path path which all values are copied into the curves points
  66640. * @param firstNormal which should be projected onto the curve
  66641. * @returns the same object updated.
  66642. */
  66643. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66644. private _compute;
  66645. private _getFirstNonNullVector;
  66646. private _getLastNonNullVector;
  66647. private _normalVector;
  66648. }
  66649. /**
  66650. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66651. * A Curve3 is designed from a series of successive Vector3.
  66652. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66653. */
  66654. export class Curve3 {
  66655. private _points;
  66656. private _length;
  66657. /**
  66658. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66659. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66660. * @param v1 (Vector3) the control point
  66661. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66662. * @param nbPoints (integer) the wanted number of points in the curve
  66663. * @returns the created Curve3
  66664. */
  66665. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66666. /**
  66667. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66668. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66669. * @param v1 (Vector3) the first control point
  66670. * @param v2 (Vector3) the second control point
  66671. * @param v3 (Vector3) the end point of the Cubic Bezier
  66672. * @param nbPoints (integer) the wanted number of points in the curve
  66673. * @returns the created Curve3
  66674. */
  66675. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66676. /**
  66677. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66678. * @param p1 (Vector3) the origin point of the Hermite Spline
  66679. * @param t1 (Vector3) the tangent vector at the origin point
  66680. * @param p2 (Vector3) the end point of the Hermite Spline
  66681. * @param t2 (Vector3) the tangent vector at the end point
  66682. * @param nbPoints (integer) the wanted number of points in the curve
  66683. * @returns the created Curve3
  66684. */
  66685. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66686. /**
  66687. * Returns a Curve3 object along a CatmullRom Spline curve :
  66688. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66689. * @param nbPoints (integer) the wanted number of points between each curve control points
  66690. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66691. * @returns the created Curve3
  66692. */
  66693. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66694. /**
  66695. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66696. * A Curve3 is designed from a series of successive Vector3.
  66697. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66698. * @param points points which make up the curve
  66699. */
  66700. constructor(points: Vector3[]);
  66701. /**
  66702. * @returns the Curve3 stored array of successive Vector3
  66703. */
  66704. getPoints(): Vector3[];
  66705. /**
  66706. * @returns the computed length (float) of the curve.
  66707. */
  66708. length(): number;
  66709. /**
  66710. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66711. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66712. * curveA and curveB keep unchanged.
  66713. * @param curve the curve to continue from this curve
  66714. * @returns the newly constructed curve
  66715. */
  66716. continue(curve: DeepImmutable<Curve3>): Curve3;
  66717. private _computeLength;
  66718. }
  66719. /**
  66720. * Contains position and normal vectors for a vertex
  66721. */
  66722. export class PositionNormalVertex {
  66723. /** the position of the vertex (defaut: 0,0,0) */
  66724. position: Vector3;
  66725. /** the normal of the vertex (defaut: 0,1,0) */
  66726. normal: Vector3;
  66727. /**
  66728. * Creates a PositionNormalVertex
  66729. * @param position the position of the vertex (defaut: 0,0,0)
  66730. * @param normal the normal of the vertex (defaut: 0,1,0)
  66731. */
  66732. constructor(
  66733. /** the position of the vertex (defaut: 0,0,0) */
  66734. position?: Vector3,
  66735. /** the normal of the vertex (defaut: 0,1,0) */
  66736. normal?: Vector3);
  66737. /**
  66738. * Clones the PositionNormalVertex
  66739. * @returns the cloned PositionNormalVertex
  66740. */
  66741. clone(): PositionNormalVertex;
  66742. }
  66743. /**
  66744. * Contains position, normal and uv vectors for a vertex
  66745. */
  66746. export class PositionNormalTextureVertex {
  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. /** the uv of the vertex (default: 0,0) */
  66752. uv: Vector2;
  66753. /**
  66754. * Creates a PositionNormalTextureVertex
  66755. * @param position the position of the vertex (defaut: 0,0,0)
  66756. * @param normal the normal of the vertex (defaut: 0,1,0)
  66757. * @param uv the uv of the vertex (default: 0,0)
  66758. */
  66759. constructor(
  66760. /** the position of the vertex (defaut: 0,0,0) */
  66761. position?: Vector3,
  66762. /** the normal of the vertex (defaut: 0,1,0) */
  66763. normal?: Vector3,
  66764. /** the uv of the vertex (default: 0,0) */
  66765. uv?: Vector2);
  66766. /**
  66767. * Clones the PositionNormalTextureVertex
  66768. * @returns the cloned PositionNormalTextureVertex
  66769. */
  66770. clone(): PositionNormalTextureVertex;
  66771. }
  66772. /**
  66773. * @hidden
  66774. */
  66775. export class Tmp {
  66776. static Color3: Color3[];
  66777. static Color4: Color4[];
  66778. static Vector2: Vector2[];
  66779. static Vector3: Vector3[];
  66780. static Vector4: Vector4[];
  66781. static Quaternion: Quaternion[];
  66782. static Matrix: Matrix[];
  66783. }
  66784. }
  66785. declare module BABYLON {
  66786. /**
  66787. * Class used to enable access to offline support
  66788. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66789. */
  66790. export interface IOfflineProvider {
  66791. /**
  66792. * Gets a boolean indicating if scene must be saved in the database
  66793. */
  66794. enableSceneOffline: boolean;
  66795. /**
  66796. * Gets a boolean indicating if textures must be saved in the database
  66797. */
  66798. enableTexturesOffline: boolean;
  66799. /**
  66800. * Open the offline support and make it available
  66801. * @param successCallback defines the callback to call on success
  66802. * @param errorCallback defines the callback to call on error
  66803. */
  66804. open(successCallback: () => void, errorCallback: () => void): void;
  66805. /**
  66806. * Loads an image from the offline support
  66807. * @param url defines the url to load from
  66808. * @param image defines the target DOM image
  66809. */
  66810. loadImage(url: string, image: HTMLImageElement): void;
  66811. /**
  66812. * Loads a file from offline support
  66813. * @param url defines the URL to load from
  66814. * @param sceneLoaded defines a callback to call on success
  66815. * @param progressCallBack defines a callback to call when progress changed
  66816. * @param errorCallback defines a callback to call on error
  66817. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66818. */
  66819. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66820. }
  66821. }
  66822. declare module BABYLON {
  66823. /**
  66824. * A class serves as a medium between the observable and its observers
  66825. */
  66826. export class EventState {
  66827. /**
  66828. * Create a new EventState
  66829. * @param mask defines the mask associated with this state
  66830. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66831. * @param target defines the original target of the state
  66832. * @param currentTarget defines the current target of the state
  66833. */
  66834. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66835. /**
  66836. * Initialize the current event state
  66837. * @param mask defines the mask associated with this state
  66838. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66839. * @param target defines the original target of the state
  66840. * @param currentTarget defines the current target of the state
  66841. * @returns the current event state
  66842. */
  66843. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66844. /**
  66845. * An Observer can set this property to true to prevent subsequent observers of being notified
  66846. */
  66847. skipNextObservers: boolean;
  66848. /**
  66849. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66850. */
  66851. mask: number;
  66852. /**
  66853. * The object that originally notified the event
  66854. */
  66855. target?: any;
  66856. /**
  66857. * The current object in the bubbling phase
  66858. */
  66859. currentTarget?: any;
  66860. /**
  66861. * This will be populated with the return value of the last function that was executed.
  66862. * If it is the first function in the callback chain it will be the event data.
  66863. */
  66864. lastReturnValue?: any;
  66865. }
  66866. /**
  66867. * Represent an Observer registered to a given Observable object.
  66868. */
  66869. export class Observer<T> {
  66870. /**
  66871. * Defines the callback to call when the observer is notified
  66872. */
  66873. callback: (eventData: T, eventState: EventState) => void;
  66874. /**
  66875. * Defines the mask of the observer (used to filter notifications)
  66876. */
  66877. mask: number;
  66878. /**
  66879. * Defines the current scope used to restore the JS context
  66880. */
  66881. scope: any;
  66882. /** @hidden */
  66883. _willBeUnregistered: boolean;
  66884. /**
  66885. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66886. */
  66887. unregisterOnNextCall: boolean;
  66888. /**
  66889. * Creates a new observer
  66890. * @param callback defines the callback to call when the observer is notified
  66891. * @param mask defines the mask of the observer (used to filter notifications)
  66892. * @param scope defines the current scope used to restore the JS context
  66893. */
  66894. constructor(
  66895. /**
  66896. * Defines the callback to call when the observer is notified
  66897. */
  66898. callback: (eventData: T, eventState: EventState) => void,
  66899. /**
  66900. * Defines the mask of the observer (used to filter notifications)
  66901. */
  66902. mask: number,
  66903. /**
  66904. * Defines the current scope used to restore the JS context
  66905. */
  66906. scope?: any);
  66907. }
  66908. /**
  66909. * Represent a list of observers registered to multiple Observables object.
  66910. */
  66911. export class MultiObserver<T> {
  66912. private _observers;
  66913. private _observables;
  66914. /**
  66915. * Release associated resources
  66916. */
  66917. dispose(): void;
  66918. /**
  66919. * Raise a callback when one of the observable will notify
  66920. * @param observables defines a list of observables to watch
  66921. * @param callback defines the callback to call on notification
  66922. * @param mask defines the mask used to filter notifications
  66923. * @param scope defines the current scope used to restore the JS context
  66924. * @returns the new MultiObserver
  66925. */
  66926. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66927. }
  66928. /**
  66929. * The Observable class is a simple implementation of the Observable pattern.
  66930. *
  66931. * 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.
  66932. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66933. * 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).
  66934. * 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.
  66935. */
  66936. export class Observable<T> {
  66937. private _observers;
  66938. private _eventState;
  66939. private _onObserverAdded;
  66940. /**
  66941. * Gets the list of observers
  66942. */
  66943. readonly observers: Array<Observer<T>>;
  66944. /**
  66945. * Creates a new observable
  66946. * @param onObserverAdded defines a callback to call when a new observer is added
  66947. */
  66948. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66949. /**
  66950. * Create a new Observer with the specified callback
  66951. * @param callback the callback that will be executed for that Observer
  66952. * @param mask the mask used to filter observers
  66953. * @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.
  66954. * @param scope optional scope for the callback to be called from
  66955. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66956. * @returns the new observer created for the callback
  66957. */
  66958. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66959. /**
  66960. * Create a new Observer with the specified callback and unregisters after the next notification
  66961. * @param callback the callback that will be executed for that Observer
  66962. * @returns the new observer created for the callback
  66963. */
  66964. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66965. /**
  66966. * Remove an Observer from the Observable object
  66967. * @param observer the instance of the Observer to remove
  66968. * @returns false if it doesn't belong to this Observable
  66969. */
  66970. remove(observer: Nullable<Observer<T>>): boolean;
  66971. /**
  66972. * Remove a callback from the Observable object
  66973. * @param callback the callback to remove
  66974. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66975. * @returns false if it doesn't belong to this Observable
  66976. */
  66977. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66978. private _deferUnregister;
  66979. private _remove;
  66980. /**
  66981. * Moves the observable to the top of the observer list making it get called first when notified
  66982. * @param observer the observer to move
  66983. */
  66984. makeObserverTopPriority(observer: Observer<T>): void;
  66985. /**
  66986. * Moves the observable to the bottom of the observer list making it get called last when notified
  66987. * @param observer the observer to move
  66988. */
  66989. makeObserverBottomPriority(observer: Observer<T>): void;
  66990. /**
  66991. * Notify all Observers by calling their respective callback with the given data
  66992. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66993. * @param eventData defines the data to send to all observers
  66994. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66995. * @param target defines the original target of the state
  66996. * @param currentTarget defines the current target of the state
  66997. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66998. */
  66999. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67000. /**
  67001. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67002. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67003. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67004. * and it is crucial that all callbacks will be executed.
  67005. * The order of the callbacks is kept, callbacks are not executed parallel.
  67006. *
  67007. * @param eventData The data to be sent to each callback
  67008. * @param mask is used to filter observers defaults to -1
  67009. * @param target defines the callback target (see EventState)
  67010. * @param currentTarget defines he current object in the bubbling phase
  67011. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67012. */
  67013. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67014. /**
  67015. * Notify a specific observer
  67016. * @param observer defines the observer to notify
  67017. * @param eventData defines the data to be sent to each callback
  67018. * @param mask is used to filter observers defaults to -1
  67019. */
  67020. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67021. /**
  67022. * Gets a boolean indicating if the observable has at least one observer
  67023. * @returns true is the Observable has at least one Observer registered
  67024. */
  67025. hasObservers(): boolean;
  67026. /**
  67027. * Clear the list of observers
  67028. */
  67029. clear(): void;
  67030. /**
  67031. * Clone the current observable
  67032. * @returns a new observable
  67033. */
  67034. clone(): Observable<T>;
  67035. /**
  67036. * Does this observable handles observer registered with a given mask
  67037. * @param mask defines the mask to be tested
  67038. * @return whether or not one observer registered with the given mask is handeled
  67039. **/
  67040. hasSpecificMask(mask?: number): boolean;
  67041. }
  67042. }
  67043. declare module BABYLON {
  67044. /**
  67045. * Class used to help managing file picking and drag'n'drop
  67046. * File Storage
  67047. */
  67048. export class FilesInputStore {
  67049. /**
  67050. * List of files ready to be loaded
  67051. */
  67052. static FilesToLoad: {
  67053. [key: string]: File;
  67054. };
  67055. }
  67056. }
  67057. declare module BABYLON {
  67058. /** Defines the cross module used constants to avoid circular dependncies */
  67059. export class Constants {
  67060. /** Defines that alpha blending is disabled */
  67061. static readonly ALPHA_DISABLE: number;
  67062. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67063. static readonly ALPHA_ADD: number;
  67064. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67065. static readonly ALPHA_COMBINE: number;
  67066. /** Defines that alpha blending to DEST - SRC * DEST */
  67067. static readonly ALPHA_SUBTRACT: number;
  67068. /** Defines that alpha blending to SRC * DEST */
  67069. static readonly ALPHA_MULTIPLY: number;
  67070. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67071. static readonly ALPHA_MAXIMIZED: number;
  67072. /** Defines that alpha blending to SRC + DEST */
  67073. static readonly ALPHA_ONEONE: number;
  67074. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67075. static readonly ALPHA_PREMULTIPLIED: number;
  67076. /**
  67077. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67078. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67079. */
  67080. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67081. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67082. static readonly ALPHA_INTERPOLATE: number;
  67083. /**
  67084. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67085. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67086. */
  67087. static readonly ALPHA_SCREENMODE: number;
  67088. /** Defines that the ressource is not delayed*/
  67089. static readonly DELAYLOADSTATE_NONE: number;
  67090. /** Defines that the ressource was successfully delay loaded */
  67091. static readonly DELAYLOADSTATE_LOADED: number;
  67092. /** Defines that the ressource is currently delay loading */
  67093. static readonly DELAYLOADSTATE_LOADING: number;
  67094. /** Defines that the ressource is delayed and has not started loading */
  67095. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67097. static readonly NEVER: number;
  67098. /** 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 */
  67099. static readonly ALWAYS: number;
  67100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67101. static readonly LESS: number;
  67102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67103. static readonly EQUAL: number;
  67104. /** 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 */
  67105. static readonly LEQUAL: number;
  67106. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67107. static readonly GREATER: number;
  67108. /** 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 */
  67109. static readonly GEQUAL: number;
  67110. /** 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 */
  67111. static readonly NOTEQUAL: number;
  67112. /** Passed to stencilOperation to specify that stencil value must be kept */
  67113. static readonly KEEP: number;
  67114. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67115. static readonly REPLACE: number;
  67116. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67117. static readonly INCR: number;
  67118. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67119. static readonly DECR: number;
  67120. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67121. static readonly INVERT: number;
  67122. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67123. static readonly INCR_WRAP: number;
  67124. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67125. static readonly DECR_WRAP: number;
  67126. /** Texture is not repeating outside of 0..1 UVs */
  67127. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67128. /** Texture is repeating outside of 0..1 UVs */
  67129. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67130. /** Texture is repeating and mirrored */
  67131. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67132. /** ALPHA */
  67133. static readonly TEXTUREFORMAT_ALPHA: number;
  67134. /** LUMINANCE */
  67135. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67136. /** LUMINANCE_ALPHA */
  67137. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67138. /** RGB */
  67139. static readonly TEXTUREFORMAT_RGB: number;
  67140. /** RGBA */
  67141. static readonly TEXTUREFORMAT_RGBA: number;
  67142. /** RED */
  67143. static readonly TEXTUREFORMAT_RED: number;
  67144. /** RED (2nd reference) */
  67145. static readonly TEXTUREFORMAT_R: number;
  67146. /** RG */
  67147. static readonly TEXTUREFORMAT_RG: number;
  67148. /** RED_INTEGER */
  67149. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67150. /** RED_INTEGER (2nd reference) */
  67151. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67152. /** RG_INTEGER */
  67153. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67154. /** RGB_INTEGER */
  67155. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67156. /** RGBA_INTEGER */
  67157. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67158. /** UNSIGNED_BYTE */
  67159. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67160. /** UNSIGNED_BYTE (2nd reference) */
  67161. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67162. /** FLOAT */
  67163. static readonly TEXTURETYPE_FLOAT: number;
  67164. /** HALF_FLOAT */
  67165. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67166. /** BYTE */
  67167. static readonly TEXTURETYPE_BYTE: number;
  67168. /** SHORT */
  67169. static readonly TEXTURETYPE_SHORT: number;
  67170. /** UNSIGNED_SHORT */
  67171. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67172. /** INT */
  67173. static readonly TEXTURETYPE_INT: number;
  67174. /** UNSIGNED_INT */
  67175. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67176. /** UNSIGNED_SHORT_4_4_4_4 */
  67177. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67178. /** UNSIGNED_SHORT_5_5_5_1 */
  67179. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67180. /** UNSIGNED_SHORT_5_6_5 */
  67181. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67182. /** UNSIGNED_INT_2_10_10_10_REV */
  67183. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67184. /** UNSIGNED_INT_24_8 */
  67185. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67186. /** UNSIGNED_INT_10F_11F_11F_REV */
  67187. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67188. /** UNSIGNED_INT_5_9_9_9_REV */
  67189. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67190. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67191. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67192. /** nearest is mag = nearest and min = nearest and mip = linear */
  67193. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67194. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67195. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67196. /** Trilinear is mag = linear and min = linear and mip = linear */
  67197. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67198. /** nearest is mag = nearest and min = nearest and mip = linear */
  67199. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67200. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67201. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67202. /** Trilinear is mag = linear and min = linear and mip = linear */
  67203. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67204. /** mag = nearest and min = nearest and mip = nearest */
  67205. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67206. /** mag = nearest and min = linear and mip = nearest */
  67207. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67208. /** mag = nearest and min = linear and mip = linear */
  67209. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67210. /** mag = nearest and min = linear and mip = none */
  67211. static readonly TEXTURE_NEAREST_LINEAR: number;
  67212. /** mag = nearest and min = nearest and mip = none */
  67213. static readonly TEXTURE_NEAREST_NEAREST: number;
  67214. /** mag = linear and min = nearest and mip = nearest */
  67215. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67216. /** mag = linear and min = nearest and mip = linear */
  67217. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67218. /** mag = linear and min = linear and mip = none */
  67219. static readonly TEXTURE_LINEAR_LINEAR: number;
  67220. /** mag = linear and min = nearest and mip = none */
  67221. static readonly TEXTURE_LINEAR_NEAREST: number;
  67222. /** Explicit coordinates mode */
  67223. static readonly TEXTURE_EXPLICIT_MODE: number;
  67224. /** Spherical coordinates mode */
  67225. static readonly TEXTURE_SPHERICAL_MODE: number;
  67226. /** Planar coordinates mode */
  67227. static readonly TEXTURE_PLANAR_MODE: number;
  67228. /** Cubic coordinates mode */
  67229. static readonly TEXTURE_CUBIC_MODE: number;
  67230. /** Projection coordinates mode */
  67231. static readonly TEXTURE_PROJECTION_MODE: number;
  67232. /** Skybox coordinates mode */
  67233. static readonly TEXTURE_SKYBOX_MODE: number;
  67234. /** Inverse Cubic coordinates mode */
  67235. static readonly TEXTURE_INVCUBIC_MODE: number;
  67236. /** Equirectangular coordinates mode */
  67237. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67238. /** Equirectangular Fixed coordinates mode */
  67239. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67240. /** Equirectangular Fixed Mirrored coordinates mode */
  67241. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67242. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67243. static readonly SCALEMODE_FLOOR: number;
  67244. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67245. static readonly SCALEMODE_NEAREST: number;
  67246. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67247. static readonly SCALEMODE_CEILING: number;
  67248. /**
  67249. * The dirty texture flag value
  67250. */
  67251. static readonly MATERIAL_TextureDirtyFlag: number;
  67252. /**
  67253. * The dirty light flag value
  67254. */
  67255. static readonly MATERIAL_LightDirtyFlag: number;
  67256. /**
  67257. * The dirty fresnel flag value
  67258. */
  67259. static readonly MATERIAL_FresnelDirtyFlag: number;
  67260. /**
  67261. * The dirty attribute flag value
  67262. */
  67263. static readonly MATERIAL_AttributesDirtyFlag: number;
  67264. /**
  67265. * The dirty misc flag value
  67266. */
  67267. static readonly MATERIAL_MiscDirtyFlag: number;
  67268. /**
  67269. * The all dirty flag value
  67270. */
  67271. static readonly MATERIAL_AllDirtyFlag: number;
  67272. /**
  67273. * Returns the triangle fill mode
  67274. */
  67275. static readonly MATERIAL_TriangleFillMode: number;
  67276. /**
  67277. * Returns the wireframe mode
  67278. */
  67279. static readonly MATERIAL_WireFrameFillMode: number;
  67280. /**
  67281. * Returns the point fill mode
  67282. */
  67283. static readonly MATERIAL_PointFillMode: number;
  67284. /**
  67285. * Returns the point list draw mode
  67286. */
  67287. static readonly MATERIAL_PointListDrawMode: number;
  67288. /**
  67289. * Returns the line list draw mode
  67290. */
  67291. static readonly MATERIAL_LineListDrawMode: number;
  67292. /**
  67293. * Returns the line loop draw mode
  67294. */
  67295. static readonly MATERIAL_LineLoopDrawMode: number;
  67296. /**
  67297. * Returns the line strip draw mode
  67298. */
  67299. static readonly MATERIAL_LineStripDrawMode: number;
  67300. /**
  67301. * Returns the triangle strip draw mode
  67302. */
  67303. static readonly MATERIAL_TriangleStripDrawMode: number;
  67304. /**
  67305. * Returns the triangle fan draw mode
  67306. */
  67307. static readonly MATERIAL_TriangleFanDrawMode: number;
  67308. /**
  67309. * Stores the clock-wise side orientation
  67310. */
  67311. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67312. /**
  67313. * Stores the counter clock-wise side orientation
  67314. */
  67315. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67316. /**
  67317. * Nothing
  67318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67319. */
  67320. static readonly ACTION_NothingTrigger: number;
  67321. /**
  67322. * On pick
  67323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67324. */
  67325. static readonly ACTION_OnPickTrigger: number;
  67326. /**
  67327. * On left pick
  67328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67329. */
  67330. static readonly ACTION_OnLeftPickTrigger: number;
  67331. /**
  67332. * On right pick
  67333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67334. */
  67335. static readonly ACTION_OnRightPickTrigger: number;
  67336. /**
  67337. * On center pick
  67338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67339. */
  67340. static readonly ACTION_OnCenterPickTrigger: number;
  67341. /**
  67342. * On pick down
  67343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67344. */
  67345. static readonly ACTION_OnPickDownTrigger: number;
  67346. /**
  67347. * On double pick
  67348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67349. */
  67350. static readonly ACTION_OnDoublePickTrigger: number;
  67351. /**
  67352. * On pick up
  67353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67354. */
  67355. static readonly ACTION_OnPickUpTrigger: number;
  67356. /**
  67357. * On pick out.
  67358. * This trigger will only be raised if you also declared a OnPickDown
  67359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67360. */
  67361. static readonly ACTION_OnPickOutTrigger: number;
  67362. /**
  67363. * On long press
  67364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67365. */
  67366. static readonly ACTION_OnLongPressTrigger: number;
  67367. /**
  67368. * On pointer over
  67369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67370. */
  67371. static readonly ACTION_OnPointerOverTrigger: number;
  67372. /**
  67373. * On pointer out
  67374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67375. */
  67376. static readonly ACTION_OnPointerOutTrigger: number;
  67377. /**
  67378. * On every frame
  67379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67380. */
  67381. static readonly ACTION_OnEveryFrameTrigger: number;
  67382. /**
  67383. * On intersection enter
  67384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67385. */
  67386. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67387. /**
  67388. * On intersection exit
  67389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67390. */
  67391. static readonly ACTION_OnIntersectionExitTrigger: number;
  67392. /**
  67393. * On key down
  67394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67395. */
  67396. static readonly ACTION_OnKeyDownTrigger: number;
  67397. /**
  67398. * On key up
  67399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67400. */
  67401. static readonly ACTION_OnKeyUpTrigger: number;
  67402. /**
  67403. * Billboard mode will only apply to Y axis
  67404. */
  67405. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67406. /**
  67407. * Billboard mode will apply to all axes
  67408. */
  67409. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67410. /**
  67411. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67412. */
  67413. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67414. /**
  67415. * Gets or sets base Assets URL
  67416. */
  67417. static PARTICLES_BaseAssetsUrl: string;
  67418. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67419. * Test order :
  67420. * Is the bounding sphere outside the frustum ?
  67421. * If not, are the bounding box vertices outside the frustum ?
  67422. * It not, then the cullable object is in the frustum.
  67423. */
  67424. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67425. /** Culling strategy : Bounding Sphere Only.
  67426. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67427. * It's also less accurate than the standard because some not visible objects can still be selected.
  67428. * Test : is the bounding sphere outside the frustum ?
  67429. * If not, then the cullable object is in the frustum.
  67430. */
  67431. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67432. /** Culling strategy : Optimistic Inclusion.
  67433. * This in an inclusion test first, then the standard exclusion test.
  67434. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67435. * 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.
  67436. * Anyway, it's as accurate as the standard strategy.
  67437. * Test :
  67438. * Is the cullable object bounding sphere center in the frustum ?
  67439. * If not, apply the default culling strategy.
  67440. */
  67441. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67442. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67443. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67444. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67445. * 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.
  67446. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67447. * Test :
  67448. * Is the cullable object bounding sphere center in the frustum ?
  67449. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67450. */
  67451. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67452. /**
  67453. * No logging while loading
  67454. */
  67455. static readonly SCENELOADER_NO_LOGGING: number;
  67456. /**
  67457. * Minimal logging while loading
  67458. */
  67459. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67460. /**
  67461. * Summary logging while loading
  67462. */
  67463. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67464. /**
  67465. * Detailled logging while loading
  67466. */
  67467. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67468. }
  67469. }
  67470. declare module BABYLON {
  67471. /**
  67472. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67473. * Babylon.js
  67474. */
  67475. export class DomManagement {
  67476. /**
  67477. * Checks if the window object exists
  67478. * @returns true if the window object exists
  67479. */
  67480. static IsWindowObjectExist(): boolean;
  67481. /**
  67482. * Extracts text content from a DOM element hierarchy
  67483. * @param element defines the root element
  67484. * @returns a string
  67485. */
  67486. static GetDOMTextContent(element: HTMLElement): string;
  67487. }
  67488. }
  67489. declare module BABYLON {
  67490. /**
  67491. * Logger used througouht the application to allow configuration of
  67492. * the log level required for the messages.
  67493. */
  67494. export class Logger {
  67495. /**
  67496. * No log
  67497. */
  67498. static readonly NoneLogLevel: number;
  67499. /**
  67500. * Only message logs
  67501. */
  67502. static readonly MessageLogLevel: number;
  67503. /**
  67504. * Only warning logs
  67505. */
  67506. static readonly WarningLogLevel: number;
  67507. /**
  67508. * Only error logs
  67509. */
  67510. static readonly ErrorLogLevel: number;
  67511. /**
  67512. * All logs
  67513. */
  67514. static readonly AllLogLevel: number;
  67515. private static _LogCache;
  67516. /**
  67517. * Gets a value indicating the number of loading errors
  67518. * @ignorenaming
  67519. */
  67520. static errorsCount: number;
  67521. /**
  67522. * Callback called when a new log is added
  67523. */
  67524. static OnNewCacheEntry: (entry: string) => void;
  67525. private static _AddLogEntry;
  67526. private static _FormatMessage;
  67527. private static _LogDisabled;
  67528. private static _LogEnabled;
  67529. private static _WarnDisabled;
  67530. private static _WarnEnabled;
  67531. private static _ErrorDisabled;
  67532. private static _ErrorEnabled;
  67533. /**
  67534. * Log a message to the console
  67535. */
  67536. static Log: (message: string) => void;
  67537. /**
  67538. * Write a warning message to the console
  67539. */
  67540. static Warn: (message: string) => void;
  67541. /**
  67542. * Write an error message to the console
  67543. */
  67544. static Error: (message: string) => void;
  67545. /**
  67546. * Gets current log cache (list of logs)
  67547. */
  67548. static readonly LogCache: string;
  67549. /**
  67550. * Clears the log cache
  67551. */
  67552. static ClearLogCache(): void;
  67553. /**
  67554. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67555. */
  67556. static LogLevels: number;
  67557. }
  67558. }
  67559. declare module BABYLON {
  67560. /** @hidden */
  67561. export class _TypeStore {
  67562. /** @hidden */
  67563. static RegisteredTypes: {
  67564. [key: string]: Object;
  67565. };
  67566. /** @hidden */
  67567. static GetClass(fqdn: string): any;
  67568. }
  67569. }
  67570. declare module BABYLON {
  67571. /**
  67572. * Class containing a set of static utilities functions for deep copy.
  67573. */
  67574. export class DeepCopier {
  67575. /**
  67576. * Tries to copy an object by duplicating every property
  67577. * @param source defines the source object
  67578. * @param destination defines the target object
  67579. * @param doNotCopyList defines a list of properties to avoid
  67580. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67581. */
  67582. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67583. }
  67584. }
  67585. declare module BABYLON {
  67586. /**
  67587. * Class containing a set of static utilities functions for precision date
  67588. */
  67589. export class PrecisionDate {
  67590. /**
  67591. * Gets either window.performance.now() if supported or Date.now() else
  67592. */
  67593. static readonly Now: number;
  67594. }
  67595. }
  67596. declare module BABYLON {
  67597. /** @hidden */
  67598. export class _DevTools {
  67599. static WarnImport(name: string): string;
  67600. }
  67601. }
  67602. declare module BABYLON {
  67603. /**
  67604. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67605. */
  67606. export class WebRequest {
  67607. private _xhr;
  67608. /**
  67609. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67610. * i.e. when loading files, where the server/service expects an Authorization header
  67611. */
  67612. static CustomRequestHeaders: {
  67613. [key: string]: string;
  67614. };
  67615. /**
  67616. * Add callback functions in this array to update all the requests before they get sent to the network
  67617. */
  67618. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67619. private _injectCustomRequestHeaders;
  67620. /**
  67621. * Gets or sets a function to be called when loading progress changes
  67622. */
  67623. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67624. /**
  67625. * Returns client's state
  67626. */
  67627. readonly readyState: number;
  67628. /**
  67629. * Returns client's status
  67630. */
  67631. readonly status: number;
  67632. /**
  67633. * Returns client's status as a text
  67634. */
  67635. readonly statusText: string;
  67636. /**
  67637. * Returns client's response
  67638. */
  67639. readonly response: any;
  67640. /**
  67641. * Returns client's response url
  67642. */
  67643. readonly responseURL: string;
  67644. /**
  67645. * Returns client's response as text
  67646. */
  67647. readonly responseText: string;
  67648. /**
  67649. * Gets or sets the expected response type
  67650. */
  67651. responseType: XMLHttpRequestResponseType;
  67652. /** @hidden */
  67653. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67654. /** @hidden */
  67655. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67656. /**
  67657. * Cancels any network activity
  67658. */
  67659. abort(): void;
  67660. /**
  67661. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67662. * @param body defines an optional request body
  67663. */
  67664. send(body?: Document | BodyInit | null): void;
  67665. /**
  67666. * Sets the request method, request URL
  67667. * @param method defines the method to use (GET, POST, etc..)
  67668. * @param url defines the url to connect with
  67669. */
  67670. open(method: string, url: string): void;
  67671. }
  67672. }
  67673. declare module BABYLON {
  67674. /**
  67675. * Class used to evalaute queries containing `and` and `or` operators
  67676. */
  67677. export class AndOrNotEvaluator {
  67678. /**
  67679. * Evaluate a query
  67680. * @param query defines the query to evaluate
  67681. * @param evaluateCallback defines the callback used to filter result
  67682. * @returns true if the query matches
  67683. */
  67684. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67685. private static _HandleParenthesisContent;
  67686. private static _SimplifyNegation;
  67687. }
  67688. }
  67689. declare module BABYLON {
  67690. /**
  67691. * Class used to store custom tags
  67692. */
  67693. export class Tags {
  67694. /**
  67695. * Adds support for tags on the given object
  67696. * @param obj defines the object to use
  67697. */
  67698. static EnableFor(obj: any): void;
  67699. /**
  67700. * Removes tags support
  67701. * @param obj defines the object to use
  67702. */
  67703. static DisableFor(obj: any): void;
  67704. /**
  67705. * Gets a boolean indicating if the given object has tags
  67706. * @param obj defines the object to use
  67707. * @returns a boolean
  67708. */
  67709. static HasTags(obj: any): boolean;
  67710. /**
  67711. * Gets the tags available on a given object
  67712. * @param obj defines the object to use
  67713. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67714. * @returns the tags
  67715. */
  67716. static GetTags(obj: any, asString?: boolean): any;
  67717. /**
  67718. * Adds tags to an object
  67719. * @param obj defines the object to use
  67720. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67721. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67722. */
  67723. static AddTagsTo(obj: any, tagsString: string): void;
  67724. /**
  67725. * @hidden
  67726. */
  67727. static _AddTagTo(obj: any, tag: string): void;
  67728. /**
  67729. * Removes specific tags from a specific object
  67730. * @param obj defines the object to use
  67731. * @param tagsString defines the tags to remove
  67732. */
  67733. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67734. /**
  67735. * @hidden
  67736. */
  67737. static _RemoveTagFrom(obj: any, tag: string): void;
  67738. /**
  67739. * Defines if tags hosted on an object match a given query
  67740. * @param obj defines the object to use
  67741. * @param tagsQuery defines the tag query
  67742. * @returns a boolean
  67743. */
  67744. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67745. }
  67746. }
  67747. declare module BABYLON {
  67748. /**
  67749. * Manages the defines for the Material
  67750. */
  67751. export class MaterialDefines {
  67752. /** @hidden */
  67753. protected _keys: string[];
  67754. private _isDirty;
  67755. /** @hidden */
  67756. _renderId: number;
  67757. /** @hidden */
  67758. _areLightsDirty: boolean;
  67759. /** @hidden */
  67760. _areAttributesDirty: boolean;
  67761. /** @hidden */
  67762. _areTexturesDirty: boolean;
  67763. /** @hidden */
  67764. _areFresnelDirty: boolean;
  67765. /** @hidden */
  67766. _areMiscDirty: boolean;
  67767. /** @hidden */
  67768. _areImageProcessingDirty: boolean;
  67769. /** @hidden */
  67770. _normals: boolean;
  67771. /** @hidden */
  67772. _uvs: boolean;
  67773. /** @hidden */
  67774. _needNormals: boolean;
  67775. /** @hidden */
  67776. _needUVs: boolean;
  67777. [id: string]: any;
  67778. /**
  67779. * Specifies if the material needs to be re-calculated
  67780. */
  67781. readonly isDirty: boolean;
  67782. /**
  67783. * Marks the material to indicate that it has been re-calculated
  67784. */
  67785. markAsProcessed(): void;
  67786. /**
  67787. * Marks the material to indicate that it needs to be re-calculated
  67788. */
  67789. markAsUnprocessed(): void;
  67790. /**
  67791. * Marks the material to indicate all of its defines need to be re-calculated
  67792. */
  67793. markAllAsDirty(): void;
  67794. /**
  67795. * Marks the material to indicate that image processing needs to be re-calculated
  67796. */
  67797. markAsImageProcessingDirty(): void;
  67798. /**
  67799. * Marks the material to indicate the lights need to be re-calculated
  67800. */
  67801. markAsLightDirty(): void;
  67802. /**
  67803. * Marks the attribute state as changed
  67804. */
  67805. markAsAttributesDirty(): void;
  67806. /**
  67807. * Marks the texture state as changed
  67808. */
  67809. markAsTexturesDirty(): void;
  67810. /**
  67811. * Marks the fresnel state as changed
  67812. */
  67813. markAsFresnelDirty(): void;
  67814. /**
  67815. * Marks the misc state as changed
  67816. */
  67817. markAsMiscDirty(): void;
  67818. /**
  67819. * Rebuilds the material defines
  67820. */
  67821. rebuild(): void;
  67822. /**
  67823. * Specifies if two material defines are equal
  67824. * @param other - A material define instance to compare to
  67825. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67826. */
  67827. isEqual(other: MaterialDefines): boolean;
  67828. /**
  67829. * Clones this instance's defines to another instance
  67830. * @param other - material defines to clone values to
  67831. */
  67832. cloneTo(other: MaterialDefines): void;
  67833. /**
  67834. * Resets the material define values
  67835. */
  67836. reset(): void;
  67837. /**
  67838. * Converts the material define values to a string
  67839. * @returns - String of material define information
  67840. */
  67841. toString(): string;
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /**
  67846. * Class used to store and describe the pipeline context associated with an effect
  67847. */
  67848. export interface IPipelineContext {
  67849. /**
  67850. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67851. */
  67852. isAsync: boolean;
  67853. /**
  67854. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67855. */
  67856. isReady: boolean;
  67857. /** @hidden */
  67858. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Class used to store gfx data (like WebGLBuffer)
  67864. */
  67865. export class DataBuffer {
  67866. /**
  67867. * Gets or sets the number of objects referencing this buffer
  67868. */
  67869. references: number;
  67870. /** Gets or sets the size of the underlying buffer */
  67871. capacity: number;
  67872. /**
  67873. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67874. */
  67875. is32Bits: boolean;
  67876. /**
  67877. * Gets the underlying buffer
  67878. */
  67879. readonly underlyingResource: any;
  67880. }
  67881. }
  67882. declare module BABYLON {
  67883. /** @hidden */
  67884. export interface IShaderProcessor {
  67885. attributeProcessor?: (attribute: string) => string;
  67886. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67887. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67888. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67889. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67890. lineProcessor?: (line: string, isFragment: boolean) => string;
  67891. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67892. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67893. }
  67894. }
  67895. declare module BABYLON {
  67896. /** @hidden */
  67897. export interface ProcessingOptions {
  67898. defines: string[];
  67899. indexParameters: any;
  67900. isFragment: boolean;
  67901. shouldUseHighPrecisionShader: boolean;
  67902. supportsUniformBuffers: boolean;
  67903. shadersRepository: string;
  67904. includesShadersStore: {
  67905. [key: string]: string;
  67906. };
  67907. processor?: IShaderProcessor;
  67908. version: string;
  67909. platformName: string;
  67910. lookForClosingBracketForUniformBuffer?: boolean;
  67911. }
  67912. }
  67913. declare module BABYLON {
  67914. /** @hidden */
  67915. export class ShaderCodeNode {
  67916. line: string;
  67917. children: ShaderCodeNode[];
  67918. additionalDefineKey?: string;
  67919. additionalDefineValue?: string;
  67920. isValid(preprocessors: {
  67921. [key: string]: string;
  67922. }): boolean;
  67923. process(preprocessors: {
  67924. [key: string]: string;
  67925. }, options: ProcessingOptions): string;
  67926. }
  67927. }
  67928. declare module BABYLON {
  67929. /** @hidden */
  67930. export class ShaderCodeCursor {
  67931. private _lines;
  67932. lineIndex: number;
  67933. readonly currentLine: string;
  67934. readonly canRead: boolean;
  67935. lines: string[];
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67941. process(preprocessors: {
  67942. [key: string]: string;
  67943. }, options: ProcessingOptions): string;
  67944. }
  67945. }
  67946. declare module BABYLON {
  67947. /** @hidden */
  67948. export class ShaderDefineExpression {
  67949. isTrue(preprocessors: {
  67950. [key: string]: string;
  67951. }): boolean;
  67952. }
  67953. }
  67954. declare module BABYLON {
  67955. /** @hidden */
  67956. export class ShaderCodeTestNode extends ShaderCodeNode {
  67957. testExpression: ShaderDefineExpression;
  67958. isValid(preprocessors: {
  67959. [key: string]: string;
  67960. }): boolean;
  67961. }
  67962. }
  67963. declare module BABYLON {
  67964. /** @hidden */
  67965. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67966. define: string;
  67967. not: boolean;
  67968. constructor(define: string, not?: boolean);
  67969. isTrue(preprocessors: {
  67970. [key: string]: string;
  67971. }): boolean;
  67972. }
  67973. }
  67974. declare module BABYLON {
  67975. /** @hidden */
  67976. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67977. leftOperand: ShaderDefineExpression;
  67978. rightOperand: ShaderDefineExpression;
  67979. isTrue(preprocessors: {
  67980. [key: string]: string;
  67981. }): boolean;
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /** @hidden */
  67986. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67987. leftOperand: ShaderDefineExpression;
  67988. rightOperand: ShaderDefineExpression;
  67989. isTrue(preprocessors: {
  67990. [key: string]: string;
  67991. }): boolean;
  67992. }
  67993. }
  67994. declare module BABYLON {
  67995. /** @hidden */
  67996. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67997. define: string;
  67998. operand: string;
  67999. testValue: string;
  68000. constructor(define: string, operand: string, testValue: string);
  68001. isTrue(preprocessors: {
  68002. [key: string]: string;
  68003. }): boolean;
  68004. }
  68005. }
  68006. declare module BABYLON {
  68007. /** @hidden */
  68008. export class ShaderProcessor {
  68009. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68010. private static _ProcessPrecision;
  68011. private static _ExtractOperation;
  68012. private static _BuildSubExpression;
  68013. private static _BuildExpression;
  68014. private static _MoveCursorWithinIf;
  68015. private static _MoveCursor;
  68016. private static _EvaluatePreProcessors;
  68017. private static _PreparePreProcessors;
  68018. private static _ProcessShaderConversion;
  68019. private static _ProcessIncludes;
  68020. }
  68021. }
  68022. declare module BABYLON {
  68023. /**
  68024. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  68025. */
  68026. export class PerformanceMonitor {
  68027. private _enabled;
  68028. private _rollingFrameTime;
  68029. private _lastFrameTimeMs;
  68030. /**
  68031. * constructor
  68032. * @param frameSampleSize The number of samples required to saturate the sliding window
  68033. */
  68034. constructor(frameSampleSize?: number);
  68035. /**
  68036. * Samples current frame
  68037. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  68038. */
  68039. sampleFrame(timeMs?: number): void;
  68040. /**
  68041. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68042. */
  68043. readonly averageFrameTime: number;
  68044. /**
  68045. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68046. */
  68047. readonly averageFrameTimeVariance: number;
  68048. /**
  68049. * Returns the frame time of the most recent frame
  68050. */
  68051. readonly instantaneousFrameTime: number;
  68052. /**
  68053. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68054. */
  68055. readonly averageFPS: number;
  68056. /**
  68057. * Returns the average framerate in frames per second using the most recent frame time
  68058. */
  68059. readonly instantaneousFPS: number;
  68060. /**
  68061. * Returns true if enough samples have been taken to completely fill the sliding window
  68062. */
  68063. readonly isSaturated: boolean;
  68064. /**
  68065. * Enables contributions to the sliding window sample set
  68066. */
  68067. enable(): void;
  68068. /**
  68069. * Disables contributions to the sliding window sample set
  68070. * Samples will not be interpolated over the disabled period
  68071. */
  68072. disable(): void;
  68073. /**
  68074. * Returns true if sampling is enabled
  68075. */
  68076. readonly isEnabled: boolean;
  68077. /**
  68078. * Resets performance monitor
  68079. */
  68080. reset(): void;
  68081. }
  68082. /**
  68083. * RollingAverage
  68084. *
  68085. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68086. */
  68087. export class RollingAverage {
  68088. /**
  68089. * Current average
  68090. */
  68091. average: number;
  68092. /**
  68093. * Current variance
  68094. */
  68095. variance: number;
  68096. protected _samples: Array<number>;
  68097. protected _sampleCount: number;
  68098. protected _pos: number;
  68099. protected _m2: number;
  68100. /**
  68101. * constructor
  68102. * @param length The number of samples required to saturate the sliding window
  68103. */
  68104. constructor(length: number);
  68105. /**
  68106. * Adds a sample to the sample set
  68107. * @param v The sample value
  68108. */
  68109. add(v: number): void;
  68110. /**
  68111. * Returns previously added values or null if outside of history or outside the sliding window domain
  68112. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68113. * @return Value previously recorded with add() or null if outside of range
  68114. */
  68115. history(i: number): number;
  68116. /**
  68117. * Returns true if enough samples have been taken to completely fill the sliding window
  68118. * @return true if sample-set saturated
  68119. */
  68120. isSaturated(): boolean;
  68121. /**
  68122. * Resets the rolling average (equivalent to 0 samples taken so far)
  68123. */
  68124. reset(): void;
  68125. /**
  68126. * Wraps a value around the sample range boundaries
  68127. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68128. * @return Wrapped position in sample range
  68129. */
  68130. protected _wrapPosition(i: number): number;
  68131. }
  68132. }
  68133. declare module BABYLON {
  68134. /**
  68135. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68136. * The underlying implementation relies on an associative array to ensure the best performances.
  68137. * The value can be anything including 'null' but except 'undefined'
  68138. */
  68139. export class StringDictionary<T> {
  68140. /**
  68141. * This will clear this dictionary and copy the content from the 'source' one.
  68142. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68143. * @param source the dictionary to take the content from and copy to this dictionary
  68144. */
  68145. copyFrom(source: StringDictionary<T>): void;
  68146. /**
  68147. * Get a value based from its key
  68148. * @param key the given key to get the matching value from
  68149. * @return the value if found, otherwise undefined is returned
  68150. */
  68151. get(key: string): T | undefined;
  68152. /**
  68153. * Get a value from its key or add it if it doesn't exist.
  68154. * This method will ensure you that a given key/data will be present in the dictionary.
  68155. * @param key the given key to get the matching value from
  68156. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68157. * The factory will only be invoked if there's no data for the given key.
  68158. * @return the value corresponding to the key.
  68159. */
  68160. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68161. /**
  68162. * Get a value from its key if present in the dictionary otherwise add it
  68163. * @param key the key to get the value from
  68164. * @param val if there's no such key/value pair in the dictionary add it with this value
  68165. * @return the value corresponding to the key
  68166. */
  68167. getOrAdd(key: string, val: T): T;
  68168. /**
  68169. * Check if there's a given key in the dictionary
  68170. * @param key the key to check for
  68171. * @return true if the key is present, false otherwise
  68172. */
  68173. contains(key: string): boolean;
  68174. /**
  68175. * Add a new key and its corresponding value
  68176. * @param key the key to add
  68177. * @param value the value corresponding to the key
  68178. * @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
  68179. */
  68180. add(key: string, value: T): boolean;
  68181. /**
  68182. * Update a specific value associated to a key
  68183. * @param key defines the key to use
  68184. * @param value defines the value to store
  68185. * @returns true if the value was updated (or false if the key was not found)
  68186. */
  68187. set(key: string, value: T): boolean;
  68188. /**
  68189. * Get the element of the given key and remove it from the dictionary
  68190. * @param key defines the key to search
  68191. * @returns the value associated with the key or null if not found
  68192. */
  68193. getAndRemove(key: string): Nullable<T>;
  68194. /**
  68195. * Remove a key/value from the dictionary.
  68196. * @param key the key to remove
  68197. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68198. */
  68199. remove(key: string): boolean;
  68200. /**
  68201. * Clear the whole content of the dictionary
  68202. */
  68203. clear(): void;
  68204. /**
  68205. * Gets the current count
  68206. */
  68207. readonly count: number;
  68208. /**
  68209. * Execute a callback on each key/val of the dictionary.
  68210. * Note that you can remove any element in this dictionary in the callback implementation
  68211. * @param callback the callback to execute on a given key/value pair
  68212. */
  68213. forEach(callback: (key: string, val: T) => void): void;
  68214. /**
  68215. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68216. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68217. * Note that you can remove any element in this dictionary in the callback implementation
  68218. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68219. * @returns the first item
  68220. */
  68221. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68222. private _count;
  68223. private _data;
  68224. }
  68225. }
  68226. declare module BABYLON {
  68227. /**
  68228. * Helper class that provides a small promise polyfill
  68229. */
  68230. export class PromisePolyfill {
  68231. /**
  68232. * Static function used to check if the polyfill is required
  68233. * If this is the case then the function will inject the polyfill to window.Promise
  68234. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68235. */
  68236. static Apply(force?: boolean): void;
  68237. }
  68238. }
  68239. declare module BABYLON {
  68240. /**
  68241. * Class used to store data that will be store in GPU memory
  68242. */
  68243. export class Buffer {
  68244. private _engine;
  68245. private _buffer;
  68246. /** @hidden */
  68247. _data: Nullable<DataArray>;
  68248. private _updatable;
  68249. private _instanced;
  68250. /**
  68251. * Gets the byte stride.
  68252. */
  68253. readonly byteStride: number;
  68254. /**
  68255. * Constructor
  68256. * @param engine the engine
  68257. * @param data the data to use for this buffer
  68258. * @param updatable whether the data is updatable
  68259. * @param stride the stride (optional)
  68260. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68261. * @param instanced whether the buffer is instanced (optional)
  68262. * @param useBytes set to true if the stride in in bytes (optional)
  68263. */
  68264. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68265. /**
  68266. * Create a new VertexBuffer based on the current buffer
  68267. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68268. * @param offset defines offset in the buffer (0 by default)
  68269. * @param size defines the size in floats of attributes (position is 3 for instance)
  68270. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68271. * @param instanced defines if the vertex buffer contains indexed data
  68272. * @param useBytes defines if the offset and stride are in bytes
  68273. * @returns the new vertex buffer
  68274. */
  68275. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68276. /**
  68277. * Gets a boolean indicating if the Buffer is updatable?
  68278. * @returns true if the buffer is updatable
  68279. */
  68280. isUpdatable(): boolean;
  68281. /**
  68282. * Gets current buffer's data
  68283. * @returns a DataArray or null
  68284. */
  68285. getData(): Nullable<DataArray>;
  68286. /**
  68287. * Gets underlying native buffer
  68288. * @returns underlying native buffer
  68289. */
  68290. getBuffer(): Nullable<DataBuffer>;
  68291. /**
  68292. * Gets the stride in float32 units (i.e. byte stride / 4).
  68293. * May not be an integer if the byte stride is not divisible by 4.
  68294. * DEPRECATED. Use byteStride instead.
  68295. * @returns the stride in float32 units
  68296. */
  68297. getStrideSize(): number;
  68298. /**
  68299. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68300. * @param data defines the data to store
  68301. */
  68302. create(data?: Nullable<DataArray>): void;
  68303. /** @hidden */
  68304. _rebuild(): void;
  68305. /**
  68306. * Update current buffer data
  68307. * @param data defines the data to store
  68308. */
  68309. update(data: DataArray): void;
  68310. /**
  68311. * Updates the data directly.
  68312. * @param data the new data
  68313. * @param offset the new offset
  68314. * @param vertexCount the vertex count (optional)
  68315. * @param useBytes set to true if the offset is in bytes
  68316. */
  68317. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68318. /**
  68319. * Release all resources
  68320. */
  68321. dispose(): void;
  68322. }
  68323. /**
  68324. * Specialized buffer used to store vertex data
  68325. */
  68326. export class VertexBuffer {
  68327. /** @hidden */
  68328. _buffer: Buffer;
  68329. private _kind;
  68330. private _size;
  68331. private _ownsBuffer;
  68332. private _instanced;
  68333. private _instanceDivisor;
  68334. /**
  68335. * The byte type.
  68336. */
  68337. static readonly BYTE: number;
  68338. /**
  68339. * The unsigned byte type.
  68340. */
  68341. static readonly UNSIGNED_BYTE: number;
  68342. /**
  68343. * The short type.
  68344. */
  68345. static readonly SHORT: number;
  68346. /**
  68347. * The unsigned short type.
  68348. */
  68349. static readonly UNSIGNED_SHORT: number;
  68350. /**
  68351. * The integer type.
  68352. */
  68353. static readonly INT: number;
  68354. /**
  68355. * The unsigned integer type.
  68356. */
  68357. static readonly UNSIGNED_INT: number;
  68358. /**
  68359. * The float type.
  68360. */
  68361. static readonly FLOAT: number;
  68362. /**
  68363. * Gets or sets the instance divisor when in instanced mode
  68364. */
  68365. instanceDivisor: number;
  68366. /**
  68367. * Gets the byte stride.
  68368. */
  68369. readonly byteStride: number;
  68370. /**
  68371. * Gets the byte offset.
  68372. */
  68373. readonly byteOffset: number;
  68374. /**
  68375. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68376. */
  68377. readonly normalized: boolean;
  68378. /**
  68379. * Gets the data type of each component in the array.
  68380. */
  68381. readonly type: number;
  68382. /**
  68383. * Constructor
  68384. * @param engine the engine
  68385. * @param data the data to use for this vertex buffer
  68386. * @param kind the vertex buffer kind
  68387. * @param updatable whether the data is updatable
  68388. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68389. * @param stride the stride (optional)
  68390. * @param instanced whether the buffer is instanced (optional)
  68391. * @param offset the offset of the data (optional)
  68392. * @param size the number of components (optional)
  68393. * @param type the type of the component (optional)
  68394. * @param normalized whether the data contains normalized data (optional)
  68395. * @param useBytes set to true if stride and offset are in bytes (optional)
  68396. */
  68397. 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);
  68398. /** @hidden */
  68399. _rebuild(): void;
  68400. /**
  68401. * Returns the kind of the VertexBuffer (string)
  68402. * @returns a string
  68403. */
  68404. getKind(): string;
  68405. /**
  68406. * Gets a boolean indicating if the VertexBuffer is updatable?
  68407. * @returns true if the buffer is updatable
  68408. */
  68409. isUpdatable(): boolean;
  68410. /**
  68411. * Gets current buffer's data
  68412. * @returns a DataArray or null
  68413. */
  68414. getData(): Nullable<DataArray>;
  68415. /**
  68416. * Gets underlying native buffer
  68417. * @returns underlying native buffer
  68418. */
  68419. getBuffer(): Nullable<DataBuffer>;
  68420. /**
  68421. * Gets the stride in float32 units (i.e. byte stride / 4).
  68422. * May not be an integer if the byte stride is not divisible by 4.
  68423. * DEPRECATED. Use byteStride instead.
  68424. * @returns the stride in float32 units
  68425. */
  68426. getStrideSize(): number;
  68427. /**
  68428. * Returns the offset as a multiple of the type byte length.
  68429. * DEPRECATED. Use byteOffset instead.
  68430. * @returns the offset in bytes
  68431. */
  68432. getOffset(): number;
  68433. /**
  68434. * Returns the number of components per vertex attribute (integer)
  68435. * @returns the size in float
  68436. */
  68437. getSize(): number;
  68438. /**
  68439. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68440. * @returns true if this buffer is instanced
  68441. */
  68442. getIsInstanced(): boolean;
  68443. /**
  68444. * Returns the instancing divisor, zero for non-instanced (integer).
  68445. * @returns a number
  68446. */
  68447. getInstanceDivisor(): number;
  68448. /**
  68449. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68450. * @param data defines the data to store
  68451. */
  68452. create(data?: DataArray): void;
  68453. /**
  68454. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68455. * This function will create a new buffer if the current one is not updatable
  68456. * @param data defines the data to store
  68457. */
  68458. update(data: DataArray): void;
  68459. /**
  68460. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68461. * Returns the directly updated WebGLBuffer.
  68462. * @param data the new data
  68463. * @param offset the new offset
  68464. * @param useBytes set to true if the offset is in bytes
  68465. */
  68466. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68467. /**
  68468. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68469. */
  68470. dispose(): void;
  68471. /**
  68472. * Enumerates each value of this vertex buffer as numbers.
  68473. * @param count the number of values to enumerate
  68474. * @param callback the callback function called for each value
  68475. */
  68476. forEach(count: number, callback: (value: number, index: number) => void): void;
  68477. /**
  68478. * Positions
  68479. */
  68480. static readonly PositionKind: string;
  68481. /**
  68482. * Normals
  68483. */
  68484. static readonly NormalKind: string;
  68485. /**
  68486. * Tangents
  68487. */
  68488. static readonly TangentKind: string;
  68489. /**
  68490. * Texture coordinates
  68491. */
  68492. static readonly UVKind: string;
  68493. /**
  68494. * Texture coordinates 2
  68495. */
  68496. static readonly UV2Kind: string;
  68497. /**
  68498. * Texture coordinates 3
  68499. */
  68500. static readonly UV3Kind: string;
  68501. /**
  68502. * Texture coordinates 4
  68503. */
  68504. static readonly UV4Kind: string;
  68505. /**
  68506. * Texture coordinates 5
  68507. */
  68508. static readonly UV5Kind: string;
  68509. /**
  68510. * Texture coordinates 6
  68511. */
  68512. static readonly UV6Kind: string;
  68513. /**
  68514. * Colors
  68515. */
  68516. static readonly ColorKind: string;
  68517. /**
  68518. * Matrix indices (for bones)
  68519. */
  68520. static readonly MatricesIndicesKind: string;
  68521. /**
  68522. * Matrix weights (for bones)
  68523. */
  68524. static readonly MatricesWeightsKind: string;
  68525. /**
  68526. * Additional matrix indices (for bones)
  68527. */
  68528. static readonly MatricesIndicesExtraKind: string;
  68529. /**
  68530. * Additional matrix weights (for bones)
  68531. */
  68532. static readonly MatricesWeightsExtraKind: string;
  68533. /**
  68534. * Deduces the stride given a kind.
  68535. * @param kind The kind string to deduce
  68536. * @returns The deduced stride
  68537. */
  68538. static DeduceStride(kind: string): number;
  68539. /**
  68540. * Gets the byte length of the given type.
  68541. * @param type the type
  68542. * @returns the number of bytes
  68543. */
  68544. static GetTypeByteLength(type: number): number;
  68545. /**
  68546. * Enumerates each value of the given parameters as numbers.
  68547. * @param data the data to enumerate
  68548. * @param byteOffset the byte offset of the data
  68549. * @param byteStride the byte stride of the data
  68550. * @param componentCount the number of components per element
  68551. * @param componentType the type of the component
  68552. * @param count the number of values to enumerate
  68553. * @param normalized whether the data is normalized
  68554. * @param callback the callback function called for each value
  68555. */
  68556. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68557. private static _GetFloatValue;
  68558. }
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * Class representing spherical harmonics coefficients to the 3rd degree
  68563. */
  68564. export class SphericalHarmonics {
  68565. /**
  68566. * Defines whether or not the harmonics have been prescaled for rendering.
  68567. */
  68568. preScaled: boolean;
  68569. /**
  68570. * The l0,0 coefficients of the spherical harmonics
  68571. */
  68572. l00: Vector3;
  68573. /**
  68574. * The l1,-1 coefficients of the spherical harmonics
  68575. */
  68576. l1_1: Vector3;
  68577. /**
  68578. * The l1,0 coefficients of the spherical harmonics
  68579. */
  68580. l10: Vector3;
  68581. /**
  68582. * The l1,1 coefficients of the spherical harmonics
  68583. */
  68584. l11: Vector3;
  68585. /**
  68586. * The l2,-2 coefficients of the spherical harmonics
  68587. */
  68588. l2_2: Vector3;
  68589. /**
  68590. * The l2,-1 coefficients of the spherical harmonics
  68591. */
  68592. l2_1: Vector3;
  68593. /**
  68594. * The l2,0 coefficients of the spherical harmonics
  68595. */
  68596. l20: Vector3;
  68597. /**
  68598. * The l2,1 coefficients of the spherical harmonics
  68599. */
  68600. l21: Vector3;
  68601. /**
  68602. * The l2,2 coefficients of the spherical harmonics
  68603. */
  68604. l22: Vector3;
  68605. /**
  68606. * Adds a light to the spherical harmonics
  68607. * @param direction the direction of the light
  68608. * @param color the color of the light
  68609. * @param deltaSolidAngle the delta solid angle of the light
  68610. */
  68611. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68612. /**
  68613. * Scales the spherical harmonics by the given amount
  68614. * @param scale the amount to scale
  68615. */
  68616. scaleInPlace(scale: number): void;
  68617. /**
  68618. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68619. *
  68620. * ```
  68621. * E_lm = A_l * L_lm
  68622. * ```
  68623. *
  68624. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68625. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68626. * the scaling factors are given in equation 9.
  68627. */
  68628. convertIncidentRadianceToIrradiance(): void;
  68629. /**
  68630. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68631. *
  68632. * ```
  68633. * L = (1/pi) * E * rho
  68634. * ```
  68635. *
  68636. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68637. */
  68638. convertIrradianceToLambertianRadiance(): void;
  68639. /**
  68640. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68641. * required operations at run time.
  68642. *
  68643. * This is simply done by scaling back the SH with Ylm constants parameter.
  68644. * The trigonometric part being applied by the shader at run time.
  68645. */
  68646. preScaleForRendering(): void;
  68647. /**
  68648. * Constructs a spherical harmonics from an array.
  68649. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68650. * @returns the spherical harmonics
  68651. */
  68652. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68653. /**
  68654. * Gets the spherical harmonics from polynomial
  68655. * @param polynomial the spherical polynomial
  68656. * @returns the spherical harmonics
  68657. */
  68658. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68659. }
  68660. /**
  68661. * Class representing spherical polynomial coefficients to the 3rd degree
  68662. */
  68663. export class SphericalPolynomial {
  68664. private _harmonics;
  68665. /**
  68666. * The spherical harmonics used to create the polynomials.
  68667. */
  68668. readonly preScaledHarmonics: SphericalHarmonics;
  68669. /**
  68670. * The x coefficients of the spherical polynomial
  68671. */
  68672. x: Vector3;
  68673. /**
  68674. * The y coefficients of the spherical polynomial
  68675. */
  68676. y: Vector3;
  68677. /**
  68678. * The z coefficients of the spherical polynomial
  68679. */
  68680. z: Vector3;
  68681. /**
  68682. * The xx coefficients of the spherical polynomial
  68683. */
  68684. xx: Vector3;
  68685. /**
  68686. * The yy coefficients of the spherical polynomial
  68687. */
  68688. yy: Vector3;
  68689. /**
  68690. * The zz coefficients of the spherical polynomial
  68691. */
  68692. zz: Vector3;
  68693. /**
  68694. * The xy coefficients of the spherical polynomial
  68695. */
  68696. xy: Vector3;
  68697. /**
  68698. * The yz coefficients of the spherical polynomial
  68699. */
  68700. yz: Vector3;
  68701. /**
  68702. * The zx coefficients of the spherical polynomial
  68703. */
  68704. zx: Vector3;
  68705. /**
  68706. * Adds an ambient color to the spherical polynomial
  68707. * @param color the color to add
  68708. */
  68709. addAmbient(color: Color3): void;
  68710. /**
  68711. * Scales the spherical polynomial by the given amount
  68712. * @param scale the amount to scale
  68713. */
  68714. scaleInPlace(scale: number): void;
  68715. /**
  68716. * Gets the spherical polynomial from harmonics
  68717. * @param harmonics the spherical harmonics
  68718. * @returns the spherical polynomial
  68719. */
  68720. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68721. /**
  68722. * Constructs a spherical polynomial from an array.
  68723. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68724. * @returns the spherical polynomial
  68725. */
  68726. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68727. }
  68728. }
  68729. declare module BABYLON {
  68730. /**
  68731. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68732. */
  68733. export interface CubeMapInfo {
  68734. /**
  68735. * The pixel array for the front face.
  68736. * This is stored in format, left to right, up to down format.
  68737. */
  68738. front: Nullable<ArrayBufferView>;
  68739. /**
  68740. * The pixel array for the back face.
  68741. * This is stored in format, left to right, up to down format.
  68742. */
  68743. back: Nullable<ArrayBufferView>;
  68744. /**
  68745. * The pixel array for the left face.
  68746. * This is stored in format, left to right, up to down format.
  68747. */
  68748. left: Nullable<ArrayBufferView>;
  68749. /**
  68750. * The pixel array for the right face.
  68751. * This is stored in format, left to right, up to down format.
  68752. */
  68753. right: Nullable<ArrayBufferView>;
  68754. /**
  68755. * The pixel array for the up face.
  68756. * This is stored in format, left to right, up to down format.
  68757. */
  68758. up: Nullable<ArrayBufferView>;
  68759. /**
  68760. * The pixel array for the down face.
  68761. * This is stored in format, left to right, up to down format.
  68762. */
  68763. down: Nullable<ArrayBufferView>;
  68764. /**
  68765. * The size of the cubemap stored.
  68766. *
  68767. * Each faces will be size * size pixels.
  68768. */
  68769. size: number;
  68770. /**
  68771. * The format of the texture.
  68772. *
  68773. * RGBA, RGB.
  68774. */
  68775. format: number;
  68776. /**
  68777. * The type of the texture data.
  68778. *
  68779. * UNSIGNED_INT, FLOAT.
  68780. */
  68781. type: number;
  68782. /**
  68783. * Specifies whether the texture is in gamma space.
  68784. */
  68785. gammaSpace: boolean;
  68786. }
  68787. /**
  68788. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68789. */
  68790. export class PanoramaToCubeMapTools {
  68791. private static FACE_FRONT;
  68792. private static FACE_BACK;
  68793. private static FACE_RIGHT;
  68794. private static FACE_LEFT;
  68795. private static FACE_DOWN;
  68796. private static FACE_UP;
  68797. /**
  68798. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68799. *
  68800. * @param float32Array The source data.
  68801. * @param inputWidth The width of the input panorama.
  68802. * @param inputHeight The height of the input panorama.
  68803. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68804. * @return The cubemap data
  68805. */
  68806. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68807. private static CreateCubemapTexture;
  68808. private static CalcProjectionSpherical;
  68809. }
  68810. }
  68811. declare module BABYLON {
  68812. /**
  68813. * Helper class dealing with the extraction of spherical polynomial dataArray
  68814. * from a cube map.
  68815. */
  68816. export class CubeMapToSphericalPolynomialTools {
  68817. private static FileFaces;
  68818. /**
  68819. * Converts a texture to the according Spherical Polynomial data.
  68820. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68821. *
  68822. * @param texture The texture to extract the information from.
  68823. * @return The Spherical Polynomial data.
  68824. */
  68825. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68826. /**
  68827. * Converts a cubemap to the according Spherical Polynomial data.
  68828. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68829. *
  68830. * @param cubeInfo The Cube map to extract the information from.
  68831. * @return The Spherical Polynomial data.
  68832. */
  68833. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68834. }
  68835. }
  68836. declare module BABYLON {
  68837. /**
  68838. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68839. * during the life time of the application.
  68840. */
  68841. export class EngineStore {
  68842. /** Gets the list of created engines */
  68843. static Instances: Engine[];
  68844. /** @hidden */
  68845. static _LastCreatedScene: Nullable<Scene>;
  68846. /**
  68847. * Gets the latest created engine
  68848. */
  68849. static readonly LastCreatedEngine: Nullable<Engine>;
  68850. /**
  68851. * Gets the latest created scene
  68852. */
  68853. static readonly LastCreatedScene: Nullable<Scene>;
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * Define options used to create a render target texture
  68859. */
  68860. export class RenderTargetCreationOptions {
  68861. /**
  68862. * Specifies is mipmaps must be generated
  68863. */
  68864. generateMipMaps?: boolean;
  68865. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68866. generateDepthBuffer?: boolean;
  68867. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68868. generateStencilBuffer?: boolean;
  68869. /** Defines texture type (int by default) */
  68870. type?: number;
  68871. /** Defines sampling mode (trilinear by default) */
  68872. samplingMode?: number;
  68873. /** Defines format (RGBA by default) */
  68874. format?: number;
  68875. }
  68876. }
  68877. declare module BABYLON {
  68878. /**
  68879. * @hidden
  68880. **/
  68881. export class _AlphaState {
  68882. private _isAlphaBlendDirty;
  68883. private _isBlendFunctionParametersDirty;
  68884. private _isBlendEquationParametersDirty;
  68885. private _isBlendConstantsDirty;
  68886. private _alphaBlend;
  68887. private _blendFunctionParameters;
  68888. private _blendEquationParameters;
  68889. private _blendConstants;
  68890. /**
  68891. * Initializes the state.
  68892. */
  68893. constructor();
  68894. readonly isDirty: boolean;
  68895. alphaBlend: boolean;
  68896. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68897. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68898. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68899. reset(): void;
  68900. apply(gl: WebGLRenderingContext): void;
  68901. }
  68902. }
  68903. declare module BABYLON {
  68904. /**
  68905. * @hidden
  68906. **/
  68907. export class _DepthCullingState {
  68908. private _isDepthTestDirty;
  68909. private _isDepthMaskDirty;
  68910. private _isDepthFuncDirty;
  68911. private _isCullFaceDirty;
  68912. private _isCullDirty;
  68913. private _isZOffsetDirty;
  68914. private _isFrontFaceDirty;
  68915. private _depthTest;
  68916. private _depthMask;
  68917. private _depthFunc;
  68918. private _cull;
  68919. private _cullFace;
  68920. private _zOffset;
  68921. private _frontFace;
  68922. /**
  68923. * Initializes the state.
  68924. */
  68925. constructor();
  68926. readonly isDirty: boolean;
  68927. zOffset: number;
  68928. cullFace: Nullable<number>;
  68929. cull: Nullable<boolean>;
  68930. depthFunc: Nullable<number>;
  68931. depthMask: boolean;
  68932. depthTest: boolean;
  68933. frontFace: Nullable<number>;
  68934. reset(): void;
  68935. apply(gl: WebGLRenderingContext): void;
  68936. }
  68937. }
  68938. declare module BABYLON {
  68939. /**
  68940. * @hidden
  68941. **/
  68942. export class _StencilState {
  68943. /** 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 */
  68944. static readonly ALWAYS: number;
  68945. /** Passed to stencilOperation to specify that stencil value must be kept */
  68946. static readonly KEEP: number;
  68947. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68948. static readonly REPLACE: number;
  68949. private _isStencilTestDirty;
  68950. private _isStencilMaskDirty;
  68951. private _isStencilFuncDirty;
  68952. private _isStencilOpDirty;
  68953. private _stencilTest;
  68954. private _stencilMask;
  68955. private _stencilFunc;
  68956. private _stencilFuncRef;
  68957. private _stencilFuncMask;
  68958. private _stencilOpStencilFail;
  68959. private _stencilOpDepthFail;
  68960. private _stencilOpStencilDepthPass;
  68961. readonly isDirty: boolean;
  68962. stencilFunc: number;
  68963. stencilFuncRef: number;
  68964. stencilFuncMask: number;
  68965. stencilOpStencilFail: number;
  68966. stencilOpDepthFail: number;
  68967. stencilOpStencilDepthPass: number;
  68968. stencilMask: number;
  68969. stencilTest: boolean;
  68970. constructor();
  68971. reset(): void;
  68972. apply(gl: WebGLRenderingContext): void;
  68973. }
  68974. }
  68975. declare module BABYLON {
  68976. /**
  68977. * @hidden
  68978. **/
  68979. export class _TimeToken {
  68980. _startTimeQuery: Nullable<WebGLQuery>;
  68981. _endTimeQuery: Nullable<WebGLQuery>;
  68982. _timeElapsedQuery: Nullable<WebGLQuery>;
  68983. _timeElapsedQueryEnded: boolean;
  68984. }
  68985. }
  68986. declare module BABYLON {
  68987. /**
  68988. * Class used to store data associated with WebGL texture data for the engine
  68989. * This class should not be used directly
  68990. */
  68991. export class InternalTexture {
  68992. /** @hidden */
  68993. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68994. /**
  68995. * The source of the texture data is unknown
  68996. */
  68997. static DATASOURCE_UNKNOWN: number;
  68998. /**
  68999. * Texture data comes from an URL
  69000. */
  69001. static DATASOURCE_URL: number;
  69002. /**
  69003. * Texture data is only used for temporary storage
  69004. */
  69005. static DATASOURCE_TEMP: number;
  69006. /**
  69007. * Texture data comes from raw data (ArrayBuffer)
  69008. */
  69009. static DATASOURCE_RAW: number;
  69010. /**
  69011. * Texture content is dynamic (video or dynamic texture)
  69012. */
  69013. static DATASOURCE_DYNAMIC: number;
  69014. /**
  69015. * Texture content is generated by rendering to it
  69016. */
  69017. static DATASOURCE_RENDERTARGET: number;
  69018. /**
  69019. * Texture content is part of a multi render target process
  69020. */
  69021. static DATASOURCE_MULTIRENDERTARGET: number;
  69022. /**
  69023. * Texture data comes from a cube data file
  69024. */
  69025. static DATASOURCE_CUBE: number;
  69026. /**
  69027. * Texture data comes from a raw cube data
  69028. */
  69029. static DATASOURCE_CUBERAW: number;
  69030. /**
  69031. * Texture data come from a prefiltered cube data file
  69032. */
  69033. static DATASOURCE_CUBEPREFILTERED: number;
  69034. /**
  69035. * Texture content is raw 3D data
  69036. */
  69037. static DATASOURCE_RAW3D: number;
  69038. /**
  69039. * Texture content is a depth texture
  69040. */
  69041. static DATASOURCE_DEPTHTEXTURE: number;
  69042. /**
  69043. * Texture data comes from a raw cube data encoded with RGBD
  69044. */
  69045. static DATASOURCE_CUBERAW_RGBD: number;
  69046. /**
  69047. * Defines if the texture is ready
  69048. */
  69049. isReady: boolean;
  69050. /**
  69051. * Defines if the texture is a cube texture
  69052. */
  69053. isCube: boolean;
  69054. /**
  69055. * Defines if the texture contains 3D data
  69056. */
  69057. is3D: boolean;
  69058. /**
  69059. * Defines if the texture contains multiview data
  69060. */
  69061. isMultiview: boolean;
  69062. /**
  69063. * Gets the URL used to load this texture
  69064. */
  69065. url: string;
  69066. /**
  69067. * Gets the sampling mode of the texture
  69068. */
  69069. samplingMode: number;
  69070. /**
  69071. * Gets a boolean indicating if the texture needs mipmaps generation
  69072. */
  69073. generateMipMaps: boolean;
  69074. /**
  69075. * Gets the number of samples used by the texture (WebGL2+ only)
  69076. */
  69077. samples: number;
  69078. /**
  69079. * Gets the type of the texture (int, float...)
  69080. */
  69081. type: number;
  69082. /**
  69083. * Gets the format of the texture (RGB, RGBA...)
  69084. */
  69085. format: number;
  69086. /**
  69087. * Observable called when the texture is loaded
  69088. */
  69089. onLoadedObservable: Observable<InternalTexture>;
  69090. /**
  69091. * Gets the width of the texture
  69092. */
  69093. width: number;
  69094. /**
  69095. * Gets the height of the texture
  69096. */
  69097. height: number;
  69098. /**
  69099. * Gets the depth of the texture
  69100. */
  69101. depth: number;
  69102. /**
  69103. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69104. */
  69105. baseWidth: number;
  69106. /**
  69107. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69108. */
  69109. baseHeight: number;
  69110. /**
  69111. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69112. */
  69113. baseDepth: number;
  69114. /**
  69115. * Gets a boolean indicating if the texture is inverted on Y axis
  69116. */
  69117. invertY: boolean;
  69118. /** @hidden */
  69119. _invertVScale: boolean;
  69120. /** @hidden */
  69121. _associatedChannel: number;
  69122. /** @hidden */
  69123. _dataSource: number;
  69124. /** @hidden */
  69125. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69126. /** @hidden */
  69127. _bufferView: Nullable<ArrayBufferView>;
  69128. /** @hidden */
  69129. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69130. /** @hidden */
  69131. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69132. /** @hidden */
  69133. _size: number;
  69134. /** @hidden */
  69135. _extension: string;
  69136. /** @hidden */
  69137. _files: Nullable<string[]>;
  69138. /** @hidden */
  69139. _workingCanvas: Nullable<HTMLCanvasElement>;
  69140. /** @hidden */
  69141. _workingContext: Nullable<CanvasRenderingContext2D>;
  69142. /** @hidden */
  69143. _framebuffer: Nullable<WebGLFramebuffer>;
  69144. /** @hidden */
  69145. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69146. /** @hidden */
  69147. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69148. /** @hidden */
  69149. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69150. /** @hidden */
  69151. _attachments: Nullable<number[]>;
  69152. /** @hidden */
  69153. _cachedCoordinatesMode: Nullable<number>;
  69154. /** @hidden */
  69155. _cachedWrapU: Nullable<number>;
  69156. /** @hidden */
  69157. _cachedWrapV: Nullable<number>;
  69158. /** @hidden */
  69159. _cachedWrapR: Nullable<number>;
  69160. /** @hidden */
  69161. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69162. /** @hidden */
  69163. _isDisabled: boolean;
  69164. /** @hidden */
  69165. _compression: Nullable<string>;
  69166. /** @hidden */
  69167. _generateStencilBuffer: boolean;
  69168. /** @hidden */
  69169. _generateDepthBuffer: boolean;
  69170. /** @hidden */
  69171. _comparisonFunction: number;
  69172. /** @hidden */
  69173. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69174. /** @hidden */
  69175. _lodGenerationScale: number;
  69176. /** @hidden */
  69177. _lodGenerationOffset: number;
  69178. /** @hidden */
  69179. _colorTextureArray: Nullable<WebGLTexture>;
  69180. /** @hidden */
  69181. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69182. /** @hidden */
  69183. _lodTextureHigh: Nullable<BaseTexture>;
  69184. /** @hidden */
  69185. _lodTextureMid: Nullable<BaseTexture>;
  69186. /** @hidden */
  69187. _lodTextureLow: Nullable<BaseTexture>;
  69188. /** @hidden */
  69189. _isRGBD: boolean;
  69190. /** @hidden */
  69191. _linearSpecularLOD: boolean;
  69192. /** @hidden */
  69193. _irradianceTexture: Nullable<BaseTexture>;
  69194. /** @hidden */
  69195. _webGLTexture: Nullable<WebGLTexture>;
  69196. /** @hidden */
  69197. _references: number;
  69198. private _engine;
  69199. /**
  69200. * Gets the Engine the texture belongs to.
  69201. * @returns The babylon engine
  69202. */
  69203. getEngine(): Engine;
  69204. /**
  69205. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69206. */
  69207. readonly dataSource: number;
  69208. /**
  69209. * Creates a new InternalTexture
  69210. * @param engine defines the engine to use
  69211. * @param dataSource defines the type of data that will be used
  69212. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69213. */
  69214. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69215. /**
  69216. * Increments the number of references (ie. the number of Texture that point to it)
  69217. */
  69218. incrementReferences(): void;
  69219. /**
  69220. * Change the size of the texture (not the size of the content)
  69221. * @param width defines the new width
  69222. * @param height defines the new height
  69223. * @param depth defines the new depth (1 by default)
  69224. */
  69225. updateSize(width: int, height: int, depth?: int): void;
  69226. /** @hidden */
  69227. _rebuild(): void;
  69228. /** @hidden */
  69229. _swapAndDie(target: InternalTexture): void;
  69230. /**
  69231. * Dispose the current allocated resources
  69232. */
  69233. dispose(): void;
  69234. }
  69235. }
  69236. declare module BABYLON {
  69237. /**
  69238. * This represents the main contract an easing function should follow.
  69239. * Easing functions are used throughout the animation system.
  69240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69241. */
  69242. export interface IEasingFunction {
  69243. /**
  69244. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69245. * of the easing function.
  69246. * The link below provides some of the most common examples of easing functions.
  69247. * @see https://easings.net/
  69248. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69249. * @returns the corresponding value on the curve defined by the easing function
  69250. */
  69251. ease(gradient: number): number;
  69252. }
  69253. /**
  69254. * Base class used for every default easing function.
  69255. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69256. */
  69257. export class EasingFunction implements IEasingFunction {
  69258. /**
  69259. * Interpolation follows the mathematical formula associated with the easing function.
  69260. */
  69261. static readonly EASINGMODE_EASEIN: number;
  69262. /**
  69263. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69264. */
  69265. static readonly EASINGMODE_EASEOUT: number;
  69266. /**
  69267. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69268. */
  69269. static readonly EASINGMODE_EASEINOUT: number;
  69270. private _easingMode;
  69271. /**
  69272. * Sets the easing mode of the current function.
  69273. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69274. */
  69275. setEasingMode(easingMode: number): void;
  69276. /**
  69277. * Gets the current easing mode.
  69278. * @returns the easing mode
  69279. */
  69280. getEasingMode(): number;
  69281. /**
  69282. * @hidden
  69283. */
  69284. easeInCore(gradient: number): number;
  69285. /**
  69286. * Given an input gradient between 0 and 1, this returns the corresponding value
  69287. * of the easing function.
  69288. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69289. * @returns the corresponding value on the curve defined by the easing function
  69290. */
  69291. ease(gradient: number): number;
  69292. }
  69293. /**
  69294. * Easing function with a circle shape (see link below).
  69295. * @see https://easings.net/#easeInCirc
  69296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69297. */
  69298. export class CircleEase extends EasingFunction implements IEasingFunction {
  69299. /** @hidden */
  69300. easeInCore(gradient: number): number;
  69301. }
  69302. /**
  69303. * Easing function with a ease back shape (see link below).
  69304. * @see https://easings.net/#easeInBack
  69305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69306. */
  69307. export class BackEase extends EasingFunction implements IEasingFunction {
  69308. /** Defines the amplitude of the function */
  69309. amplitude: number;
  69310. /**
  69311. * Instantiates a back ease easing
  69312. * @see https://easings.net/#easeInBack
  69313. * @param amplitude Defines the amplitude of the function
  69314. */
  69315. constructor(
  69316. /** Defines the amplitude of the function */
  69317. amplitude?: number);
  69318. /** @hidden */
  69319. easeInCore(gradient: number): number;
  69320. }
  69321. /**
  69322. * Easing function with a bouncing shape (see link below).
  69323. * @see https://easings.net/#easeInBounce
  69324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69325. */
  69326. export class BounceEase extends EasingFunction implements IEasingFunction {
  69327. /** Defines the number of bounces */
  69328. bounces: number;
  69329. /** Defines the amplitude of the bounce */
  69330. bounciness: number;
  69331. /**
  69332. * Instantiates a bounce easing
  69333. * @see https://easings.net/#easeInBounce
  69334. * @param bounces Defines the number of bounces
  69335. * @param bounciness Defines the amplitude of the bounce
  69336. */
  69337. constructor(
  69338. /** Defines the number of bounces */
  69339. bounces?: number,
  69340. /** Defines the amplitude of the bounce */
  69341. bounciness?: number);
  69342. /** @hidden */
  69343. easeInCore(gradient: number): number;
  69344. }
  69345. /**
  69346. * Easing function with a power of 3 shape (see link below).
  69347. * @see https://easings.net/#easeInCubic
  69348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69349. */
  69350. export class CubicEase extends EasingFunction implements IEasingFunction {
  69351. /** @hidden */
  69352. easeInCore(gradient: number): number;
  69353. }
  69354. /**
  69355. * Easing function with an elastic shape (see link below).
  69356. * @see https://easings.net/#easeInElastic
  69357. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69358. */
  69359. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69360. /** Defines the number of oscillations*/
  69361. oscillations: number;
  69362. /** Defines the amplitude of the oscillations*/
  69363. springiness: number;
  69364. /**
  69365. * Instantiates an elastic easing function
  69366. * @see https://easings.net/#easeInElastic
  69367. * @param oscillations Defines the number of oscillations
  69368. * @param springiness Defines the amplitude of the oscillations
  69369. */
  69370. constructor(
  69371. /** Defines the number of oscillations*/
  69372. oscillations?: number,
  69373. /** Defines the amplitude of the oscillations*/
  69374. springiness?: number);
  69375. /** @hidden */
  69376. easeInCore(gradient: number): number;
  69377. }
  69378. /**
  69379. * Easing function with an exponential shape (see link below).
  69380. * @see https://easings.net/#easeInExpo
  69381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69382. */
  69383. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69384. /** Defines the exponent of the function */
  69385. exponent: number;
  69386. /**
  69387. * Instantiates an exponential easing function
  69388. * @see https://easings.net/#easeInExpo
  69389. * @param exponent Defines the exponent of the function
  69390. */
  69391. constructor(
  69392. /** Defines the exponent of the function */
  69393. exponent?: number);
  69394. /** @hidden */
  69395. easeInCore(gradient: number): number;
  69396. }
  69397. /**
  69398. * Easing function with a power shape (see link below).
  69399. * @see https://easings.net/#easeInQuad
  69400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69401. */
  69402. export class PowerEase extends EasingFunction implements IEasingFunction {
  69403. /** Defines the power of the function */
  69404. power: number;
  69405. /**
  69406. * Instantiates an power base easing function
  69407. * @see https://easings.net/#easeInQuad
  69408. * @param power Defines the power of the function
  69409. */
  69410. constructor(
  69411. /** Defines the power of the function */
  69412. power?: number);
  69413. /** @hidden */
  69414. easeInCore(gradient: number): number;
  69415. }
  69416. /**
  69417. * Easing function with a power of 2 shape (see link below).
  69418. * @see https://easings.net/#easeInQuad
  69419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69420. */
  69421. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69422. /** @hidden */
  69423. easeInCore(gradient: number): number;
  69424. }
  69425. /**
  69426. * Easing function with a power of 4 shape (see link below).
  69427. * @see https://easings.net/#easeInQuart
  69428. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69429. */
  69430. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69431. /** @hidden */
  69432. easeInCore(gradient: number): number;
  69433. }
  69434. /**
  69435. * Easing function with a power of 5 shape (see link below).
  69436. * @see https://easings.net/#easeInQuint
  69437. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69438. */
  69439. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69440. /** @hidden */
  69441. easeInCore(gradient: number): number;
  69442. }
  69443. /**
  69444. * Easing function with a sin shape (see link below).
  69445. * @see https://easings.net/#easeInSine
  69446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69447. */
  69448. export class SineEase extends EasingFunction implements IEasingFunction {
  69449. /** @hidden */
  69450. easeInCore(gradient: number): number;
  69451. }
  69452. /**
  69453. * Easing function with a bezier shape (see link below).
  69454. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69456. */
  69457. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69458. /** Defines the x component of the start tangent in the bezier curve */
  69459. x1: number;
  69460. /** Defines the y component of the start tangent in the bezier curve */
  69461. y1: number;
  69462. /** Defines the x component of the end tangent in the bezier curve */
  69463. x2: number;
  69464. /** Defines the y component of the end tangent in the bezier curve */
  69465. y2: number;
  69466. /**
  69467. * Instantiates a bezier function
  69468. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69469. * @param x1 Defines the x component of the start tangent in the bezier curve
  69470. * @param y1 Defines the y component of the start tangent in the bezier curve
  69471. * @param x2 Defines the x component of the end tangent in the bezier curve
  69472. * @param y2 Defines the y component of the end tangent in the bezier curve
  69473. */
  69474. constructor(
  69475. /** Defines the x component of the start tangent in the bezier curve */
  69476. x1?: number,
  69477. /** Defines the y component of the start tangent in the bezier curve */
  69478. y1?: number,
  69479. /** Defines the x component of the end tangent in the bezier curve */
  69480. x2?: number,
  69481. /** Defines the y component of the end tangent in the bezier curve */
  69482. y2?: number);
  69483. /** @hidden */
  69484. easeInCore(gradient: number): number;
  69485. }
  69486. }
  69487. declare module BABYLON {
  69488. /**
  69489. * Defines an interface which represents an animation key frame
  69490. */
  69491. export interface IAnimationKey {
  69492. /**
  69493. * Frame of the key frame
  69494. */
  69495. frame: number;
  69496. /**
  69497. * Value at the specifies key frame
  69498. */
  69499. value: any;
  69500. /**
  69501. * The input tangent for the cubic hermite spline
  69502. */
  69503. inTangent?: any;
  69504. /**
  69505. * The output tangent for the cubic hermite spline
  69506. */
  69507. outTangent?: any;
  69508. /**
  69509. * The animation interpolation type
  69510. */
  69511. interpolation?: AnimationKeyInterpolation;
  69512. }
  69513. /**
  69514. * Enum for the animation key frame interpolation type
  69515. */
  69516. export enum AnimationKeyInterpolation {
  69517. /**
  69518. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69519. */
  69520. STEP = 1
  69521. }
  69522. }
  69523. declare module BABYLON {
  69524. /**
  69525. * Represents the range of an animation
  69526. */
  69527. export class AnimationRange {
  69528. /**The name of the animation range**/
  69529. name: string;
  69530. /**The starting frame of the animation */
  69531. from: number;
  69532. /**The ending frame of the animation*/
  69533. to: number;
  69534. /**
  69535. * Initializes the range of an animation
  69536. * @param name The name of the animation range
  69537. * @param from The starting frame of the animation
  69538. * @param to The ending frame of the animation
  69539. */
  69540. constructor(
  69541. /**The name of the animation range**/
  69542. name: string,
  69543. /**The starting frame of the animation */
  69544. from: number,
  69545. /**The ending frame of the animation*/
  69546. to: number);
  69547. /**
  69548. * Makes a copy of the animation range
  69549. * @returns A copy of the animation range
  69550. */
  69551. clone(): AnimationRange;
  69552. }
  69553. }
  69554. declare module BABYLON {
  69555. /**
  69556. * Composed of a frame, and an action function
  69557. */
  69558. export class AnimationEvent {
  69559. /** The frame for which the event is triggered **/
  69560. frame: number;
  69561. /** The event to perform when triggered **/
  69562. action: (currentFrame: number) => void;
  69563. /** Specifies if the event should be triggered only once**/
  69564. onlyOnce?: boolean | undefined;
  69565. /**
  69566. * Specifies if the animation event is done
  69567. */
  69568. isDone: boolean;
  69569. /**
  69570. * Initializes the animation event
  69571. * @param frame The frame for which the event is triggered
  69572. * @param action The event to perform when triggered
  69573. * @param onlyOnce Specifies if the event should be triggered only once
  69574. */
  69575. constructor(
  69576. /** The frame for which the event is triggered **/
  69577. frame: number,
  69578. /** The event to perform when triggered **/
  69579. action: (currentFrame: number) => void,
  69580. /** Specifies if the event should be triggered only once**/
  69581. onlyOnce?: boolean | undefined);
  69582. /** @hidden */
  69583. _clone(): AnimationEvent;
  69584. }
  69585. }
  69586. declare module BABYLON {
  69587. /**
  69588. * Interface used to define a behavior
  69589. */
  69590. export interface Behavior<T> {
  69591. /** gets or sets behavior's name */
  69592. name: string;
  69593. /**
  69594. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69595. */
  69596. init(): void;
  69597. /**
  69598. * Called when the behavior is attached to a target
  69599. * @param target defines the target where the behavior is attached to
  69600. */
  69601. attach(target: T): void;
  69602. /**
  69603. * Called when the behavior is detached from its target
  69604. */
  69605. detach(): void;
  69606. }
  69607. /**
  69608. * Interface implemented by classes supporting behaviors
  69609. */
  69610. export interface IBehaviorAware<T> {
  69611. /**
  69612. * Attach a behavior
  69613. * @param behavior defines the behavior to attach
  69614. * @returns the current host
  69615. */
  69616. addBehavior(behavior: Behavior<T>): T;
  69617. /**
  69618. * Remove a behavior from the current object
  69619. * @param behavior defines the behavior to detach
  69620. * @returns the current host
  69621. */
  69622. removeBehavior(behavior: Behavior<T>): T;
  69623. /**
  69624. * Gets a behavior using its name to search
  69625. * @param name defines the name to search
  69626. * @returns the behavior or null if not found
  69627. */
  69628. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69629. }
  69630. }
  69631. declare module BABYLON {
  69632. /**
  69633. * @hidden
  69634. */
  69635. export class IntersectionInfo {
  69636. bu: Nullable<number>;
  69637. bv: Nullable<number>;
  69638. distance: number;
  69639. faceId: number;
  69640. subMeshId: number;
  69641. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69642. }
  69643. }
  69644. declare module BABYLON {
  69645. /**
  69646. * Class used to store bounding sphere information
  69647. */
  69648. export class BoundingSphere {
  69649. /**
  69650. * Gets the center of the bounding sphere in local space
  69651. */
  69652. readonly center: Vector3;
  69653. /**
  69654. * Radius of the bounding sphere in local space
  69655. */
  69656. radius: number;
  69657. /**
  69658. * Gets the center of the bounding sphere in world space
  69659. */
  69660. readonly centerWorld: Vector3;
  69661. /**
  69662. * Radius of the bounding sphere in world space
  69663. */
  69664. radiusWorld: number;
  69665. /**
  69666. * Gets the minimum vector in local space
  69667. */
  69668. readonly minimum: Vector3;
  69669. /**
  69670. * Gets the maximum vector in local space
  69671. */
  69672. readonly maximum: Vector3;
  69673. private _worldMatrix;
  69674. private static readonly TmpVector3;
  69675. /**
  69676. * Creates a new bounding sphere
  69677. * @param min defines the minimum vector (in local space)
  69678. * @param max defines the maximum vector (in local space)
  69679. * @param worldMatrix defines the new world matrix
  69680. */
  69681. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69682. /**
  69683. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69684. * @param min defines the new minimum vector (in local space)
  69685. * @param max defines the new maximum vector (in local space)
  69686. * @param worldMatrix defines the new world matrix
  69687. */
  69688. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69689. /**
  69690. * Scale the current bounding sphere by applying a scale factor
  69691. * @param factor defines the scale factor to apply
  69692. * @returns the current bounding box
  69693. */
  69694. scale(factor: number): BoundingSphere;
  69695. /**
  69696. * Gets the world matrix of the bounding box
  69697. * @returns a matrix
  69698. */
  69699. getWorldMatrix(): DeepImmutable<Matrix>;
  69700. /** @hidden */
  69701. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69702. /**
  69703. * Tests if the bounding sphere is intersecting the frustum planes
  69704. * @param frustumPlanes defines the frustum planes to test
  69705. * @returns true if there is an intersection
  69706. */
  69707. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69708. /**
  69709. * Tests if the bounding sphere center is in between the frustum planes.
  69710. * Used for optimistic fast inclusion.
  69711. * @param frustumPlanes defines the frustum planes to test
  69712. * @returns true if the sphere center is in between the frustum planes
  69713. */
  69714. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69715. /**
  69716. * Tests if a point is inside the bounding sphere
  69717. * @param point defines the point to test
  69718. * @returns true if the point is inside the bounding sphere
  69719. */
  69720. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69721. /**
  69722. * Checks if two sphere intersct
  69723. * @param sphere0 sphere 0
  69724. * @param sphere1 sphere 1
  69725. * @returns true if the speres intersect
  69726. */
  69727. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69728. }
  69729. }
  69730. declare module BABYLON {
  69731. /**
  69732. * Class used to store bounding box information
  69733. */
  69734. export class BoundingBox implements ICullable {
  69735. /**
  69736. * Gets the 8 vectors representing the bounding box in local space
  69737. */
  69738. readonly vectors: Vector3[];
  69739. /**
  69740. * Gets the center of the bounding box in local space
  69741. */
  69742. readonly center: Vector3;
  69743. /**
  69744. * Gets the center of the bounding box in world space
  69745. */
  69746. readonly centerWorld: Vector3;
  69747. /**
  69748. * Gets the extend size in local space
  69749. */
  69750. readonly extendSize: Vector3;
  69751. /**
  69752. * Gets the extend size in world space
  69753. */
  69754. readonly extendSizeWorld: Vector3;
  69755. /**
  69756. * Gets the OBB (object bounding box) directions
  69757. */
  69758. readonly directions: Vector3[];
  69759. /**
  69760. * Gets the 8 vectors representing the bounding box in world space
  69761. */
  69762. readonly vectorsWorld: Vector3[];
  69763. /**
  69764. * Gets the minimum vector in world space
  69765. */
  69766. readonly minimumWorld: Vector3;
  69767. /**
  69768. * Gets the maximum vector in world space
  69769. */
  69770. readonly maximumWorld: Vector3;
  69771. /**
  69772. * Gets the minimum vector in local space
  69773. */
  69774. readonly minimum: Vector3;
  69775. /**
  69776. * Gets the maximum vector in local space
  69777. */
  69778. readonly maximum: Vector3;
  69779. private _worldMatrix;
  69780. private static readonly TmpVector3;
  69781. /**
  69782. * @hidden
  69783. */
  69784. _tag: number;
  69785. /**
  69786. * Creates a new bounding box
  69787. * @param min defines the minimum vector (in local space)
  69788. * @param max defines the maximum vector (in local space)
  69789. * @param worldMatrix defines the new world matrix
  69790. */
  69791. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69792. /**
  69793. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69794. * @param min defines the new minimum vector (in local space)
  69795. * @param max defines the new maximum vector (in local space)
  69796. * @param worldMatrix defines the new world matrix
  69797. */
  69798. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69799. /**
  69800. * Scale the current bounding box by applying a scale factor
  69801. * @param factor defines the scale factor to apply
  69802. * @returns the current bounding box
  69803. */
  69804. scale(factor: number): BoundingBox;
  69805. /**
  69806. * Gets the world matrix of the bounding box
  69807. * @returns a matrix
  69808. */
  69809. getWorldMatrix(): DeepImmutable<Matrix>;
  69810. /** @hidden */
  69811. _update(world: DeepImmutable<Matrix>): void;
  69812. /**
  69813. * Tests if the bounding box is intersecting the frustum planes
  69814. * @param frustumPlanes defines the frustum planes to test
  69815. * @returns true if there is an intersection
  69816. */
  69817. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69818. /**
  69819. * Tests if the bounding box is entirely inside the frustum planes
  69820. * @param frustumPlanes defines the frustum planes to test
  69821. * @returns true if there is an inclusion
  69822. */
  69823. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69824. /**
  69825. * Tests if a point is inside the bounding box
  69826. * @param point defines the point to test
  69827. * @returns true if the point is inside the bounding box
  69828. */
  69829. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69830. /**
  69831. * Tests if the bounding box intersects with a bounding sphere
  69832. * @param sphere defines the sphere to test
  69833. * @returns true if there is an intersection
  69834. */
  69835. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69836. /**
  69837. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69838. * @param min defines the min vector to use
  69839. * @param max defines the max vector to use
  69840. * @returns true if there is an intersection
  69841. */
  69842. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69843. /**
  69844. * Tests if two bounding boxes are intersections
  69845. * @param box0 defines the first box to test
  69846. * @param box1 defines the second box to test
  69847. * @returns true if there is an intersection
  69848. */
  69849. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69850. /**
  69851. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69852. * @param minPoint defines the minimum vector of the bounding box
  69853. * @param maxPoint defines the maximum vector of the bounding box
  69854. * @param sphereCenter defines the sphere center
  69855. * @param sphereRadius defines the sphere radius
  69856. * @returns true if there is an intersection
  69857. */
  69858. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69859. /**
  69860. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69861. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69862. * @param frustumPlanes defines the frustum planes to test
  69863. * @return true if there is an inclusion
  69864. */
  69865. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69866. /**
  69867. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69868. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69869. * @param frustumPlanes defines the frustum planes to test
  69870. * @return true if there is an intersection
  69871. */
  69872. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69873. }
  69874. }
  69875. declare module BABYLON {
  69876. /** @hidden */
  69877. export class Collider {
  69878. /** Define if a collision was found */
  69879. collisionFound: boolean;
  69880. /**
  69881. * Define last intersection point in local space
  69882. */
  69883. intersectionPoint: Vector3;
  69884. /**
  69885. * Define last collided mesh
  69886. */
  69887. collidedMesh: Nullable<AbstractMesh>;
  69888. private _collisionPoint;
  69889. private _planeIntersectionPoint;
  69890. private _tempVector;
  69891. private _tempVector2;
  69892. private _tempVector3;
  69893. private _tempVector4;
  69894. private _edge;
  69895. private _baseToVertex;
  69896. private _destinationPoint;
  69897. private _slidePlaneNormal;
  69898. private _displacementVector;
  69899. /** @hidden */
  69900. _radius: Vector3;
  69901. /** @hidden */
  69902. _retry: number;
  69903. private _velocity;
  69904. private _basePoint;
  69905. private _epsilon;
  69906. /** @hidden */
  69907. _velocityWorldLength: number;
  69908. /** @hidden */
  69909. _basePointWorld: Vector3;
  69910. private _velocityWorld;
  69911. private _normalizedVelocity;
  69912. /** @hidden */
  69913. _initialVelocity: Vector3;
  69914. /** @hidden */
  69915. _initialPosition: Vector3;
  69916. private _nearestDistance;
  69917. private _collisionMask;
  69918. collisionMask: number;
  69919. /**
  69920. * Gets the plane normal used to compute the sliding response (in local space)
  69921. */
  69922. readonly slidePlaneNormal: Vector3;
  69923. /** @hidden */
  69924. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69925. /** @hidden */
  69926. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69927. /** @hidden */
  69928. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69929. /** @hidden */
  69930. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69931. /** @hidden */
  69932. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69933. /** @hidden */
  69934. _getResponse(pos: Vector3, vel: Vector3): void;
  69935. }
  69936. }
  69937. declare module BABYLON {
  69938. /**
  69939. * Interface for cullable objects
  69940. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69941. */
  69942. export interface ICullable {
  69943. /**
  69944. * Checks if the object or part of the object is in the frustum
  69945. * @param frustumPlanes Camera near/planes
  69946. * @returns true if the object is in frustum otherwise false
  69947. */
  69948. isInFrustum(frustumPlanes: Plane[]): boolean;
  69949. /**
  69950. * Checks if a cullable object (mesh...) is in the camera frustum
  69951. * Unlike isInFrustum this cheks the full bounding box
  69952. * @param frustumPlanes Camera near/planes
  69953. * @returns true if the object is in frustum otherwise false
  69954. */
  69955. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69956. }
  69957. /**
  69958. * Info for a bounding data of a mesh
  69959. */
  69960. export class BoundingInfo implements ICullable {
  69961. /**
  69962. * Bounding box for the mesh
  69963. */
  69964. readonly boundingBox: BoundingBox;
  69965. /**
  69966. * Bounding sphere for the mesh
  69967. */
  69968. readonly boundingSphere: BoundingSphere;
  69969. private _isLocked;
  69970. private static readonly TmpVector3;
  69971. /**
  69972. * Constructs bounding info
  69973. * @param minimum min vector of the bounding box/sphere
  69974. * @param maximum max vector of the bounding box/sphere
  69975. * @param worldMatrix defines the new world matrix
  69976. */
  69977. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69978. /**
  69979. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69980. * @param min defines the new minimum vector (in local space)
  69981. * @param max defines the new maximum vector (in local space)
  69982. * @param worldMatrix defines the new world matrix
  69983. */
  69984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69985. /**
  69986. * min vector of the bounding box/sphere
  69987. */
  69988. readonly minimum: Vector3;
  69989. /**
  69990. * max vector of the bounding box/sphere
  69991. */
  69992. readonly maximum: Vector3;
  69993. /**
  69994. * If the info is locked and won't be updated to avoid perf overhead
  69995. */
  69996. isLocked: boolean;
  69997. /**
  69998. * Updates the bounding sphere and box
  69999. * @param world world matrix to be used to update
  70000. */
  70001. update(world: DeepImmutable<Matrix>): void;
  70002. /**
  70003. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70004. * @param center New center of the bounding info
  70005. * @param extend New extend of the bounding info
  70006. * @returns the current bounding info
  70007. */
  70008. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70009. /**
  70010. * Scale the current bounding info by applying a scale factor
  70011. * @param factor defines the scale factor to apply
  70012. * @returns the current bounding info
  70013. */
  70014. scale(factor: number): BoundingInfo;
  70015. /**
  70016. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70017. * @param frustumPlanes defines the frustum to test
  70018. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70019. * @returns true if the bounding info is in the frustum planes
  70020. */
  70021. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70022. /**
  70023. * Gets the world distance between the min and max points of the bounding box
  70024. */
  70025. readonly diagonalLength: number;
  70026. /**
  70027. * Checks if a cullable object (mesh...) is in the camera frustum
  70028. * Unlike isInFrustum this cheks the full bounding box
  70029. * @param frustumPlanes Camera near/planes
  70030. * @returns true if the object is in frustum otherwise false
  70031. */
  70032. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70033. /** @hidden */
  70034. _checkCollision(collider: Collider): boolean;
  70035. /**
  70036. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70037. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70038. * @param point the point to check intersection with
  70039. * @returns if the point intersects
  70040. */
  70041. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70042. /**
  70043. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70044. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70045. * @param boundingInfo the bounding info to check intersection with
  70046. * @param precise if the intersection should be done using OBB
  70047. * @returns if the bounding info intersects
  70048. */
  70049. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70050. }
  70051. }
  70052. declare module BABYLON {
  70053. /**
  70054. * Defines an array and its length.
  70055. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70056. */
  70057. export interface ISmartArrayLike<T> {
  70058. /**
  70059. * The data of the array.
  70060. */
  70061. data: Array<T>;
  70062. /**
  70063. * The active length of the array.
  70064. */
  70065. length: number;
  70066. }
  70067. /**
  70068. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70069. */
  70070. export class SmartArray<T> implements ISmartArrayLike<T> {
  70071. /**
  70072. * The full set of data from the array.
  70073. */
  70074. data: Array<T>;
  70075. /**
  70076. * The active length of the array.
  70077. */
  70078. length: number;
  70079. protected _id: number;
  70080. /**
  70081. * Instantiates a Smart Array.
  70082. * @param capacity defines the default capacity of the array.
  70083. */
  70084. constructor(capacity: number);
  70085. /**
  70086. * Pushes a value at the end of the active data.
  70087. * @param value defines the object to push in the array.
  70088. */
  70089. push(value: T): void;
  70090. /**
  70091. * Iterates over the active data and apply the lambda to them.
  70092. * @param func defines the action to apply on each value.
  70093. */
  70094. forEach(func: (content: T) => void): void;
  70095. /**
  70096. * Sorts the full sets of data.
  70097. * @param compareFn defines the comparison function to apply.
  70098. */
  70099. sort(compareFn: (a: T, b: T) => number): void;
  70100. /**
  70101. * Resets the active data to an empty array.
  70102. */
  70103. reset(): void;
  70104. /**
  70105. * Releases all the data from the array as well as the array.
  70106. */
  70107. dispose(): void;
  70108. /**
  70109. * Concats the active data with a given array.
  70110. * @param array defines the data to concatenate with.
  70111. */
  70112. concat(array: any): void;
  70113. /**
  70114. * Returns the position of a value in the active data.
  70115. * @param value defines the value to find the index for
  70116. * @returns the index if found in the active data otherwise -1
  70117. */
  70118. indexOf(value: T): number;
  70119. /**
  70120. * Returns whether an element is part of the active data.
  70121. * @param value defines the value to look for
  70122. * @returns true if found in the active data otherwise false
  70123. */
  70124. contains(value: T): boolean;
  70125. private static _GlobalId;
  70126. }
  70127. /**
  70128. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70129. * The data in this array can only be present once
  70130. */
  70131. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70132. private _duplicateId;
  70133. /**
  70134. * Pushes a value at the end of the active data.
  70135. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70136. * @param value defines the object to push in the array.
  70137. */
  70138. push(value: T): void;
  70139. /**
  70140. * Pushes a value at the end of the active data.
  70141. * If the data is already present, it won t be added again
  70142. * @param value defines the object to push in the array.
  70143. * @returns true if added false if it was already present
  70144. */
  70145. pushNoDuplicate(value: T): boolean;
  70146. /**
  70147. * Resets the active data to an empty array.
  70148. */
  70149. reset(): void;
  70150. /**
  70151. * Concats the active data with a given array.
  70152. * This ensures no dupplicate will be present in the result.
  70153. * @param array defines the data to concatenate with.
  70154. */
  70155. concatWithNoDuplicate(array: any): void;
  70156. }
  70157. }
  70158. declare module BABYLON {
  70159. /**
  70160. * Enum that determines the text-wrapping mode to use.
  70161. */
  70162. export enum InspectableType {
  70163. /**
  70164. * Checkbox for booleans
  70165. */
  70166. Checkbox = 0,
  70167. /**
  70168. * Sliders for numbers
  70169. */
  70170. Slider = 1,
  70171. /**
  70172. * Vector3
  70173. */
  70174. Vector3 = 2,
  70175. /**
  70176. * Quaternions
  70177. */
  70178. Quaternion = 3,
  70179. /**
  70180. * Color3
  70181. */
  70182. Color3 = 4
  70183. }
  70184. /**
  70185. * Interface used to define custom inspectable properties.
  70186. * This interface is used by the inspector to display custom property grids
  70187. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70188. */
  70189. export interface IInspectable {
  70190. /**
  70191. * Gets the label to display
  70192. */
  70193. label: string;
  70194. /**
  70195. * Gets the name of the property to edit
  70196. */
  70197. propertyName: string;
  70198. /**
  70199. * Gets the type of the editor to use
  70200. */
  70201. type: InspectableType;
  70202. /**
  70203. * Gets the minimum value of the property when using in "slider" mode
  70204. */
  70205. min?: number;
  70206. /**
  70207. * Gets the maximum value of the property when using in "slider" mode
  70208. */
  70209. max?: number;
  70210. /**
  70211. * Gets the setp to use when using in "slider" mode
  70212. */
  70213. step?: number;
  70214. }
  70215. }
  70216. declare module BABYLON {
  70217. /**
  70218. * This represents the required contract to create a new type of texture loader.
  70219. */
  70220. export interface IInternalTextureLoader {
  70221. /**
  70222. * Defines wether the loader supports cascade loading the different faces.
  70223. */
  70224. supportCascades: boolean;
  70225. /**
  70226. * This returns if the loader support the current file information.
  70227. * @param extension defines the file extension of the file being loaded
  70228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70229. * @param fallback defines the fallback internal texture if any
  70230. * @param isBase64 defines whether the texture is encoded as a base64
  70231. * @param isBuffer defines whether the texture data are stored as a buffer
  70232. * @returns true if the loader can load the specified file
  70233. */
  70234. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70235. /**
  70236. * Transform the url before loading if required.
  70237. * @param rootUrl the url of the texture
  70238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70239. * @returns the transformed texture
  70240. */
  70241. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70242. /**
  70243. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70244. * @param rootUrl the url of the texture
  70245. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70246. * @returns the fallback texture
  70247. */
  70248. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70249. /**
  70250. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70251. * @param data contains the texture data
  70252. * @param texture defines the BabylonJS internal texture
  70253. * @param createPolynomials will be true if polynomials have been requested
  70254. * @param onLoad defines the callback to trigger once the texture is ready
  70255. * @param onError defines the callback to trigger in case of error
  70256. */
  70257. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70258. /**
  70259. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70260. * @param data contains the texture data
  70261. * @param texture defines the BabylonJS internal texture
  70262. * @param callback defines the method to call once ready to upload
  70263. */
  70264. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70265. }
  70266. }
  70267. declare module BABYLON {
  70268. interface Engine {
  70269. /**
  70270. * Creates a depth stencil cube texture.
  70271. * This is only available in WebGL 2.
  70272. * @param size The size of face edge in the cube texture.
  70273. * @param options The options defining the cube texture.
  70274. * @returns The cube texture
  70275. */
  70276. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70277. /**
  70278. * Creates a cube texture
  70279. * @param rootUrl defines the url where the files to load is located
  70280. * @param scene defines the current scene
  70281. * @param files defines the list of files to load (1 per face)
  70282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70283. * @param onLoad defines an optional callback raised when the texture is loaded
  70284. * @param onError defines an optional callback raised if there is an issue to load the texture
  70285. * @param format defines the format of the data
  70286. * @param forcedExtension defines the extension to use to pick the right loader
  70287. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70288. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70289. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70290. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70291. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70292. * @returns the cube texture as an InternalTexture
  70293. */
  70294. 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;
  70295. /**
  70296. * Creates a cube texture
  70297. * @param rootUrl defines the url where the files to load is located
  70298. * @param scene defines the current scene
  70299. * @param files defines the list of files to load (1 per face)
  70300. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70301. * @param onLoad defines an optional callback raised when the texture is loaded
  70302. * @param onError defines an optional callback raised if there is an issue to load the texture
  70303. * @param format defines the format of the data
  70304. * @param forcedExtension defines the extension to use to pick the right loader
  70305. * @returns the cube texture as an InternalTexture
  70306. */
  70307. 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;
  70308. /**
  70309. * Creates a cube texture
  70310. * @param rootUrl defines the url where the files to load is located
  70311. * @param scene defines the current scene
  70312. * @param files defines the list of files to load (1 per face)
  70313. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70314. * @param onLoad defines an optional callback raised when the texture is loaded
  70315. * @param onError defines an optional callback raised if there is an issue to load the texture
  70316. * @param format defines the format of the data
  70317. * @param forcedExtension defines the extension to use to pick the right loader
  70318. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70319. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70320. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70321. * @returns the cube texture as an InternalTexture
  70322. */
  70323. 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;
  70324. /** @hidden */
  70325. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70326. /** @hidden */
  70327. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70328. /** @hidden */
  70329. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70330. /** @hidden */
  70331. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70332. }
  70333. }
  70334. declare module BABYLON {
  70335. /**
  70336. * Class for creating a cube texture
  70337. */
  70338. export class CubeTexture extends BaseTexture {
  70339. private _delayedOnLoad;
  70340. /**
  70341. * The url of the texture
  70342. */
  70343. url: string;
  70344. /**
  70345. * Gets or sets the center of the bounding box associated with the cube texture.
  70346. * It must define where the camera used to render the texture was set
  70347. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70348. */
  70349. boundingBoxPosition: Vector3;
  70350. private _boundingBoxSize;
  70351. /**
  70352. * Gets or sets the size of the bounding box associated with the cube texture
  70353. * When defined, the cubemap will switch to local mode
  70354. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70355. * @example https://www.babylonjs-playground.com/#RNASML
  70356. */
  70357. /**
  70358. * Returns the bounding box size
  70359. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70360. */
  70361. boundingBoxSize: Vector3;
  70362. protected _rotationY: number;
  70363. /**
  70364. * Sets texture matrix rotation angle around Y axis in radians.
  70365. */
  70366. /**
  70367. * Gets texture matrix rotation angle around Y axis radians.
  70368. */
  70369. rotationY: number;
  70370. /**
  70371. * Are mip maps generated for this texture or not.
  70372. */
  70373. readonly noMipmap: boolean;
  70374. private _noMipmap;
  70375. private _files;
  70376. private _extensions;
  70377. private _textureMatrix;
  70378. private _format;
  70379. private _createPolynomials;
  70380. /** @hidden */
  70381. _prefiltered: boolean;
  70382. /**
  70383. * Creates a cube texture from an array of image urls
  70384. * @param files defines an array of image urls
  70385. * @param scene defines the hosting scene
  70386. * @param noMipmap specifies if mip maps are not used
  70387. * @returns a cube texture
  70388. */
  70389. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70390. /**
  70391. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70392. * @param url defines the url of the prefiltered texture
  70393. * @param scene defines the scene the texture is attached to
  70394. * @param forcedExtension defines the extension of the file if different from the url
  70395. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70396. * @return the prefiltered texture
  70397. */
  70398. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70399. /**
  70400. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70401. * as prefiltered data.
  70402. * @param rootUrl defines the url of the texture or the root name of the six images
  70403. * @param scene defines the scene the texture is attached to
  70404. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70405. * @param noMipmap defines if mipmaps should be created or not
  70406. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70407. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70408. * @param onError defines a callback triggered in case of error during load
  70409. * @param format defines the internal format to use for the texture once loaded
  70410. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70411. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70412. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70413. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70414. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70415. * @return the cube texture
  70416. */
  70417. 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);
  70418. /**
  70419. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70420. */
  70421. readonly isPrefiltered: boolean;
  70422. /**
  70423. * Get the current class name of the texture useful for serialization or dynamic coding.
  70424. * @returns "CubeTexture"
  70425. */
  70426. getClassName(): string;
  70427. /**
  70428. * Update the url (and optional buffer) of this texture if url was null during construction.
  70429. * @param url the url of the texture
  70430. * @param forcedExtension defines the extension to use
  70431. * @param onLoad callback called when the texture is loaded (defaults to null)
  70432. */
  70433. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70434. /**
  70435. * Delays loading of the cube texture
  70436. * @param forcedExtension defines the extension to use
  70437. */
  70438. delayLoad(forcedExtension?: string): void;
  70439. /**
  70440. * Returns the reflection texture matrix
  70441. * @returns the reflection texture matrix
  70442. */
  70443. getReflectionTextureMatrix(): Matrix;
  70444. /**
  70445. * Sets the reflection texture matrix
  70446. * @param value Reflection texture matrix
  70447. */
  70448. setReflectionTextureMatrix(value: Matrix): void;
  70449. /**
  70450. * Parses text to create a cube texture
  70451. * @param parsedTexture define the serialized text to read from
  70452. * @param scene defines the hosting scene
  70453. * @param rootUrl defines the root url of the cube texture
  70454. * @returns a cube texture
  70455. */
  70456. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70457. /**
  70458. * Makes a clone, or deep copy, of the cube texture
  70459. * @returns a new cube texture
  70460. */
  70461. clone(): CubeTexture;
  70462. }
  70463. }
  70464. declare module BABYLON {
  70465. /** @hidden */
  70466. export var postprocessVertexShader: {
  70467. name: string;
  70468. shader: string;
  70469. };
  70470. }
  70471. declare module BABYLON {
  70472. /**
  70473. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70474. * This is the base of the follow, arc rotate cameras and Free camera
  70475. * @see http://doc.babylonjs.com/features/cameras
  70476. */
  70477. export class TargetCamera extends Camera {
  70478. private static _RigCamTransformMatrix;
  70479. private static _TargetTransformMatrix;
  70480. private static _TargetFocalPoint;
  70481. /**
  70482. * Define the current direction the camera is moving to
  70483. */
  70484. cameraDirection: Vector3;
  70485. /**
  70486. * Define the current rotation the camera is rotating to
  70487. */
  70488. cameraRotation: Vector2;
  70489. /**
  70490. * When set, the up vector of the camera will be updated by the rotation of the camera
  70491. */
  70492. updateUpVectorFromRotation: boolean;
  70493. private _tmpQuaternion;
  70494. /**
  70495. * Define the current rotation of the camera
  70496. */
  70497. rotation: Vector3;
  70498. /**
  70499. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70500. */
  70501. rotationQuaternion: Quaternion;
  70502. /**
  70503. * Define the current speed of the camera
  70504. */
  70505. speed: number;
  70506. /**
  70507. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70508. * around all axis.
  70509. */
  70510. noRotationConstraint: boolean;
  70511. /**
  70512. * Define the current target of the camera as an object or a position.
  70513. */
  70514. lockedTarget: any;
  70515. /** @hidden */
  70516. _currentTarget: Vector3;
  70517. /** @hidden */
  70518. _initialFocalDistance: number;
  70519. /** @hidden */
  70520. _viewMatrix: Matrix;
  70521. /** @hidden */
  70522. _camMatrix: Matrix;
  70523. /** @hidden */
  70524. _cameraTransformMatrix: Matrix;
  70525. /** @hidden */
  70526. _cameraRotationMatrix: Matrix;
  70527. /** @hidden */
  70528. _referencePoint: Vector3;
  70529. /** @hidden */
  70530. _transformedReferencePoint: Vector3;
  70531. protected _globalCurrentTarget: Vector3;
  70532. protected _globalCurrentUpVector: Vector3;
  70533. /** @hidden */
  70534. _reset: () => void;
  70535. private _defaultUp;
  70536. /**
  70537. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70538. * This is the base of the follow, arc rotate cameras and Free camera
  70539. * @see http://doc.babylonjs.com/features/cameras
  70540. * @param name Defines the name of the camera in the scene
  70541. * @param position Defines the start position of the camera in the scene
  70542. * @param scene Defines the scene the camera belongs to
  70543. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70544. */
  70545. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70546. /**
  70547. * Gets the position in front of the camera at a given distance.
  70548. * @param distance The distance from the camera we want the position to be
  70549. * @returns the position
  70550. */
  70551. getFrontPosition(distance: number): Vector3;
  70552. /** @hidden */
  70553. _getLockedTargetPosition(): Nullable<Vector3>;
  70554. private _storedPosition;
  70555. private _storedRotation;
  70556. private _storedRotationQuaternion;
  70557. /**
  70558. * Store current camera state of the camera (fov, position, rotation, etc..)
  70559. * @returns the camera
  70560. */
  70561. storeState(): Camera;
  70562. /**
  70563. * Restored camera state. You must call storeState() first
  70564. * @returns whether it was successful or not
  70565. * @hidden
  70566. */
  70567. _restoreStateValues(): boolean;
  70568. /** @hidden */
  70569. _initCache(): void;
  70570. /** @hidden */
  70571. _updateCache(ignoreParentClass?: boolean): void;
  70572. /** @hidden */
  70573. _isSynchronizedViewMatrix(): boolean;
  70574. /** @hidden */
  70575. _computeLocalCameraSpeed(): number;
  70576. /**
  70577. * Defines the target the camera should look at.
  70578. * @param target Defines the new target as a Vector or a mesh
  70579. */
  70580. setTarget(target: Vector3): void;
  70581. /**
  70582. * Return the current target position of the camera. This value is expressed in local space.
  70583. * @returns the target position
  70584. */
  70585. getTarget(): Vector3;
  70586. /** @hidden */
  70587. _decideIfNeedsToMove(): boolean;
  70588. /** @hidden */
  70589. _updatePosition(): void;
  70590. /** @hidden */
  70591. _checkInputs(): void;
  70592. protected _updateCameraRotationMatrix(): void;
  70593. /**
  70594. * 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)
  70595. * @returns the current camera
  70596. */
  70597. private _rotateUpVectorWithCameraRotationMatrix;
  70598. private _cachedRotationZ;
  70599. private _cachedQuaternionRotationZ;
  70600. /** @hidden */
  70601. _getViewMatrix(): Matrix;
  70602. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70603. /**
  70604. * @hidden
  70605. */
  70606. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70607. /**
  70608. * @hidden
  70609. */
  70610. _updateRigCameras(): void;
  70611. private _getRigCamPositionAndTarget;
  70612. /**
  70613. * Gets the current object class name.
  70614. * @return the class name
  70615. */
  70616. getClassName(): string;
  70617. }
  70618. }
  70619. declare module BABYLON {
  70620. /**
  70621. * @ignore
  70622. * This is a list of all the different input types that are available in the application.
  70623. * Fo instance: ArcRotateCameraGamepadInput...
  70624. */
  70625. export var CameraInputTypes: {};
  70626. /**
  70627. * This is the contract to implement in order to create a new input class.
  70628. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70629. */
  70630. export interface ICameraInput<TCamera extends Camera> {
  70631. /**
  70632. * Defines the camera the input is attached to.
  70633. */
  70634. camera: Nullable<TCamera>;
  70635. /**
  70636. * Gets the class name of the current intput.
  70637. * @returns the class name
  70638. */
  70639. getClassName(): string;
  70640. /**
  70641. * Get the friendly name associated with the input class.
  70642. * @returns the input friendly name
  70643. */
  70644. getSimpleName(): string;
  70645. /**
  70646. * Attach the input controls to a specific dom element to get the input from.
  70647. * @param element Defines the element the controls should be listened from
  70648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70649. */
  70650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70651. /**
  70652. * Detach the current controls from the specified dom element.
  70653. * @param element Defines the element to stop listening the inputs from
  70654. */
  70655. detachControl(element: Nullable<HTMLElement>): void;
  70656. /**
  70657. * Update the current camera state depending on the inputs that have been used this frame.
  70658. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70659. */
  70660. checkInputs?: () => void;
  70661. }
  70662. /**
  70663. * Represents a map of input types to input instance or input index to input instance.
  70664. */
  70665. export interface CameraInputsMap<TCamera extends Camera> {
  70666. /**
  70667. * Accessor to the input by input type.
  70668. */
  70669. [name: string]: ICameraInput<TCamera>;
  70670. /**
  70671. * Accessor to the input by input index.
  70672. */
  70673. [idx: number]: ICameraInput<TCamera>;
  70674. }
  70675. /**
  70676. * This represents the input manager used within a camera.
  70677. * It helps dealing with all the different kind of input attached to a camera.
  70678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70679. */
  70680. export class CameraInputsManager<TCamera extends Camera> {
  70681. /**
  70682. * Defines the list of inputs attahed to the camera.
  70683. */
  70684. attached: CameraInputsMap<TCamera>;
  70685. /**
  70686. * Defines the dom element the camera is collecting inputs from.
  70687. * This is null if the controls have not been attached.
  70688. */
  70689. attachedElement: Nullable<HTMLElement>;
  70690. /**
  70691. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70692. */
  70693. noPreventDefault: boolean;
  70694. /**
  70695. * Defined the camera the input manager belongs to.
  70696. */
  70697. camera: TCamera;
  70698. /**
  70699. * Update the current camera state depending on the inputs that have been used this frame.
  70700. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70701. */
  70702. checkInputs: () => void;
  70703. /**
  70704. * Instantiate a new Camera Input Manager.
  70705. * @param camera Defines the camera the input manager blongs to
  70706. */
  70707. constructor(camera: TCamera);
  70708. /**
  70709. * Add an input method to a camera
  70710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70711. * @param input camera input method
  70712. */
  70713. add(input: ICameraInput<TCamera>): void;
  70714. /**
  70715. * Remove a specific input method from a camera
  70716. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70717. * @param inputToRemove camera input method
  70718. */
  70719. remove(inputToRemove: ICameraInput<TCamera>): void;
  70720. /**
  70721. * Remove a specific input type from a camera
  70722. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70723. * @param inputType the type of the input to remove
  70724. */
  70725. removeByType(inputType: string): void;
  70726. private _addCheckInputs;
  70727. /**
  70728. * Attach the input controls to the currently attached dom element to listen the events from.
  70729. * @param input Defines the input to attach
  70730. */
  70731. attachInput(input: ICameraInput<TCamera>): void;
  70732. /**
  70733. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70734. * @param element Defines the dom element to collect the events from
  70735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70736. */
  70737. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70738. /**
  70739. * Detach the current manager inputs controls from a specific dom element.
  70740. * @param element Defines the dom element to collect the events from
  70741. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70742. */
  70743. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70744. /**
  70745. * Rebuild the dynamic inputCheck function from the current list of
  70746. * defined inputs in the manager.
  70747. */
  70748. rebuildInputCheck(): void;
  70749. /**
  70750. * Remove all attached input methods from a camera
  70751. */
  70752. clear(): void;
  70753. /**
  70754. * Serialize the current input manager attached to a camera.
  70755. * This ensures than once parsed,
  70756. * the input associated to the camera will be identical to the current ones
  70757. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70758. */
  70759. serialize(serializedCamera: any): void;
  70760. /**
  70761. * Parses an input manager serialized JSON to restore the previous list of inputs
  70762. * and states associated to a camera.
  70763. * @param parsedCamera Defines the JSON to parse
  70764. */
  70765. parse(parsedCamera: any): void;
  70766. }
  70767. }
  70768. declare module BABYLON {
  70769. /**
  70770. * Gather the list of keyboard event types as constants.
  70771. */
  70772. export class KeyboardEventTypes {
  70773. /**
  70774. * The keydown event is fired when a key becomes active (pressed).
  70775. */
  70776. static readonly KEYDOWN: number;
  70777. /**
  70778. * The keyup event is fired when a key has been released.
  70779. */
  70780. static readonly KEYUP: number;
  70781. }
  70782. /**
  70783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70784. */
  70785. export class KeyboardInfo {
  70786. /**
  70787. * Defines the type of event (KeyboardEventTypes)
  70788. */
  70789. type: number;
  70790. /**
  70791. * Defines the related dom event
  70792. */
  70793. event: KeyboardEvent;
  70794. /**
  70795. * Instantiates a new keyboard info.
  70796. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70797. * @param type Defines the type of event (KeyboardEventTypes)
  70798. * @param event Defines the related dom event
  70799. */
  70800. constructor(
  70801. /**
  70802. * Defines the type of event (KeyboardEventTypes)
  70803. */
  70804. type: number,
  70805. /**
  70806. * Defines the related dom event
  70807. */
  70808. event: KeyboardEvent);
  70809. }
  70810. /**
  70811. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70812. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70813. */
  70814. export class KeyboardInfoPre extends KeyboardInfo {
  70815. /**
  70816. * Defines the type of event (KeyboardEventTypes)
  70817. */
  70818. type: number;
  70819. /**
  70820. * Defines the related dom event
  70821. */
  70822. event: KeyboardEvent;
  70823. /**
  70824. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70825. */
  70826. skipOnPointerObservable: boolean;
  70827. /**
  70828. * Instantiates a new keyboard pre info.
  70829. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70830. * @param type Defines the type of event (KeyboardEventTypes)
  70831. * @param event Defines the related dom event
  70832. */
  70833. constructor(
  70834. /**
  70835. * Defines the type of event (KeyboardEventTypes)
  70836. */
  70837. type: number,
  70838. /**
  70839. * Defines the related dom event
  70840. */
  70841. event: KeyboardEvent);
  70842. }
  70843. }
  70844. declare module BABYLON {
  70845. /**
  70846. * Manage the keyboard inputs to control the movement of a free camera.
  70847. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70848. */
  70849. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70850. /**
  70851. * Defines the camera the input is attached to.
  70852. */
  70853. camera: FreeCamera;
  70854. /**
  70855. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70856. */
  70857. keysUp: number[];
  70858. /**
  70859. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70860. */
  70861. keysDown: number[];
  70862. /**
  70863. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70864. */
  70865. keysLeft: number[];
  70866. /**
  70867. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70868. */
  70869. keysRight: number[];
  70870. private _keys;
  70871. private _onCanvasBlurObserver;
  70872. private _onKeyboardObserver;
  70873. private _engine;
  70874. private _scene;
  70875. /**
  70876. * Attach the input controls to a specific dom element to get the input from.
  70877. * @param element Defines the element the controls should be listened from
  70878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70879. */
  70880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70881. /**
  70882. * Detach the current controls from the specified dom element.
  70883. * @param element Defines the element to stop listening the inputs from
  70884. */
  70885. detachControl(element: Nullable<HTMLElement>): void;
  70886. /**
  70887. * Update the current camera state depending on the inputs that have been used this frame.
  70888. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70889. */
  70890. checkInputs(): void;
  70891. /**
  70892. * Gets the class name of the current intput.
  70893. * @returns the class name
  70894. */
  70895. getClassName(): string;
  70896. /** @hidden */
  70897. _onLostFocus(): void;
  70898. /**
  70899. * Get the friendly name associated with the input class.
  70900. * @returns the input friendly name
  70901. */
  70902. getSimpleName(): string;
  70903. }
  70904. }
  70905. declare module BABYLON {
  70906. /**
  70907. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70908. * separate meshes. This can be use to improve performances.
  70909. * @see http://doc.babylonjs.com/how_to/multi_materials
  70910. */
  70911. export class MultiMaterial extends Material {
  70912. private _subMaterials;
  70913. /**
  70914. * Gets or Sets the list of Materials used within the multi material.
  70915. * They need to be ordered according to the submeshes order in the associated mesh
  70916. */
  70917. subMaterials: Nullable<Material>[];
  70918. /**
  70919. * Function used to align with Node.getChildren()
  70920. * @returns the list of Materials used within the multi material
  70921. */
  70922. getChildren(): Nullable<Material>[];
  70923. /**
  70924. * Instantiates a new Multi Material
  70925. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70926. * separate meshes. This can be use to improve performances.
  70927. * @see http://doc.babylonjs.com/how_to/multi_materials
  70928. * @param name Define the name in the scene
  70929. * @param scene Define the scene the material belongs to
  70930. */
  70931. constructor(name: string, scene: Scene);
  70932. private _hookArray;
  70933. /**
  70934. * Get one of the submaterial by its index in the submaterials array
  70935. * @param index The index to look the sub material at
  70936. * @returns The Material if the index has been defined
  70937. */
  70938. getSubMaterial(index: number): Nullable<Material>;
  70939. /**
  70940. * Get the list of active textures for the whole sub materials list.
  70941. * @returns All the textures that will be used during the rendering
  70942. */
  70943. getActiveTextures(): BaseTexture[];
  70944. /**
  70945. * Gets the current class name of the material e.g. "MultiMaterial"
  70946. * Mainly use in serialization.
  70947. * @returns the class name
  70948. */
  70949. getClassName(): string;
  70950. /**
  70951. * Checks if the material is ready to render the requested sub mesh
  70952. * @param mesh Define the mesh the submesh belongs to
  70953. * @param subMesh Define the sub mesh to look readyness for
  70954. * @param useInstances Define whether or not the material is used with instances
  70955. * @returns true if ready, otherwise false
  70956. */
  70957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70958. /**
  70959. * Clones the current material and its related sub materials
  70960. * @param name Define the name of the newly cloned material
  70961. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70962. * @returns the cloned material
  70963. */
  70964. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70965. /**
  70966. * Serializes the materials into a JSON representation.
  70967. * @returns the JSON representation
  70968. */
  70969. serialize(): any;
  70970. /**
  70971. * Dispose the material and release its associated resources
  70972. * @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)
  70973. * @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)
  70974. * @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)
  70975. */
  70976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  70977. /**
  70978. * Creates a MultiMaterial from parsed MultiMaterial data.
  70979. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  70980. * @param scene defines the hosting scene
  70981. * @returns a new MultiMaterial
  70982. */
  70983. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  70984. }
  70985. }
  70986. declare module BABYLON {
  70987. /**
  70988. * Class used to represent data loading progression
  70989. */
  70990. export class SceneLoaderFlags {
  70991. private static _ForceFullSceneLoadingForIncremental;
  70992. private static _ShowLoadingScreen;
  70993. private static _CleanBoneMatrixWeights;
  70994. private static _loggingLevel;
  70995. /**
  70996. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  70997. */
  70998. static ForceFullSceneLoadingForIncremental: boolean;
  70999. /**
  71000. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  71001. */
  71002. static ShowLoadingScreen: boolean;
  71003. /**
  71004. * Defines the current logging level (while loading the scene)
  71005. * @ignorenaming
  71006. */
  71007. static loggingLevel: number;
  71008. /**
  71009. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  71010. */
  71011. static CleanBoneMatrixWeights: boolean;
  71012. }
  71013. }
  71014. declare module BABYLON {
  71015. /**
  71016. * 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.
  71017. * @see https://doc.babylonjs.com/how_to/transformnode
  71018. */
  71019. export class TransformNode extends Node {
  71020. /**
  71021. * Object will not rotate to face the camera
  71022. */
  71023. static BILLBOARDMODE_NONE: number;
  71024. /**
  71025. * Object will rotate to face the camera but only on the x axis
  71026. */
  71027. static BILLBOARDMODE_X: number;
  71028. /**
  71029. * Object will rotate to face the camera but only on the y axis
  71030. */
  71031. static BILLBOARDMODE_Y: number;
  71032. /**
  71033. * Object will rotate to face the camera but only on the z axis
  71034. */
  71035. static BILLBOARDMODE_Z: number;
  71036. /**
  71037. * Object will rotate to face the camera
  71038. */
  71039. static BILLBOARDMODE_ALL: number;
  71040. private _forward;
  71041. private _forwardInverted;
  71042. private _up;
  71043. private _right;
  71044. private _rightInverted;
  71045. private _position;
  71046. private _rotation;
  71047. private _rotationQuaternion;
  71048. protected _scaling: Vector3;
  71049. protected _isDirty: boolean;
  71050. private _transformToBoneReferal;
  71051. private _billboardMode;
  71052. /**
  71053. * Gets or sets the billboard mode. Default is 0.
  71054. *
  71055. * | Value | Type | Description |
  71056. * | --- | --- | --- |
  71057. * | 0 | BILLBOARDMODE_NONE | |
  71058. * | 1 | BILLBOARDMODE_X | |
  71059. * | 2 | BILLBOARDMODE_Y | |
  71060. * | 4 | BILLBOARDMODE_Z | |
  71061. * | 7 | BILLBOARDMODE_ALL | |
  71062. *
  71063. */
  71064. billboardMode: number;
  71065. private _preserveParentRotationForBillboard;
  71066. /**
  71067. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71068. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71069. */
  71070. preserveParentRotationForBillboard: boolean;
  71071. /**
  71072. * 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
  71073. */
  71074. scalingDeterminant: number;
  71075. private _infiniteDistance;
  71076. /**
  71077. * Gets or sets the distance of the object to max, often used by skybox
  71078. */
  71079. infiniteDistance: boolean;
  71080. /**
  71081. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71082. * By default the system will update normals to compensate
  71083. */
  71084. ignoreNonUniformScaling: boolean;
  71085. /**
  71086. * 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
  71087. */
  71088. reIntegrateRotationIntoRotationQuaternion: boolean;
  71089. /** @hidden */
  71090. _poseMatrix: Nullable<Matrix>;
  71091. /** @hidden */
  71092. _localMatrix: Matrix;
  71093. private _usePivotMatrix;
  71094. private _absolutePosition;
  71095. private _pivotMatrix;
  71096. private _pivotMatrixInverse;
  71097. protected _postMultiplyPivotMatrix: boolean;
  71098. protected _isWorldMatrixFrozen: boolean;
  71099. /** @hidden */
  71100. _indexInSceneTransformNodesArray: number;
  71101. /**
  71102. * An event triggered after the world matrix is updated
  71103. */
  71104. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71105. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71106. /**
  71107. * Gets a string identifying the name of the class
  71108. * @returns "TransformNode" string
  71109. */
  71110. getClassName(): string;
  71111. /**
  71112. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71113. */
  71114. position: Vector3;
  71115. /**
  71116. * 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)).
  71117. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71118. */
  71119. rotation: Vector3;
  71120. /**
  71121. * 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)).
  71122. */
  71123. scaling: Vector3;
  71124. /**
  71125. * 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).
  71126. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71127. */
  71128. rotationQuaternion: Nullable<Quaternion>;
  71129. /**
  71130. * The forward direction of that transform in world space.
  71131. */
  71132. readonly forward: Vector3;
  71133. /**
  71134. * The up direction of that transform in world space.
  71135. */
  71136. readonly up: Vector3;
  71137. /**
  71138. * The right direction of that transform in world space.
  71139. */
  71140. readonly right: Vector3;
  71141. /**
  71142. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71143. * @param matrix the matrix to copy the pose from
  71144. * @returns this TransformNode.
  71145. */
  71146. updatePoseMatrix(matrix: Matrix): TransformNode;
  71147. /**
  71148. * Returns the mesh Pose matrix.
  71149. * @returns the pose matrix
  71150. */
  71151. getPoseMatrix(): Matrix;
  71152. /** @hidden */
  71153. _isSynchronized(): boolean;
  71154. /** @hidden */
  71155. _initCache(): void;
  71156. /**
  71157. * Flag the transform node as dirty (Forcing it to update everything)
  71158. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71159. * @returns this transform node
  71160. */
  71161. markAsDirty(property: string): TransformNode;
  71162. /**
  71163. * Returns the current mesh absolute position.
  71164. * Returns a Vector3.
  71165. */
  71166. readonly absolutePosition: Vector3;
  71167. /**
  71168. * Sets a new matrix to apply before all other transformation
  71169. * @param matrix defines the transform matrix
  71170. * @returns the current TransformNode
  71171. */
  71172. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71173. /**
  71174. * Sets a new pivot matrix to the current node
  71175. * @param matrix defines the new pivot matrix to use
  71176. * @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
  71177. * @returns the current TransformNode
  71178. */
  71179. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71180. /**
  71181. * Returns the mesh pivot matrix.
  71182. * Default : Identity.
  71183. * @returns the matrix
  71184. */
  71185. getPivotMatrix(): Matrix;
  71186. /**
  71187. * Prevents the World matrix to be computed any longer.
  71188. * @returns the TransformNode.
  71189. */
  71190. freezeWorldMatrix(): TransformNode;
  71191. /**
  71192. * Allows back the World matrix computation.
  71193. * @returns the TransformNode.
  71194. */
  71195. unfreezeWorldMatrix(): this;
  71196. /**
  71197. * True if the World matrix has been frozen.
  71198. */
  71199. readonly isWorldMatrixFrozen: boolean;
  71200. /**
  71201. * Retuns the mesh absolute position in the World.
  71202. * @returns a Vector3.
  71203. */
  71204. getAbsolutePosition(): Vector3;
  71205. /**
  71206. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71207. * @param absolutePosition the absolute position to set
  71208. * @returns the TransformNode.
  71209. */
  71210. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71211. /**
  71212. * Sets the mesh position in its local space.
  71213. * @param vector3 the position to set in localspace
  71214. * @returns the TransformNode.
  71215. */
  71216. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71217. /**
  71218. * Returns the mesh position in the local space from the current World matrix values.
  71219. * @returns a new Vector3.
  71220. */
  71221. getPositionExpressedInLocalSpace(): Vector3;
  71222. /**
  71223. * Translates the mesh along the passed Vector3 in its local space.
  71224. * @param vector3 the distance to translate in localspace
  71225. * @returns the TransformNode.
  71226. */
  71227. locallyTranslate(vector3: Vector3): TransformNode;
  71228. private static _lookAtVectorCache;
  71229. /**
  71230. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71231. * @param targetPoint the position (must be in same space as current mesh) to look at
  71232. * @param yawCor optional yaw (y-axis) correction in radians
  71233. * @param pitchCor optional pitch (x-axis) correction in radians
  71234. * @param rollCor optional roll (z-axis) correction in radians
  71235. * @param space the choosen space of the target
  71236. * @returns the TransformNode.
  71237. */
  71238. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71239. /**
  71240. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71241. * This Vector3 is expressed in the World space.
  71242. * @param localAxis axis to rotate
  71243. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71244. */
  71245. getDirection(localAxis: Vector3): Vector3;
  71246. /**
  71247. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71248. * localAxis is expressed in the mesh local space.
  71249. * result is computed in the Wordl space from the mesh World matrix.
  71250. * @param localAxis axis to rotate
  71251. * @param result the resulting transformnode
  71252. * @returns this TransformNode.
  71253. */
  71254. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71255. /**
  71256. * Sets this transform node rotation to the given local axis.
  71257. * @param localAxis the axis in local space
  71258. * @param yawCor optional yaw (y-axis) correction in radians
  71259. * @param pitchCor optional pitch (x-axis) correction in radians
  71260. * @param rollCor optional roll (z-axis) correction in radians
  71261. * @returns this TransformNode
  71262. */
  71263. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71264. /**
  71265. * Sets a new pivot point to the current node
  71266. * @param point defines the new pivot point to use
  71267. * @param space defines if the point is in world or local space (local by default)
  71268. * @returns the current TransformNode
  71269. */
  71270. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71271. /**
  71272. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71273. * @returns the pivot point
  71274. */
  71275. getPivotPoint(): Vector3;
  71276. /**
  71277. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71278. * @param result the vector3 to store the result
  71279. * @returns this TransformNode.
  71280. */
  71281. getPivotPointToRef(result: Vector3): TransformNode;
  71282. /**
  71283. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71284. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71285. */
  71286. getAbsolutePivotPoint(): Vector3;
  71287. /**
  71288. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71289. * @param result vector3 to store the result
  71290. * @returns this TransformNode.
  71291. */
  71292. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71293. /**
  71294. * Defines the passed node as the parent of the current node.
  71295. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71296. * @see https://doc.babylonjs.com/how_to/parenting
  71297. * @param node the node ot set as the parent
  71298. * @returns this TransformNode.
  71299. */
  71300. setParent(node: Nullable<Node>): TransformNode;
  71301. private _nonUniformScaling;
  71302. /**
  71303. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71304. */
  71305. readonly nonUniformScaling: boolean;
  71306. /** @hidden */
  71307. _updateNonUniformScalingState(value: boolean): boolean;
  71308. /**
  71309. * Attach the current TransformNode to another TransformNode associated with a bone
  71310. * @param bone Bone affecting the TransformNode
  71311. * @param affectedTransformNode TransformNode associated with the bone
  71312. * @returns this object
  71313. */
  71314. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71315. /**
  71316. * Detach the transform node if its associated with a bone
  71317. * @returns this object
  71318. */
  71319. detachFromBone(): TransformNode;
  71320. private static _rotationAxisCache;
  71321. /**
  71322. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71323. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71324. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71325. * The passed axis is also normalized.
  71326. * @param axis the axis to rotate around
  71327. * @param amount the amount to rotate in radians
  71328. * @param space Space to rotate in (Default: local)
  71329. * @returns the TransformNode.
  71330. */
  71331. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71332. /**
  71333. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71334. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71335. * The passed axis is also normalized. .
  71336. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71337. * @param point the point to rotate around
  71338. * @param axis the axis to rotate around
  71339. * @param amount the amount to rotate in radians
  71340. * @returns the TransformNode
  71341. */
  71342. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71343. /**
  71344. * Translates the mesh along the axis vector for the passed distance in the given space.
  71345. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71346. * @param axis the axis to translate in
  71347. * @param distance the distance to translate
  71348. * @param space Space to rotate in (Default: local)
  71349. * @returns the TransformNode.
  71350. */
  71351. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71352. /**
  71353. * Adds a rotation step to the mesh current rotation.
  71354. * x, y, z are Euler angles expressed in radians.
  71355. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71356. * This means this rotation is made in the mesh local space only.
  71357. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71358. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71359. * ```javascript
  71360. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71361. * ```
  71362. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71363. * 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.
  71364. * @param x Rotation to add
  71365. * @param y Rotation to add
  71366. * @param z Rotation to add
  71367. * @returns the TransformNode.
  71368. */
  71369. addRotation(x: number, y: number, z: number): TransformNode;
  71370. /**
  71371. * @hidden
  71372. */
  71373. protected _getEffectiveParent(): Nullable<Node>;
  71374. /**
  71375. * Computes the world matrix of the node
  71376. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71377. * @returns the world matrix
  71378. */
  71379. computeWorldMatrix(force?: boolean): Matrix;
  71380. protected _afterComputeWorldMatrix(): void;
  71381. /**
  71382. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71383. * @param func callback function to add
  71384. *
  71385. * @returns the TransformNode.
  71386. */
  71387. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71388. /**
  71389. * Removes a registered callback function.
  71390. * @param func callback function to remove
  71391. * @returns the TransformNode.
  71392. */
  71393. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71394. /**
  71395. * Gets the position of the current mesh in camera space
  71396. * @param camera defines the camera to use
  71397. * @returns a position
  71398. */
  71399. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71400. /**
  71401. * Returns the distance from the mesh to the active camera
  71402. * @param camera defines the camera to use
  71403. * @returns the distance
  71404. */
  71405. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71406. /**
  71407. * Clone the current transform node
  71408. * @param name Name of the new clone
  71409. * @param newParent New parent for the clone
  71410. * @param doNotCloneChildren Do not clone children hierarchy
  71411. * @returns the new transform node
  71412. */
  71413. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71414. /**
  71415. * Serializes the objects information.
  71416. * @param currentSerializationObject defines the object to serialize in
  71417. * @returns the serialized object
  71418. */
  71419. serialize(currentSerializationObject?: any): any;
  71420. /**
  71421. * Returns a new TransformNode object parsed from the source provided.
  71422. * @param parsedTransformNode is the source.
  71423. * @param scene the scne the object belongs to
  71424. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71425. * @returns a new TransformNode object parsed from the source provided.
  71426. */
  71427. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71428. /**
  71429. * Get all child-transformNodes of this node
  71430. * @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
  71431. * @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
  71432. * @returns an array of TransformNode
  71433. */
  71434. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71435. /**
  71436. * Releases resources associated with this transform node.
  71437. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71438. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71439. */
  71440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71441. /**
  71442. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71443. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71444. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71445. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71446. * @returns the current mesh
  71447. */
  71448. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71449. }
  71450. }
  71451. declare module BABYLON {
  71452. /**
  71453. * Class used to override all child animations of a given target
  71454. */
  71455. export class AnimationPropertiesOverride {
  71456. /**
  71457. * Gets or sets a value indicating if animation blending must be used
  71458. */
  71459. enableBlending: boolean;
  71460. /**
  71461. * Gets or sets the blending speed to use when enableBlending is true
  71462. */
  71463. blendingSpeed: number;
  71464. /**
  71465. * Gets or sets the default loop mode to use
  71466. */
  71467. loopMode: number;
  71468. }
  71469. }
  71470. declare module BABYLON {
  71471. /**
  71472. * Class used to store bone information
  71473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71474. */
  71475. export class Bone extends Node {
  71476. /**
  71477. * defines the bone name
  71478. */
  71479. name: string;
  71480. private static _tmpVecs;
  71481. private static _tmpQuat;
  71482. private static _tmpMats;
  71483. /**
  71484. * Gets the list of child bones
  71485. */
  71486. children: Bone[];
  71487. /** Gets the animations associated with this bone */
  71488. animations: Animation[];
  71489. /**
  71490. * Gets or sets bone length
  71491. */
  71492. length: number;
  71493. /**
  71494. * @hidden Internal only
  71495. * Set this value to map this bone to a different index in the transform matrices
  71496. * Set this value to -1 to exclude the bone from the transform matrices
  71497. */
  71498. _index: Nullable<number>;
  71499. private _skeleton;
  71500. private _localMatrix;
  71501. private _restPose;
  71502. private _baseMatrix;
  71503. private _absoluteTransform;
  71504. private _invertedAbsoluteTransform;
  71505. private _parent;
  71506. private _scalingDeterminant;
  71507. private _worldTransform;
  71508. private _localScaling;
  71509. private _localRotation;
  71510. private _localPosition;
  71511. private _needToDecompose;
  71512. private _needToCompose;
  71513. /** @hidden */
  71514. _linkedTransformNode: Nullable<TransformNode>;
  71515. /** @hidden */
  71516. _waitingTransformNodeId: Nullable<string>;
  71517. /** @hidden */
  71518. /** @hidden */
  71519. _matrix: Matrix;
  71520. /**
  71521. * Create a new bone
  71522. * @param name defines the bone name
  71523. * @param skeleton defines the parent skeleton
  71524. * @param parentBone defines the parent (can be null if the bone is the root)
  71525. * @param localMatrix defines the local matrix
  71526. * @param restPose defines the rest pose matrix
  71527. * @param baseMatrix defines the base matrix
  71528. * @param index defines index of the bone in the hiearchy
  71529. */
  71530. constructor(
  71531. /**
  71532. * defines the bone name
  71533. */
  71534. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71535. /**
  71536. * Gets the current object class name.
  71537. * @return the class name
  71538. */
  71539. getClassName(): string;
  71540. /**
  71541. * Gets the parent skeleton
  71542. * @returns a skeleton
  71543. */
  71544. getSkeleton(): Skeleton;
  71545. /**
  71546. * Gets parent bone
  71547. * @returns a bone or null if the bone is the root of the bone hierarchy
  71548. */
  71549. getParent(): Nullable<Bone>;
  71550. /**
  71551. * Returns an array containing the root bones
  71552. * @returns an array containing the root bones
  71553. */
  71554. getChildren(): Array<Bone>;
  71555. /**
  71556. * Sets the parent bone
  71557. * @param parent defines the parent (can be null if the bone is the root)
  71558. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71559. */
  71560. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71561. /**
  71562. * Gets the local matrix
  71563. * @returns a matrix
  71564. */
  71565. getLocalMatrix(): Matrix;
  71566. /**
  71567. * Gets the base matrix (initial matrix which remains unchanged)
  71568. * @returns a matrix
  71569. */
  71570. getBaseMatrix(): Matrix;
  71571. /**
  71572. * Gets the rest pose matrix
  71573. * @returns a matrix
  71574. */
  71575. getRestPose(): Matrix;
  71576. /**
  71577. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71578. */
  71579. getWorldMatrix(): Matrix;
  71580. /**
  71581. * Sets the local matrix to rest pose matrix
  71582. */
  71583. returnToRest(): void;
  71584. /**
  71585. * Gets the inverse of the absolute transform matrix.
  71586. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71587. * @returns a matrix
  71588. */
  71589. getInvertedAbsoluteTransform(): Matrix;
  71590. /**
  71591. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71592. * @returns a matrix
  71593. */
  71594. getAbsoluteTransform(): Matrix;
  71595. /**
  71596. * Links with the given transform node.
  71597. * The local matrix of this bone is copied from the transform node every frame.
  71598. * @param transformNode defines the transform node to link to
  71599. */
  71600. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71601. /** Gets or sets current position (in local space) */
  71602. position: Vector3;
  71603. /** Gets or sets current rotation (in local space) */
  71604. rotation: Vector3;
  71605. /** Gets or sets current rotation quaternion (in local space) */
  71606. rotationQuaternion: Quaternion;
  71607. /** Gets or sets current scaling (in local space) */
  71608. scaling: Vector3;
  71609. /**
  71610. * Gets the animation properties override
  71611. */
  71612. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71613. private _decompose;
  71614. private _compose;
  71615. /**
  71616. * Update the base and local matrices
  71617. * @param matrix defines the new base or local matrix
  71618. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71619. * @param updateLocalMatrix defines if the local matrix should be updated
  71620. */
  71621. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71622. /** @hidden */
  71623. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71624. /**
  71625. * Flag the bone as dirty (Forcing it to update everything)
  71626. */
  71627. markAsDirty(): void;
  71628. /** @hidden */
  71629. _markAsDirtyAndCompose(): void;
  71630. private _markAsDirtyAndDecompose;
  71631. /**
  71632. * Translate the bone in local or world space
  71633. * @param vec The amount to translate the bone
  71634. * @param space The space that the translation is in
  71635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71636. */
  71637. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71638. /**
  71639. * Set the postion of the bone in local or world space
  71640. * @param position The position to set the bone
  71641. * @param space The space that the position is in
  71642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71643. */
  71644. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71645. /**
  71646. * Set the absolute position of the bone (world space)
  71647. * @param position The position to set the bone
  71648. * @param mesh The mesh that this bone is attached to
  71649. */
  71650. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71651. /**
  71652. * Scale the bone on the x, y and z axes (in local space)
  71653. * @param x The amount to scale the bone on the x axis
  71654. * @param y The amount to scale the bone on the y axis
  71655. * @param z The amount to scale the bone on the z axis
  71656. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71657. */
  71658. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71659. /**
  71660. * Set the bone scaling in local space
  71661. * @param scale defines the scaling vector
  71662. */
  71663. setScale(scale: Vector3): void;
  71664. /**
  71665. * Gets the current scaling in local space
  71666. * @returns the current scaling vector
  71667. */
  71668. getScale(): Vector3;
  71669. /**
  71670. * Gets the current scaling in local space and stores it in a target vector
  71671. * @param result defines the target vector
  71672. */
  71673. getScaleToRef(result: Vector3): void;
  71674. /**
  71675. * Set the yaw, pitch, and roll of the bone in local or world space
  71676. * @param yaw The rotation of the bone on the y axis
  71677. * @param pitch The rotation of the bone on the x axis
  71678. * @param roll The rotation of the bone on the z axis
  71679. * @param space The space that the axes of rotation are in
  71680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71681. */
  71682. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71683. /**
  71684. * Add a rotation to the bone on an axis in local or world space
  71685. * @param axis The axis to rotate the bone on
  71686. * @param amount The amount to rotate the bone
  71687. * @param space The space that the axis is in
  71688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71689. */
  71690. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71691. /**
  71692. * Set the rotation of the bone to a particular axis angle in local or world space
  71693. * @param axis The axis to rotate the bone on
  71694. * @param angle The angle that the bone should be rotated to
  71695. * @param space The space that the axis is in
  71696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71697. */
  71698. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71699. /**
  71700. * Set the euler rotation of the bone in local of world space
  71701. * @param rotation The euler rotation that the bone should be set to
  71702. * @param space The space that the rotation is in
  71703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71704. */
  71705. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71706. /**
  71707. * Set the quaternion rotation of the bone in local of world space
  71708. * @param quat The quaternion rotation that the bone should be set to
  71709. * @param space The space that the rotation is in
  71710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71711. */
  71712. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71713. /**
  71714. * Set the rotation matrix of the bone in local of world space
  71715. * @param rotMat The rotation matrix that the bone should be set to
  71716. * @param space The space that the rotation is in
  71717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71718. */
  71719. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71720. private _rotateWithMatrix;
  71721. private _getNegativeRotationToRef;
  71722. /**
  71723. * Get the position of the bone in local or world space
  71724. * @param space The space that the returned position is in
  71725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71726. * @returns The position of the bone
  71727. */
  71728. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71729. /**
  71730. * Copy the position of the bone to a vector3 in local or world space
  71731. * @param space The space that the returned position is in
  71732. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71733. * @param result The vector3 to copy the position to
  71734. */
  71735. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71736. /**
  71737. * Get the absolute position of the bone (world space)
  71738. * @param mesh The mesh that this bone is attached to
  71739. * @returns The absolute position of the bone
  71740. */
  71741. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71742. /**
  71743. * Copy the absolute position of the bone (world space) to the result param
  71744. * @param mesh The mesh that this bone is attached to
  71745. * @param result The vector3 to copy the absolute position to
  71746. */
  71747. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71748. /**
  71749. * Compute the absolute transforms of this bone and its children
  71750. */
  71751. computeAbsoluteTransforms(): void;
  71752. /**
  71753. * Get the world direction from an axis that is in the local space of the bone
  71754. * @param localAxis The local direction that is used to compute the world direction
  71755. * @param mesh The mesh that this bone is attached to
  71756. * @returns The world direction
  71757. */
  71758. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71759. /**
  71760. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71761. * @param localAxis The local direction that is used to compute the world direction
  71762. * @param mesh The mesh that this bone is attached to
  71763. * @param result The vector3 that the world direction will be copied to
  71764. */
  71765. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71766. /**
  71767. * Get the euler rotation of the bone in local or world space
  71768. * @param space The space that the rotation should be in
  71769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71770. * @returns The euler rotation
  71771. */
  71772. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71773. /**
  71774. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71775. * @param space The space that the rotation should be in
  71776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71777. * @param result The vector3 that the rotation should be copied to
  71778. */
  71779. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71780. /**
  71781. * Get the quaternion rotation of the bone in either local or world space
  71782. * @param space The space that the rotation should be in
  71783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71784. * @returns The quaternion rotation
  71785. */
  71786. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71787. /**
  71788. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71789. * @param space The space that the rotation should be in
  71790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71791. * @param result The quaternion that the rotation should be copied to
  71792. */
  71793. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71794. /**
  71795. * Get the rotation matrix of the bone in local or world space
  71796. * @param space The space that the rotation should be in
  71797. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71798. * @returns The rotation matrix
  71799. */
  71800. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71801. /**
  71802. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71803. * @param space The space that the rotation should be in
  71804. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71805. * @param result The quaternion that the rotation should be copied to
  71806. */
  71807. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71808. /**
  71809. * Get the world position of a point that is in the local space of the bone
  71810. * @param position The local position
  71811. * @param mesh The mesh that this bone is attached to
  71812. * @returns The world position
  71813. */
  71814. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71815. /**
  71816. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71817. * @param position The local position
  71818. * @param mesh The mesh that this bone is attached to
  71819. * @param result The vector3 that the world position should be copied to
  71820. */
  71821. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71822. /**
  71823. * Get the local position of a point that is in world space
  71824. * @param position The world position
  71825. * @param mesh The mesh that this bone is attached to
  71826. * @returns The local position
  71827. */
  71828. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71829. /**
  71830. * Get the local position of a point that is in world space and copy it to the result param
  71831. * @param position The world position
  71832. * @param mesh The mesh that this bone is attached to
  71833. * @param result The vector3 that the local position should be copied to
  71834. */
  71835. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71836. }
  71837. }
  71838. declare module BABYLON {
  71839. interface Engine {
  71840. /**
  71841. * Creates a raw texture
  71842. * @param data defines the data to store in the texture
  71843. * @param width defines the width of the texture
  71844. * @param height defines the height of the texture
  71845. * @param format defines the format of the data
  71846. * @param generateMipMaps defines if the engine should generate the mip levels
  71847. * @param invertY defines if data must be stored with Y axis inverted
  71848. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71849. * @param compression defines the compression used (null by default)
  71850. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71851. * @returns the raw texture inside an InternalTexture
  71852. */
  71853. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71854. /**
  71855. * Update a raw texture
  71856. * @param texture defines the texture to update
  71857. * @param data defines the data to store in the texture
  71858. * @param format defines the format of the data
  71859. * @param invertY defines if data must be stored with Y axis inverted
  71860. */
  71861. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71862. /**
  71863. * Update a raw texture
  71864. * @param texture defines the texture to update
  71865. * @param data defines the data to store in the texture
  71866. * @param format defines the format of the data
  71867. * @param invertY defines if data must be stored with Y axis inverted
  71868. * @param compression defines the compression used (null by default)
  71869. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71870. */
  71871. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71872. /**
  71873. * Creates a new raw cube texture
  71874. * @param data defines the array of data to use to create each face
  71875. * @param size defines the size of the textures
  71876. * @param format defines the format of the data
  71877. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71878. * @param generateMipMaps defines if the engine should generate the mip levels
  71879. * @param invertY defines if data must be stored with Y axis inverted
  71880. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71881. * @param compression defines the compression used (null by default)
  71882. * @returns the cube texture as an InternalTexture
  71883. */
  71884. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71885. /**
  71886. * Update a raw cube texture
  71887. * @param texture defines the texture to udpdate
  71888. * @param data defines the data to store
  71889. * @param format defines the data format
  71890. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71891. * @param invertY defines if data must be stored with Y axis inverted
  71892. */
  71893. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71894. /**
  71895. * Update a raw cube texture
  71896. * @param texture defines the texture to udpdate
  71897. * @param data defines the data to store
  71898. * @param format defines the data format
  71899. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71900. * @param invertY defines if data must be stored with Y axis inverted
  71901. * @param compression defines the compression used (null by default)
  71902. */
  71903. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71904. /**
  71905. * Update a raw cube texture
  71906. * @param texture defines the texture to udpdate
  71907. * @param data defines the data to store
  71908. * @param format defines the data format
  71909. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71910. * @param invertY defines if data must be stored with Y axis inverted
  71911. * @param compression defines the compression used (null by default)
  71912. * @param level defines which level of the texture to update
  71913. */
  71914. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71915. /**
  71916. * Creates a new raw cube texture from a specified url
  71917. * @param url defines the url where the data is located
  71918. * @param scene defines the current scene
  71919. * @param size defines the size of the textures
  71920. * @param format defines the format of the data
  71921. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71922. * @param noMipmap defines if the engine should avoid generating the mip levels
  71923. * @param callback defines a callback used to extract texture data from loaded data
  71924. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71925. * @param onLoad defines a callback called when texture is loaded
  71926. * @param onError defines a callback called if there is an error
  71927. * @returns the cube texture as an InternalTexture
  71928. */
  71929. 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;
  71930. /**
  71931. * Creates a new raw cube texture from a specified url
  71932. * @param url defines the url where the data is located
  71933. * @param scene defines the current scene
  71934. * @param size defines the size of the textures
  71935. * @param format defines the format of the data
  71936. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71937. * @param noMipmap defines if the engine should avoid generating the mip levels
  71938. * @param callback defines a callback used to extract texture data from loaded data
  71939. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71940. * @param onLoad defines a callback called when texture is loaded
  71941. * @param onError defines a callback called if there is an error
  71942. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71943. * @param invertY defines if data must be stored with Y axis inverted
  71944. * @returns the cube texture as an InternalTexture
  71945. */
  71946. 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;
  71947. /**
  71948. * Creates a new raw 3D texture
  71949. * @param data defines the data used to create the texture
  71950. * @param width defines the width of the texture
  71951. * @param height defines the height of the texture
  71952. * @param depth defines the depth of the texture
  71953. * @param format defines the format of the texture
  71954. * @param generateMipMaps defines if the engine must generate mip levels
  71955. * @param invertY defines if data must be stored with Y axis inverted
  71956. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71957. * @param compression defines the compressed used (can be null)
  71958. * @param textureType defines the compressed used (can be null)
  71959. * @returns a new raw 3D texture (stored in an InternalTexture)
  71960. */
  71961. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71962. /**
  71963. * Update a raw 3D texture
  71964. * @param texture defines the texture to update
  71965. * @param data defines the data to store
  71966. * @param format defines the data format
  71967. * @param invertY defines if data must be stored with Y axis inverted
  71968. */
  71969. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71970. /**
  71971. * Update a raw 3D texture
  71972. * @param texture defines the texture to update
  71973. * @param data defines the data to store
  71974. * @param format defines the data format
  71975. * @param invertY defines if data must be stored with Y axis inverted
  71976. * @param compression defines the used compression (can be null)
  71977. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  71978. */
  71979. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  71980. }
  71981. }
  71982. declare module BABYLON {
  71983. /**
  71984. * Raw texture can help creating a texture directly from an array of data.
  71985. * This can be super useful if you either get the data from an uncompressed source or
  71986. * if you wish to create your texture pixel by pixel.
  71987. */
  71988. export class RawTexture extends Texture {
  71989. /**
  71990. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71991. */
  71992. format: number;
  71993. private _engine;
  71994. /**
  71995. * Instantiates a new RawTexture.
  71996. * Raw texture can help creating a texture directly from an array of data.
  71997. * This can be super useful if you either get the data from an uncompressed source or
  71998. * if you wish to create your texture pixel by pixel.
  71999. * @param data define the array of data to use to create the texture
  72000. * @param width define the width of the texture
  72001. * @param height define the height of the texture
  72002. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72003. * @param scene define the scene the texture belongs to
  72004. * @param generateMipMaps define whether mip maps should be generated or not
  72005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72007. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72008. */
  72009. constructor(data: ArrayBufferView, width: number, height: number,
  72010. /**
  72011. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  72012. */
  72013. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  72014. /**
  72015. * Updates the texture underlying data.
  72016. * @param data Define the new data of the texture
  72017. */
  72018. update(data: ArrayBufferView): void;
  72019. /**
  72020. * Creates a luminance texture from some data.
  72021. * @param data Define the texture data
  72022. * @param width Define the width of the texture
  72023. * @param height Define the height of the texture
  72024. * @param scene Define the scene the texture belongs to
  72025. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72026. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72027. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72028. * @returns the luminance texture
  72029. */
  72030. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72031. /**
  72032. * Creates a luminance alpha texture from some data.
  72033. * @param data Define the texture data
  72034. * @param width Define the width of the texture
  72035. * @param height Define the height of the texture
  72036. * @param scene Define the scene the texture belongs to
  72037. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72038. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72039. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72040. * @returns the luminance alpha texture
  72041. */
  72042. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72043. /**
  72044. * Creates an alpha 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 alpha texture
  72053. */
  72054. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72055. /**
  72056. * Creates a RGB 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72065. * @returns the RGB alpha texture
  72066. */
  72067. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72068. /**
  72069. * Creates a RGBA texture from some data.
  72070. * @param data Define the texture data
  72071. * @param width Define the width of the texture
  72072. * @param height Define the height of the texture
  72073. * @param scene Define the scene the texture belongs to
  72074. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72075. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72076. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72077. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72078. * @returns the RGBA texture
  72079. */
  72080. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72081. /**
  72082. * Creates a R texture from some data.
  72083. * @param data Define the texture data
  72084. * @param width Define the width of the texture
  72085. * @param height Define the height of the texture
  72086. * @param scene Define the scene the texture belongs to
  72087. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72088. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72089. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72090. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72091. * @returns the R texture
  72092. */
  72093. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72094. }
  72095. }
  72096. declare module BABYLON {
  72097. /**
  72098. * Defines a runtime animation
  72099. */
  72100. export class RuntimeAnimation {
  72101. private _events;
  72102. /**
  72103. * The current frame of the runtime animation
  72104. */
  72105. private _currentFrame;
  72106. /**
  72107. * The animation used by the runtime animation
  72108. */
  72109. private _animation;
  72110. /**
  72111. * The target of the runtime animation
  72112. */
  72113. private _target;
  72114. /**
  72115. * The initiating animatable
  72116. */
  72117. private _host;
  72118. /**
  72119. * The original value of the runtime animation
  72120. */
  72121. private _originalValue;
  72122. /**
  72123. * The original blend value of the runtime animation
  72124. */
  72125. private _originalBlendValue;
  72126. /**
  72127. * The offsets cache of the runtime animation
  72128. */
  72129. private _offsetsCache;
  72130. /**
  72131. * The high limits cache of the runtime animation
  72132. */
  72133. private _highLimitsCache;
  72134. /**
  72135. * Specifies if the runtime animation has been stopped
  72136. */
  72137. private _stopped;
  72138. /**
  72139. * The blending factor of the runtime animation
  72140. */
  72141. private _blendingFactor;
  72142. /**
  72143. * The BabylonJS scene
  72144. */
  72145. private _scene;
  72146. /**
  72147. * The current value of the runtime animation
  72148. */
  72149. private _currentValue;
  72150. /** @hidden */
  72151. _animationState: _IAnimationState;
  72152. /**
  72153. * The active target of the runtime animation
  72154. */
  72155. private _activeTargets;
  72156. private _currentActiveTarget;
  72157. private _directTarget;
  72158. /**
  72159. * The target path of the runtime animation
  72160. */
  72161. private _targetPath;
  72162. /**
  72163. * The weight of the runtime animation
  72164. */
  72165. private _weight;
  72166. /**
  72167. * The ratio offset of the runtime animation
  72168. */
  72169. private _ratioOffset;
  72170. /**
  72171. * The previous delay of the runtime animation
  72172. */
  72173. private _previousDelay;
  72174. /**
  72175. * The previous ratio of the runtime animation
  72176. */
  72177. private _previousRatio;
  72178. private _enableBlending;
  72179. private _keys;
  72180. private _minFrame;
  72181. private _maxFrame;
  72182. private _minValue;
  72183. private _maxValue;
  72184. private _targetIsArray;
  72185. /**
  72186. * Gets the current frame of the runtime animation
  72187. */
  72188. readonly currentFrame: number;
  72189. /**
  72190. * Gets the weight of the runtime animation
  72191. */
  72192. readonly weight: number;
  72193. /**
  72194. * Gets the current value of the runtime animation
  72195. */
  72196. readonly currentValue: any;
  72197. /**
  72198. * Gets the target path of the runtime animation
  72199. */
  72200. readonly targetPath: string;
  72201. /**
  72202. * Gets the actual target of the runtime animation
  72203. */
  72204. readonly target: any;
  72205. /** @hidden */
  72206. _onLoop: () => void;
  72207. /**
  72208. * Create a new RuntimeAnimation object
  72209. * @param target defines the target of the animation
  72210. * @param animation defines the source animation object
  72211. * @param scene defines the hosting scene
  72212. * @param host defines the initiating Animatable
  72213. */
  72214. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72215. private _preparePath;
  72216. /**
  72217. * Gets the animation from the runtime animation
  72218. */
  72219. readonly animation: Animation;
  72220. /**
  72221. * Resets the runtime animation to the beginning
  72222. * @param restoreOriginal defines whether to restore the target property to the original value
  72223. */
  72224. reset(restoreOriginal?: boolean): void;
  72225. /**
  72226. * Specifies if the runtime animation is stopped
  72227. * @returns Boolean specifying if the runtime animation is stopped
  72228. */
  72229. isStopped(): boolean;
  72230. /**
  72231. * Disposes of the runtime animation
  72232. */
  72233. dispose(): void;
  72234. /**
  72235. * Apply the interpolated value to the target
  72236. * @param currentValue defines the value computed by the animation
  72237. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72238. */
  72239. setValue(currentValue: any, weight: number): void;
  72240. private _getOriginalValues;
  72241. private _setValue;
  72242. /**
  72243. * Gets the loop pmode of the runtime animation
  72244. * @returns Loop Mode
  72245. */
  72246. private _getCorrectLoopMode;
  72247. /**
  72248. * Move the current animation to a given frame
  72249. * @param frame defines the frame to move to
  72250. */
  72251. goToFrame(frame: number): void;
  72252. /**
  72253. * @hidden Internal use only
  72254. */
  72255. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72256. /**
  72257. * Execute the current animation
  72258. * @param delay defines the delay to add to the current frame
  72259. * @param from defines the lower bound of the animation range
  72260. * @param to defines the upper bound of the animation range
  72261. * @param loop defines if the current animation must loop
  72262. * @param speedRatio defines the current speed ratio
  72263. * @param weight defines the weight of the animation (default is -1 so no weight)
  72264. * @param onLoop optional callback called when animation loops
  72265. * @returns a boolean indicating if the animation is running
  72266. */
  72267. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72268. }
  72269. }
  72270. declare module BABYLON {
  72271. /**
  72272. * Class used to store an actual running animation
  72273. */
  72274. export class Animatable {
  72275. /** defines the target object */
  72276. target: any;
  72277. /** defines the starting frame number (default is 0) */
  72278. fromFrame: number;
  72279. /** defines the ending frame number (default is 100) */
  72280. toFrame: number;
  72281. /** defines if the animation must loop (default is false) */
  72282. loopAnimation: boolean;
  72283. /** defines a callback to call when animation ends if it is not looping */
  72284. onAnimationEnd?: (() => void) | null | undefined;
  72285. /** defines a callback to call when animation loops */
  72286. onAnimationLoop?: (() => void) | null | undefined;
  72287. private _localDelayOffset;
  72288. private _pausedDelay;
  72289. private _runtimeAnimations;
  72290. private _paused;
  72291. private _scene;
  72292. private _speedRatio;
  72293. private _weight;
  72294. private _syncRoot;
  72295. /**
  72296. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72297. * This will only apply for non looping animation (default is true)
  72298. */
  72299. disposeOnEnd: boolean;
  72300. /**
  72301. * Gets a boolean indicating if the animation has started
  72302. */
  72303. animationStarted: boolean;
  72304. /**
  72305. * Observer raised when the animation ends
  72306. */
  72307. onAnimationEndObservable: Observable<Animatable>;
  72308. /**
  72309. * Observer raised when the animation loops
  72310. */
  72311. onAnimationLoopObservable: Observable<Animatable>;
  72312. /**
  72313. * Gets the root Animatable used to synchronize and normalize animations
  72314. */
  72315. readonly syncRoot: Nullable<Animatable>;
  72316. /**
  72317. * Gets the current frame of the first RuntimeAnimation
  72318. * Used to synchronize Animatables
  72319. */
  72320. readonly masterFrame: number;
  72321. /**
  72322. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72323. */
  72324. weight: number;
  72325. /**
  72326. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72327. */
  72328. speedRatio: number;
  72329. /**
  72330. * Creates a new Animatable
  72331. * @param scene defines the hosting scene
  72332. * @param target defines the target object
  72333. * @param fromFrame defines the starting frame number (default is 0)
  72334. * @param toFrame defines the ending frame number (default is 100)
  72335. * @param loopAnimation defines if the animation must loop (default is false)
  72336. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72337. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72338. * @param animations defines a group of animation to add to the new Animatable
  72339. * @param onAnimationLoop defines a callback to call when animation loops
  72340. */
  72341. constructor(scene: Scene,
  72342. /** defines the target object */
  72343. target: any,
  72344. /** defines the starting frame number (default is 0) */
  72345. fromFrame?: number,
  72346. /** defines the ending frame number (default is 100) */
  72347. toFrame?: number,
  72348. /** defines if the animation must loop (default is false) */
  72349. loopAnimation?: boolean, speedRatio?: number,
  72350. /** defines a callback to call when animation ends if it is not looping */
  72351. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72352. /** defines a callback to call when animation loops */
  72353. onAnimationLoop?: (() => void) | null | undefined);
  72354. /**
  72355. * Synchronize and normalize current Animatable with a source Animatable
  72356. * This is useful when using animation weights and when animations are not of the same length
  72357. * @param root defines the root Animatable to synchronize with
  72358. * @returns the current Animatable
  72359. */
  72360. syncWith(root: Animatable): Animatable;
  72361. /**
  72362. * Gets the list of runtime animations
  72363. * @returns an array of RuntimeAnimation
  72364. */
  72365. getAnimations(): RuntimeAnimation[];
  72366. /**
  72367. * Adds more animations to the current animatable
  72368. * @param target defines the target of the animations
  72369. * @param animations defines the new animations to add
  72370. */
  72371. appendAnimations(target: any, animations: Animation[]): void;
  72372. /**
  72373. * Gets the source animation for a specific property
  72374. * @param property defines the propertyu to look for
  72375. * @returns null or the source animation for the given property
  72376. */
  72377. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72378. /**
  72379. * Gets the runtime animation for a specific property
  72380. * @param property defines the propertyu to look for
  72381. * @returns null or the runtime animation for the given property
  72382. */
  72383. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72384. /**
  72385. * Resets the animatable to its original state
  72386. */
  72387. reset(): void;
  72388. /**
  72389. * Allows the animatable to blend with current running animations
  72390. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72391. * @param blendingSpeed defines the blending speed to use
  72392. */
  72393. enableBlending(blendingSpeed: number): void;
  72394. /**
  72395. * Disable animation blending
  72396. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72397. */
  72398. disableBlending(): void;
  72399. /**
  72400. * Jump directly to a given frame
  72401. * @param frame defines the frame to jump to
  72402. */
  72403. goToFrame(frame: number): void;
  72404. /**
  72405. * Pause the animation
  72406. */
  72407. pause(): void;
  72408. /**
  72409. * Restart the animation
  72410. */
  72411. restart(): void;
  72412. private _raiseOnAnimationEnd;
  72413. /**
  72414. * Stop and delete the current animation
  72415. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72416. * @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)
  72417. */
  72418. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72419. /**
  72420. * Wait asynchronously for the animation to end
  72421. * @returns a promise which will be fullfilled when the animation ends
  72422. */
  72423. waitAsync(): Promise<Animatable>;
  72424. /** @hidden */
  72425. _animate(delay: number): boolean;
  72426. }
  72427. interface Scene {
  72428. /** @hidden */
  72429. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72430. /** @hidden */
  72431. _processLateAnimationBindingsForMatrices(holder: {
  72432. totalWeight: number;
  72433. animations: RuntimeAnimation[];
  72434. originalValue: Matrix;
  72435. }): any;
  72436. /** @hidden */
  72437. _processLateAnimationBindingsForQuaternions(holder: {
  72438. totalWeight: number;
  72439. animations: RuntimeAnimation[];
  72440. originalValue: Quaternion;
  72441. }, refQuaternion: Quaternion): Quaternion;
  72442. /** @hidden */
  72443. _processLateAnimationBindings(): void;
  72444. /**
  72445. * Will start the animation sequence of a given target
  72446. * @param target defines the target
  72447. * @param from defines from which frame should animation start
  72448. * @param to defines until which frame should animation run.
  72449. * @param weight defines the weight to apply to the animation (1.0 by default)
  72450. * @param loop defines if the animation loops
  72451. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72452. * @param onAnimationEnd defines the function to be executed when the animation ends
  72453. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72454. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72455. * @param onAnimationLoop defines the callback to call when an animation loops
  72456. * @returns the animatable object created for this animation
  72457. */
  72458. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72459. /**
  72460. * Will start the animation sequence of a given target
  72461. * @param target defines the target
  72462. * @param from defines from which frame should animation start
  72463. * @param to defines until which frame should animation run.
  72464. * @param loop defines if the animation loops
  72465. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72466. * @param onAnimationEnd defines the function to be executed when the animation ends
  72467. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72468. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72469. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72470. * @param onAnimationLoop defines the callback to call when an animation loops
  72471. * @returns the animatable object created for this animation
  72472. */
  72473. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72474. /**
  72475. * Will start the animation sequence of a given target and its hierarchy
  72476. * @param target defines the target
  72477. * @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.
  72478. * @param from defines from which frame should animation start
  72479. * @param to defines until which frame should animation run.
  72480. * @param loop defines if the animation loops
  72481. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72482. * @param onAnimationEnd defines the function to be executed when the animation ends
  72483. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72484. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72485. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72486. * @param onAnimationLoop defines the callback to call when an animation loops
  72487. * @returns the list of created animatables
  72488. */
  72489. 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[];
  72490. /**
  72491. * Begin a new animation on a given node
  72492. * @param target defines the target where the animation will take place
  72493. * @param animations defines the list of animations to start
  72494. * @param from defines the initial value
  72495. * @param to defines the final value
  72496. * @param loop defines if you want animation to loop (off by default)
  72497. * @param speedRatio defines the speed ratio to apply to all animations
  72498. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72499. * @param onAnimationLoop defines the callback to call when an animation loops
  72500. * @returns the list of created animatables
  72501. */
  72502. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72503. /**
  72504. * Begin a new animation on a given node and its hierarchy
  72505. * @param target defines the root node where the animation will take place
  72506. * @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.
  72507. * @param animations defines the list of animations to start
  72508. * @param from defines the initial value
  72509. * @param to defines the final value
  72510. * @param loop defines if you want animation to loop (off by default)
  72511. * @param speedRatio defines the speed ratio to apply to all animations
  72512. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72513. * @param onAnimationLoop defines the callback to call when an animation loops
  72514. * @returns the list of animatables created for all nodes
  72515. */
  72516. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72517. /**
  72518. * Gets the animatable associated with a specific target
  72519. * @param target defines the target of the animatable
  72520. * @returns the required animatable if found
  72521. */
  72522. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72523. /**
  72524. * Gets all animatables associated with a given target
  72525. * @param target defines the target to look animatables for
  72526. * @returns an array of Animatables
  72527. */
  72528. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72529. /**
  72530. * Stops and removes all animations that have been applied to the scene
  72531. */
  72532. stopAllAnimations(): void;
  72533. }
  72534. interface Bone {
  72535. /**
  72536. * Copy an animation range from another bone
  72537. * @param source defines the source bone
  72538. * @param rangeName defines the range name to copy
  72539. * @param frameOffset defines the frame offset
  72540. * @param rescaleAsRequired defines if rescaling must be applied if required
  72541. * @param skelDimensionsRatio defines the scaling ratio
  72542. * @returns true if operation was successful
  72543. */
  72544. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72545. }
  72546. }
  72547. declare module BABYLON {
  72548. /**
  72549. * Class used to handle skinning animations
  72550. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72551. */
  72552. export class Skeleton implements IAnimatable {
  72553. /** defines the skeleton name */
  72554. name: string;
  72555. /** defines the skeleton Id */
  72556. id: string;
  72557. /**
  72558. * Defines the list of child bones
  72559. */
  72560. bones: Bone[];
  72561. /**
  72562. * Defines an estimate of the dimension of the skeleton at rest
  72563. */
  72564. dimensionsAtRest: Vector3;
  72565. /**
  72566. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72567. */
  72568. needInitialSkinMatrix: boolean;
  72569. /**
  72570. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72571. */
  72572. overrideMesh: Nullable<AbstractMesh>;
  72573. /**
  72574. * Gets the list of animations attached to this skeleton
  72575. */
  72576. animations: Array<Animation>;
  72577. private _scene;
  72578. private _isDirty;
  72579. private _transformMatrices;
  72580. private _transformMatrixTexture;
  72581. private _meshesWithPoseMatrix;
  72582. private _animatables;
  72583. private _identity;
  72584. private _synchronizedWithMesh;
  72585. private _ranges;
  72586. private _lastAbsoluteTransformsUpdateId;
  72587. private _canUseTextureForBones;
  72588. private _uniqueId;
  72589. /** @hidden */
  72590. _numBonesWithLinkedTransformNode: number;
  72591. /** @hidden */
  72592. _hasWaitingData: Nullable<boolean>;
  72593. /**
  72594. * Specifies if the skeleton should be serialized
  72595. */
  72596. doNotSerialize: boolean;
  72597. private _useTextureToStoreBoneMatrices;
  72598. /**
  72599. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72600. * Please note that this option is not available if the hardware does not support it
  72601. */
  72602. useTextureToStoreBoneMatrices: boolean;
  72603. private _animationPropertiesOverride;
  72604. /**
  72605. * Gets or sets the animation properties override
  72606. */
  72607. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72608. /**
  72609. * List of inspectable custom properties (used by the Inspector)
  72610. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72611. */
  72612. inspectableCustomProperties: IInspectable[];
  72613. /**
  72614. * An observable triggered before computing the skeleton's matrices
  72615. */
  72616. onBeforeComputeObservable: Observable<Skeleton>;
  72617. /**
  72618. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72619. */
  72620. readonly isUsingTextureForMatrices: boolean;
  72621. /**
  72622. * Gets the unique ID of this skeleton
  72623. */
  72624. readonly uniqueId: number;
  72625. /**
  72626. * Creates a new skeleton
  72627. * @param name defines the skeleton name
  72628. * @param id defines the skeleton Id
  72629. * @param scene defines the hosting scene
  72630. */
  72631. constructor(
  72632. /** defines the skeleton name */
  72633. name: string,
  72634. /** defines the skeleton Id */
  72635. id: string, scene: Scene);
  72636. /**
  72637. * Gets the current object class name.
  72638. * @return the class name
  72639. */
  72640. getClassName(): string;
  72641. /**
  72642. * Returns an array containing the root bones
  72643. * @returns an array containing the root bones
  72644. */
  72645. getChildren(): Array<Bone>;
  72646. /**
  72647. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72648. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72649. * @returns a Float32Array containing matrices data
  72650. */
  72651. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72652. /**
  72653. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72654. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72655. * @returns a raw texture containing the data
  72656. */
  72657. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  72658. /**
  72659. * Gets the current hosting scene
  72660. * @returns a scene object
  72661. */
  72662. getScene(): Scene;
  72663. /**
  72664. * Gets a string representing the current skeleton data
  72665. * @param fullDetails defines a boolean indicating if we want a verbose version
  72666. * @returns a string representing the current skeleton data
  72667. */
  72668. toString(fullDetails?: boolean): string;
  72669. /**
  72670. * Get bone's index searching by name
  72671. * @param name defines bone's name to search for
  72672. * @return the indice of the bone. Returns -1 if not found
  72673. */
  72674. getBoneIndexByName(name: string): number;
  72675. /**
  72676. * Creater a new animation range
  72677. * @param name defines the name of the range
  72678. * @param from defines the start key
  72679. * @param to defines the end key
  72680. */
  72681. createAnimationRange(name: string, from: number, to: number): void;
  72682. /**
  72683. * Delete a specific animation range
  72684. * @param name defines the name of the range
  72685. * @param deleteFrames defines if frames must be removed as well
  72686. */
  72687. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72688. /**
  72689. * Gets a specific animation range
  72690. * @param name defines the name of the range to look for
  72691. * @returns the requested animation range or null if not found
  72692. */
  72693. getAnimationRange(name: string): Nullable<AnimationRange>;
  72694. /**
  72695. * Gets the list of all animation ranges defined on this skeleton
  72696. * @returns an array
  72697. */
  72698. getAnimationRanges(): Nullable<AnimationRange>[];
  72699. /**
  72700. * Copy animation range from a source skeleton.
  72701. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72702. * @param source defines the source skeleton
  72703. * @param name defines the name of the range to copy
  72704. * @param rescaleAsRequired defines if rescaling must be applied if required
  72705. * @returns true if operation was successful
  72706. */
  72707. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72708. /**
  72709. * Forces the skeleton to go to rest pose
  72710. */
  72711. returnToRest(): void;
  72712. private _getHighestAnimationFrame;
  72713. /**
  72714. * Begin a specific animation range
  72715. * @param name defines the name of the range to start
  72716. * @param loop defines if looping must be turned on (false by default)
  72717. * @param speedRatio defines the speed ratio to apply (1 by default)
  72718. * @param onAnimationEnd defines a callback which will be called when animation will end
  72719. * @returns a new animatable
  72720. */
  72721. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72722. /** @hidden */
  72723. _markAsDirty(): void;
  72724. /** @hidden */
  72725. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72726. /** @hidden */
  72727. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72728. private _computeTransformMatrices;
  72729. /**
  72730. * Build all resources required to render a skeleton
  72731. */
  72732. prepare(): void;
  72733. /**
  72734. * Gets the list of animatables currently running for this skeleton
  72735. * @returns an array of animatables
  72736. */
  72737. getAnimatables(): IAnimatable[];
  72738. /**
  72739. * Clone the current skeleton
  72740. * @param name defines the name of the new skeleton
  72741. * @param id defines the id of the new skeleton
  72742. * @returns the new skeleton
  72743. */
  72744. clone(name: string, id: string): Skeleton;
  72745. /**
  72746. * Enable animation blending for this skeleton
  72747. * @param blendingSpeed defines the blending speed to apply
  72748. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72749. */
  72750. enableBlending(blendingSpeed?: number): void;
  72751. /**
  72752. * Releases all resources associated with the current skeleton
  72753. */
  72754. dispose(): void;
  72755. /**
  72756. * Serialize the skeleton in a JSON object
  72757. * @returns a JSON object
  72758. */
  72759. serialize(): any;
  72760. /**
  72761. * Creates a new skeleton from serialized data
  72762. * @param parsedSkeleton defines the serialized data
  72763. * @param scene defines the hosting scene
  72764. * @returns a new skeleton
  72765. */
  72766. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72767. /**
  72768. * Compute all node absolute transforms
  72769. * @param forceUpdate defines if computation must be done even if cache is up to date
  72770. */
  72771. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72772. /**
  72773. * Gets the root pose matrix
  72774. * @returns a matrix
  72775. */
  72776. getPoseMatrix(): Nullable<Matrix>;
  72777. /**
  72778. * Sorts bones per internal index
  72779. */
  72780. sortBones(): void;
  72781. private _sortBones;
  72782. }
  72783. }
  72784. declare module BABYLON {
  72785. /**
  72786. * Defines a target to use with MorphTargetManager
  72787. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72788. */
  72789. export class MorphTarget implements IAnimatable {
  72790. /** defines the name of the target */
  72791. name: string;
  72792. /**
  72793. * Gets or sets the list of animations
  72794. */
  72795. animations: Animation[];
  72796. private _scene;
  72797. private _positions;
  72798. private _normals;
  72799. private _tangents;
  72800. private _uvs;
  72801. private _influence;
  72802. /**
  72803. * Observable raised when the influence changes
  72804. */
  72805. onInfluenceChanged: Observable<boolean>;
  72806. /** @hidden */
  72807. _onDataLayoutChanged: Observable<void>;
  72808. /**
  72809. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72810. */
  72811. influence: number;
  72812. /**
  72813. * Gets or sets the id of the morph Target
  72814. */
  72815. id: string;
  72816. private _animationPropertiesOverride;
  72817. /**
  72818. * Gets or sets the animation properties override
  72819. */
  72820. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72821. /**
  72822. * Creates a new MorphTarget
  72823. * @param name defines the name of the target
  72824. * @param influence defines the influence to use
  72825. * @param scene defines the scene the morphtarget belongs to
  72826. */
  72827. constructor(
  72828. /** defines the name of the target */
  72829. name: string, influence?: number, scene?: Nullable<Scene>);
  72830. /**
  72831. * Gets a boolean defining if the target contains position data
  72832. */
  72833. readonly hasPositions: boolean;
  72834. /**
  72835. * Gets a boolean defining if the target contains normal data
  72836. */
  72837. readonly hasNormals: boolean;
  72838. /**
  72839. * Gets a boolean defining if the target contains tangent data
  72840. */
  72841. readonly hasTangents: boolean;
  72842. /**
  72843. * Gets a boolean defining if the target contains texture coordinates data
  72844. */
  72845. readonly hasUVs: boolean;
  72846. /**
  72847. * Affects position data to this target
  72848. * @param data defines the position data to use
  72849. */
  72850. setPositions(data: Nullable<FloatArray>): void;
  72851. /**
  72852. * Gets the position data stored in this target
  72853. * @returns a FloatArray containing the position data (or null if not present)
  72854. */
  72855. getPositions(): Nullable<FloatArray>;
  72856. /**
  72857. * Affects normal data to this target
  72858. * @param data defines the normal data to use
  72859. */
  72860. setNormals(data: Nullable<FloatArray>): void;
  72861. /**
  72862. * Gets the normal data stored in this target
  72863. * @returns a FloatArray containing the normal data (or null if not present)
  72864. */
  72865. getNormals(): Nullable<FloatArray>;
  72866. /**
  72867. * Affects tangent data to this target
  72868. * @param data defines the tangent data to use
  72869. */
  72870. setTangents(data: Nullable<FloatArray>): void;
  72871. /**
  72872. * Gets the tangent data stored in this target
  72873. * @returns a FloatArray containing the tangent data (or null if not present)
  72874. */
  72875. getTangents(): Nullable<FloatArray>;
  72876. /**
  72877. * Affects texture coordinates data to this target
  72878. * @param data defines the texture coordinates data to use
  72879. */
  72880. setUVs(data: Nullable<FloatArray>): void;
  72881. /**
  72882. * Gets the texture coordinates data stored in this target
  72883. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  72884. */
  72885. getUVs(): Nullable<FloatArray>;
  72886. /**
  72887. * Serializes the current target into a Serialization object
  72888. * @returns the serialized object
  72889. */
  72890. serialize(): any;
  72891. /**
  72892. * Returns the string "MorphTarget"
  72893. * @returns "MorphTarget"
  72894. */
  72895. getClassName(): string;
  72896. /**
  72897. * Creates a new target from serialized data
  72898. * @param serializationObject defines the serialized data to use
  72899. * @returns a new MorphTarget
  72900. */
  72901. static Parse(serializationObject: any): MorphTarget;
  72902. /**
  72903. * Creates a MorphTarget from mesh data
  72904. * @param mesh defines the source mesh
  72905. * @param name defines the name to use for the new target
  72906. * @param influence defines the influence to attach to the target
  72907. * @returns a new MorphTarget
  72908. */
  72909. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72910. }
  72911. }
  72912. declare module BABYLON {
  72913. /**
  72914. * This class is used to deform meshes using morphing between different targets
  72915. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72916. */
  72917. export class MorphTargetManager {
  72918. private _targets;
  72919. private _targetInfluenceChangedObservers;
  72920. private _targetDataLayoutChangedObservers;
  72921. private _activeTargets;
  72922. private _scene;
  72923. private _influences;
  72924. private _supportsNormals;
  72925. private _supportsTangents;
  72926. private _supportsUVs;
  72927. private _vertexCount;
  72928. private _uniqueId;
  72929. private _tempInfluences;
  72930. /**
  72931. * Gets or sets a boolean indicating if normals must be morphed
  72932. */
  72933. enableNormalMorphing: boolean;
  72934. /**
  72935. * Gets or sets a boolean indicating if tangents must be morphed
  72936. */
  72937. enableTangentMorphing: boolean;
  72938. /**
  72939. * Gets or sets a boolean indicating if UV must be morphed
  72940. */
  72941. enableUVMorphing: boolean;
  72942. /**
  72943. * Creates a new MorphTargetManager
  72944. * @param scene defines the current scene
  72945. */
  72946. constructor(scene?: Nullable<Scene>);
  72947. /**
  72948. * Gets the unique ID of this manager
  72949. */
  72950. readonly uniqueId: number;
  72951. /**
  72952. * Gets the number of vertices handled by this manager
  72953. */
  72954. readonly vertexCount: number;
  72955. /**
  72956. * Gets a boolean indicating if this manager supports morphing of normals
  72957. */
  72958. readonly supportsNormals: boolean;
  72959. /**
  72960. * Gets a boolean indicating if this manager supports morphing of tangents
  72961. */
  72962. readonly supportsTangents: boolean;
  72963. /**
  72964. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  72965. */
  72966. readonly supportsUVs: boolean;
  72967. /**
  72968. * Gets the number of targets stored in this manager
  72969. */
  72970. readonly numTargets: number;
  72971. /**
  72972. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72973. */
  72974. readonly numInfluencers: number;
  72975. /**
  72976. * Gets the list of influences (one per target)
  72977. */
  72978. readonly influences: Float32Array;
  72979. /**
  72980. * Gets the active target at specified index. An active target is a target with an influence > 0
  72981. * @param index defines the index to check
  72982. * @returns the requested target
  72983. */
  72984. getActiveTarget(index: number): MorphTarget;
  72985. /**
  72986. * Gets the target at specified index
  72987. * @param index defines the index to check
  72988. * @returns the requested target
  72989. */
  72990. getTarget(index: number): MorphTarget;
  72991. /**
  72992. * Add a new target to this manager
  72993. * @param target defines the target to add
  72994. */
  72995. addTarget(target: MorphTarget): void;
  72996. /**
  72997. * Removes a target from the manager
  72998. * @param target defines the target to remove
  72999. */
  73000. removeTarget(target: MorphTarget): void;
  73001. /**
  73002. * Serializes the current manager into a Serialization object
  73003. * @returns the serialized object
  73004. */
  73005. serialize(): any;
  73006. private _syncActiveTargets;
  73007. /**
  73008. * Syncrhonize the targets with all the meshes using this morph target manager
  73009. */
  73010. synchronize(): void;
  73011. /**
  73012. * Creates a new MorphTargetManager from serialized data
  73013. * @param serializationObject defines the serialized data
  73014. * @param scene defines the hosting scene
  73015. * @returns the new MorphTargetManager
  73016. */
  73017. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73018. }
  73019. }
  73020. declare module BABYLON {
  73021. /**
  73022. * Groups all the scene component constants in one place to ease maintenance.
  73023. * @hidden
  73024. */
  73025. export class SceneComponentConstants {
  73026. static readonly NAME_EFFECTLAYER: string;
  73027. static readonly NAME_LAYER: string;
  73028. static readonly NAME_LENSFLARESYSTEM: string;
  73029. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73030. static readonly NAME_PARTICLESYSTEM: string;
  73031. static readonly NAME_GAMEPAD: string;
  73032. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73033. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73034. static readonly NAME_DEPTHRENDERER: string;
  73035. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73036. static readonly NAME_SPRITE: string;
  73037. static readonly NAME_OUTLINERENDERER: string;
  73038. static readonly NAME_PROCEDURALTEXTURE: string;
  73039. static readonly NAME_SHADOWGENERATOR: string;
  73040. static readonly NAME_OCTREE: string;
  73041. static readonly NAME_PHYSICSENGINE: string;
  73042. static readonly NAME_AUDIO: string;
  73043. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73044. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73045. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73046. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73047. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73048. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73049. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73050. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73051. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73052. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73053. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73054. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73055. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73056. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73057. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73058. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73059. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73060. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73061. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73062. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73063. static readonly STEP_AFTERRENDER_AUDIO: number;
  73064. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73065. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73066. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73067. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73068. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73069. static readonly STEP_POINTERMOVE_SPRITE: number;
  73070. static readonly STEP_POINTERDOWN_SPRITE: number;
  73071. static readonly STEP_POINTERUP_SPRITE: number;
  73072. }
  73073. /**
  73074. * This represents a scene component.
  73075. *
  73076. * This is used to decouple the dependency the scene is having on the different workloads like
  73077. * layers, post processes...
  73078. */
  73079. export interface ISceneComponent {
  73080. /**
  73081. * The name of the component. Each component must have a unique name.
  73082. */
  73083. name: string;
  73084. /**
  73085. * The scene the component belongs to.
  73086. */
  73087. scene: Scene;
  73088. /**
  73089. * Register the component to one instance of a scene.
  73090. */
  73091. register(): void;
  73092. /**
  73093. * Rebuilds the elements related to this component in case of
  73094. * context lost for instance.
  73095. */
  73096. rebuild(): void;
  73097. /**
  73098. * Disposes the component and the associated ressources.
  73099. */
  73100. dispose(): void;
  73101. }
  73102. /**
  73103. * This represents a SERIALIZABLE scene component.
  73104. *
  73105. * This extends Scene Component to add Serialization methods on top.
  73106. */
  73107. export interface ISceneSerializableComponent extends ISceneComponent {
  73108. /**
  73109. * Adds all the elements from the container to the scene
  73110. * @param container the container holding the elements
  73111. */
  73112. addFromContainer(container: AbstractScene): void;
  73113. /**
  73114. * Removes all the elements in the container from the scene
  73115. * @param container contains the elements to remove
  73116. * @param dispose if the removed element should be disposed (default: false)
  73117. */
  73118. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73119. /**
  73120. * Serializes the component data to the specified json object
  73121. * @param serializationObject The object to serialize to
  73122. */
  73123. serialize(serializationObject: any): void;
  73124. }
  73125. /**
  73126. * Strong typing of a Mesh related stage step action
  73127. */
  73128. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73129. /**
  73130. * Strong typing of a Evaluate Sub Mesh related stage step action
  73131. */
  73132. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73133. /**
  73134. * Strong typing of a Active Mesh related stage step action
  73135. */
  73136. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73137. /**
  73138. * Strong typing of a Camera related stage step action
  73139. */
  73140. export type CameraStageAction = (camera: Camera) => void;
  73141. /**
  73142. * Strong typing of a Camera Frame buffer related stage step action
  73143. */
  73144. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73145. /**
  73146. * Strong typing of a Render Target related stage step action
  73147. */
  73148. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73149. /**
  73150. * Strong typing of a RenderingGroup related stage step action
  73151. */
  73152. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73153. /**
  73154. * Strong typing of a Mesh Render related stage step action
  73155. */
  73156. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73157. /**
  73158. * Strong typing of a simple stage step action
  73159. */
  73160. export type SimpleStageAction = () => void;
  73161. /**
  73162. * Strong typing of a render target action.
  73163. */
  73164. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73165. /**
  73166. * Strong typing of a pointer move action.
  73167. */
  73168. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73169. /**
  73170. * Strong typing of a pointer up/down action.
  73171. */
  73172. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73173. /**
  73174. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73175. * @hidden
  73176. */
  73177. export class Stage<T extends Function> extends Array<{
  73178. index: number;
  73179. component: ISceneComponent;
  73180. action: T;
  73181. }> {
  73182. /**
  73183. * Hide ctor from the rest of the world.
  73184. * @param items The items to add.
  73185. */
  73186. private constructor();
  73187. /**
  73188. * Creates a new Stage.
  73189. * @returns A new instance of a Stage
  73190. */
  73191. static Create<T extends Function>(): Stage<T>;
  73192. /**
  73193. * Registers a step in an ordered way in the targeted stage.
  73194. * @param index Defines the position to register the step in
  73195. * @param component Defines the component attached to the step
  73196. * @param action Defines the action to launch during the step
  73197. */
  73198. registerStep(index: number, component: ISceneComponent, action: T): void;
  73199. /**
  73200. * Clears all the steps from the stage.
  73201. */
  73202. clear(): void;
  73203. }
  73204. }
  73205. declare module BABYLON {
  73206. /**
  73207. * Class used to represent a specific level of detail of a mesh
  73208. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73209. */
  73210. export class MeshLODLevel {
  73211. /** Defines the distance where this level should star being displayed */
  73212. distance: number;
  73213. /** Defines the mesh to use to render this level */
  73214. mesh: Nullable<Mesh>;
  73215. /**
  73216. * Creates a new LOD level
  73217. * @param distance defines the distance where this level should star being displayed
  73218. * @param mesh defines the mesh to use to render this level
  73219. */
  73220. constructor(
  73221. /** Defines the distance where this level should star being displayed */
  73222. distance: number,
  73223. /** Defines the mesh to use to render this level */
  73224. mesh: Nullable<Mesh>);
  73225. }
  73226. }
  73227. declare module BABYLON {
  73228. /**
  73229. * Interface describing all the common properties and methods a shadow light needs to implement.
  73230. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73231. * as well as binding the different shadow properties to the effects.
  73232. */
  73233. export interface IShadowLight extends Light {
  73234. /**
  73235. * The light id in the scene (used in scene.findLighById for instance)
  73236. */
  73237. id: string;
  73238. /**
  73239. * The position the shdow will be casted from.
  73240. */
  73241. position: Vector3;
  73242. /**
  73243. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73244. */
  73245. direction: Vector3;
  73246. /**
  73247. * The transformed position. Position of the light in world space taking parenting in account.
  73248. */
  73249. transformedPosition: Vector3;
  73250. /**
  73251. * The transformed direction. Direction of the light in world space taking parenting in account.
  73252. */
  73253. transformedDirection: Vector3;
  73254. /**
  73255. * The friendly name of the light in the scene.
  73256. */
  73257. name: string;
  73258. /**
  73259. * Defines the shadow projection clipping minimum z value.
  73260. */
  73261. shadowMinZ: number;
  73262. /**
  73263. * Defines the shadow projection clipping maximum z value.
  73264. */
  73265. shadowMaxZ: number;
  73266. /**
  73267. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73268. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73269. */
  73270. computeTransformedInformation(): boolean;
  73271. /**
  73272. * Gets the scene the light belongs to.
  73273. * @returns The scene
  73274. */
  73275. getScene(): Scene;
  73276. /**
  73277. * Callback defining a custom Projection Matrix Builder.
  73278. * This can be used to override the default projection matrix computation.
  73279. */
  73280. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73281. /**
  73282. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73283. * @param matrix The materix to updated with the projection information
  73284. * @param viewMatrix The transform matrix of the light
  73285. * @param renderList The list of mesh to render in the map
  73286. * @returns The current light
  73287. */
  73288. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73289. /**
  73290. * Gets the current depth scale used in ESM.
  73291. * @returns The scale
  73292. */
  73293. getDepthScale(): number;
  73294. /**
  73295. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73296. * @returns true if a cube texture needs to be use
  73297. */
  73298. needCube(): boolean;
  73299. /**
  73300. * Detects if the projection matrix requires to be recomputed this frame.
  73301. * @returns true if it requires to be recomputed otherwise, false.
  73302. */
  73303. needProjectionMatrixCompute(): boolean;
  73304. /**
  73305. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73306. */
  73307. forceProjectionMatrixCompute(): void;
  73308. /**
  73309. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73310. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73311. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73312. */
  73313. getShadowDirection(faceIndex?: number): Vector3;
  73314. /**
  73315. * Gets the minZ used for shadow according to both the scene and the light.
  73316. * @param activeCamera The camera we are returning the min for
  73317. * @returns the depth min z
  73318. */
  73319. getDepthMinZ(activeCamera: Camera): number;
  73320. /**
  73321. * Gets the maxZ used for shadow according to both the scene and the light.
  73322. * @param activeCamera The camera we are returning the max for
  73323. * @returns the depth max z
  73324. */
  73325. getDepthMaxZ(activeCamera: Camera): number;
  73326. }
  73327. /**
  73328. * Base implementation IShadowLight
  73329. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73330. */
  73331. export abstract class ShadowLight extends Light implements IShadowLight {
  73332. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73333. protected _position: Vector3;
  73334. protected _setPosition(value: Vector3): void;
  73335. /**
  73336. * Sets the position the shadow will be casted from. Also use as the light position for both
  73337. * point and spot lights.
  73338. */
  73339. /**
  73340. * Sets the position the shadow will be casted from. Also use as the light position for both
  73341. * point and spot lights.
  73342. */
  73343. position: Vector3;
  73344. protected _direction: Vector3;
  73345. protected _setDirection(value: Vector3): void;
  73346. /**
  73347. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73348. * Also use as the light direction on spot and directional lights.
  73349. */
  73350. /**
  73351. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73352. * Also use as the light direction on spot and directional lights.
  73353. */
  73354. direction: Vector3;
  73355. private _shadowMinZ;
  73356. /**
  73357. * Gets the shadow projection clipping minimum z value.
  73358. */
  73359. /**
  73360. * Sets the shadow projection clipping minimum z value.
  73361. */
  73362. shadowMinZ: number;
  73363. private _shadowMaxZ;
  73364. /**
  73365. * Sets the shadow projection clipping maximum z value.
  73366. */
  73367. /**
  73368. * Gets the shadow projection clipping maximum z value.
  73369. */
  73370. shadowMaxZ: number;
  73371. /**
  73372. * Callback defining a custom Projection Matrix Builder.
  73373. * This can be used to override the default projection matrix computation.
  73374. */
  73375. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73376. /**
  73377. * The transformed position. Position of the light in world space taking parenting in account.
  73378. */
  73379. transformedPosition: Vector3;
  73380. /**
  73381. * The transformed direction. Direction of the light in world space taking parenting in account.
  73382. */
  73383. transformedDirection: Vector3;
  73384. private _needProjectionMatrixCompute;
  73385. /**
  73386. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73387. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73388. */
  73389. computeTransformedInformation(): boolean;
  73390. /**
  73391. * Return the depth scale used for the shadow map.
  73392. * @returns the depth scale.
  73393. */
  73394. getDepthScale(): number;
  73395. /**
  73396. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73397. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73398. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73399. */
  73400. getShadowDirection(faceIndex?: number): Vector3;
  73401. /**
  73402. * Returns the ShadowLight absolute position in the World.
  73403. * @returns the position vector in world space
  73404. */
  73405. getAbsolutePosition(): Vector3;
  73406. /**
  73407. * Sets the ShadowLight direction toward the passed target.
  73408. * @param target The point to target in local space
  73409. * @returns the updated ShadowLight direction
  73410. */
  73411. setDirectionToTarget(target: Vector3): Vector3;
  73412. /**
  73413. * Returns the light rotation in euler definition.
  73414. * @returns the x y z rotation in local space.
  73415. */
  73416. getRotation(): Vector3;
  73417. /**
  73418. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73419. * @returns true if a cube texture needs to be use
  73420. */
  73421. needCube(): boolean;
  73422. /**
  73423. * Detects if the projection matrix requires to be recomputed this frame.
  73424. * @returns true if it requires to be recomputed otherwise, false.
  73425. */
  73426. needProjectionMatrixCompute(): boolean;
  73427. /**
  73428. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73429. */
  73430. forceProjectionMatrixCompute(): void;
  73431. /** @hidden */
  73432. _initCache(): void;
  73433. /** @hidden */
  73434. _isSynchronized(): boolean;
  73435. /**
  73436. * Computes the world matrix of the node
  73437. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73438. * @returns the world matrix
  73439. */
  73440. computeWorldMatrix(force?: boolean): Matrix;
  73441. /**
  73442. * Gets the minZ used for shadow according to both the scene and the light.
  73443. * @param activeCamera The camera we are returning the min for
  73444. * @returns the depth min z
  73445. */
  73446. getDepthMinZ(activeCamera: Camera): number;
  73447. /**
  73448. * Gets the maxZ used for shadow according to both the scene and the light.
  73449. * @param activeCamera The camera we are returning the max for
  73450. * @returns the depth max z
  73451. */
  73452. getDepthMaxZ(activeCamera: Camera): number;
  73453. /**
  73454. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73455. * @param matrix The materix to updated with the projection information
  73456. * @param viewMatrix The transform matrix of the light
  73457. * @param renderList The list of mesh to render in the map
  73458. * @returns The current light
  73459. */
  73460. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73461. }
  73462. }
  73463. declare module BABYLON {
  73464. /**
  73465. * "Static Class" containing the most commonly used helper while dealing with material for
  73466. * rendering purpose.
  73467. *
  73468. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73469. *
  73470. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73471. */
  73472. export class MaterialHelper {
  73473. /**
  73474. * Bind the current view position to an effect.
  73475. * @param effect The effect to be bound
  73476. * @param scene The scene the eyes position is used from
  73477. */
  73478. static BindEyePosition(effect: Effect, scene: Scene): void;
  73479. /**
  73480. * Helps preparing the defines values about the UVs in used in the effect.
  73481. * UVs are shared as much as we can accross channels in the shaders.
  73482. * @param texture The texture we are preparing the UVs for
  73483. * @param defines The defines to update
  73484. * @param key The channel key "diffuse", "specular"... used in the shader
  73485. */
  73486. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73487. /**
  73488. * Binds a texture matrix value to its corrsponding uniform
  73489. * @param texture The texture to bind the matrix for
  73490. * @param uniformBuffer The uniform buffer receivin the data
  73491. * @param key The channel key "diffuse", "specular"... used in the shader
  73492. */
  73493. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73494. /**
  73495. * Gets the current status of the fog (should it be enabled?)
  73496. * @param mesh defines the mesh to evaluate for fog support
  73497. * @param scene defines the hosting scene
  73498. * @returns true if fog must be enabled
  73499. */
  73500. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73501. /**
  73502. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73503. * @param mesh defines the current mesh
  73504. * @param scene defines the current scene
  73505. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73506. * @param pointsCloud defines if point cloud rendering has to be turned on
  73507. * @param fogEnabled defines if fog has to be turned on
  73508. * @param alphaTest defines if alpha testing has to be turned on
  73509. * @param defines defines the current list of defines
  73510. */
  73511. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73512. /**
  73513. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73514. * @param scene defines the current scene
  73515. * @param engine defines the current engine
  73516. * @param defines specifies the list of active defines
  73517. * @param useInstances defines if instances have to be turned on
  73518. * @param useClipPlane defines if clip plane have to be turned on
  73519. */
  73520. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73521. /**
  73522. * Prepares the defines for bones
  73523. * @param mesh The mesh containing the geometry data we will draw
  73524. * @param defines The defines to update
  73525. */
  73526. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73527. /**
  73528. * Prepares the defines for morph targets
  73529. * @param mesh The mesh containing the geometry data we will draw
  73530. * @param defines The defines to update
  73531. */
  73532. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73533. /**
  73534. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73535. * @param mesh The mesh containing the geometry data we will draw
  73536. * @param defines The defines to update
  73537. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73538. * @param useBones Precise whether bones should be used or not (override mesh info)
  73539. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73540. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73541. * @returns false if defines are considered not dirty and have not been checked
  73542. */
  73543. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73544. /**
  73545. * Prepares the defines related to multiview
  73546. * @param scene The scene we are intending to draw
  73547. * @param defines The defines to update
  73548. */
  73549. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73550. /**
  73551. * Prepares the defines related to the light information passed in parameter
  73552. * @param scene The scene we are intending to draw
  73553. * @param mesh The mesh the effect is compiling for
  73554. * @param light The light the effect is compiling for
  73555. * @param lightIndex The index of the light
  73556. * @param defines The defines to update
  73557. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73558. * @param state Defines the current state regarding what is needed (normals, etc...)
  73559. */
  73560. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73561. needNormals: boolean;
  73562. needRebuild: boolean;
  73563. shadowEnabled: boolean;
  73564. specularEnabled: boolean;
  73565. lightmapMode: boolean;
  73566. }): void;
  73567. /**
  73568. * Prepares the defines related to the light information passed in parameter
  73569. * @param scene The scene we are intending to draw
  73570. * @param mesh The mesh the effect is compiling for
  73571. * @param defines The defines to update
  73572. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73573. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73574. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73575. * @returns true if normals will be required for the rest of the effect
  73576. */
  73577. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73578. /**
  73579. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73580. * @param lightIndex defines the light index
  73581. * @param uniformsList The uniform list
  73582. * @param samplersList The sampler list
  73583. * @param projectedLightTexture defines if projected texture must be used
  73584. * @param uniformBuffersList defines an optional list of uniform buffers
  73585. */
  73586. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73587. /**
  73588. * Prepares the uniforms and samplers list to be used in the effect
  73589. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73590. * @param samplersList The sampler list
  73591. * @param defines The defines helping in the list generation
  73592. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73593. */
  73594. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73595. /**
  73596. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73597. * @param defines The defines to update while falling back
  73598. * @param fallbacks The authorized effect fallbacks
  73599. * @param maxSimultaneousLights The maximum number of lights allowed
  73600. * @param rank the current rank of the Effect
  73601. * @returns The newly affected rank
  73602. */
  73603. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73604. private static _TmpMorphInfluencers;
  73605. /**
  73606. * Prepares the list of attributes required for morph targets according to the effect defines.
  73607. * @param attribs The current list of supported attribs
  73608. * @param mesh The mesh to prepare the morph targets attributes for
  73609. * @param influencers The number of influencers
  73610. */
  73611. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73612. /**
  73613. * Prepares the list of attributes required for morph targets according to the effect defines.
  73614. * @param attribs The current list of supported attribs
  73615. * @param mesh The mesh to prepare the morph targets attributes for
  73616. * @param defines The current Defines of the effect
  73617. */
  73618. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73619. /**
  73620. * Prepares the list of attributes required for bones according to the effect defines.
  73621. * @param attribs The current list of supported attribs
  73622. * @param mesh The mesh to prepare the bones attributes for
  73623. * @param defines The current Defines of the effect
  73624. * @param fallbacks The current efffect fallback strategy
  73625. */
  73626. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73627. /**
  73628. * Check and prepare the list of attributes required for instances according to the effect defines.
  73629. * @param attribs The current list of supported attribs
  73630. * @param defines The current MaterialDefines of the effect
  73631. */
  73632. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73633. /**
  73634. * Add the list of attributes required for instances to the attribs array.
  73635. * @param attribs The current list of supported attribs
  73636. */
  73637. static PushAttributesForInstances(attribs: string[]): void;
  73638. /**
  73639. * Binds the light shadow information to the effect for the given mesh.
  73640. * @param light The light containing the generator
  73641. * @param scene The scene the lights belongs to
  73642. * @param mesh The mesh we are binding the information to render
  73643. * @param lightIndex The light index in the effect used to render the mesh
  73644. * @param effect The effect we are binding the data to
  73645. */
  73646. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73647. /**
  73648. * Binds the light information to the effect.
  73649. * @param light The light containing the generator
  73650. * @param effect The effect we are binding the data to
  73651. * @param lightIndex The light index in the effect used to render
  73652. */
  73653. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73654. /**
  73655. * Binds the lights information from the scene to the effect for the given mesh.
  73656. * @param light Light to bind
  73657. * @param lightIndex Light index
  73658. * @param scene The scene where the light belongs to
  73659. * @param mesh The mesh we are binding the information to render
  73660. * @param effect The effect we are binding the data to
  73661. * @param useSpecular Defines if specular is supported
  73662. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73663. */
  73664. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73665. /**
  73666. * Binds the lights information from the scene to the effect for the given mesh.
  73667. * @param scene The scene the lights belongs to
  73668. * @param mesh The mesh we are binding the information to render
  73669. * @param effect The effect we are binding the data to
  73670. * @param defines The generated defines for the effect
  73671. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73672. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73673. */
  73674. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73675. private static _tempFogColor;
  73676. /**
  73677. * Binds the fog information from the scene to the effect for the given mesh.
  73678. * @param scene The scene the lights belongs to
  73679. * @param mesh The mesh we are binding the information to render
  73680. * @param effect The effect we are binding the data to
  73681. * @param linearSpace Defines if the fog effect is applied in linear space
  73682. */
  73683. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73684. /**
  73685. * Binds the bones information from the mesh to the effect.
  73686. * @param mesh The mesh we are binding the information to render
  73687. * @param effect The effect we are binding the data to
  73688. */
  73689. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73690. /**
  73691. * Binds the morph targets information from the mesh to the effect.
  73692. * @param abstractMesh The mesh we are binding the information to render
  73693. * @param effect The effect we are binding the data to
  73694. */
  73695. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73696. /**
  73697. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73698. * @param defines The generated defines used in the effect
  73699. * @param effect The effect we are binding the data to
  73700. * @param scene The scene we are willing to render with logarithmic scale for
  73701. */
  73702. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73703. /**
  73704. * Binds the clip plane information from the scene to the effect.
  73705. * @param scene The scene the clip plane information are extracted from
  73706. * @param effect The effect we are binding the data to
  73707. */
  73708. static BindClipPlane(effect: Effect, scene: Scene): void;
  73709. }
  73710. }
  73711. declare module BABYLON {
  73712. /** @hidden */
  73713. export var shadowMapPixelShader: {
  73714. name: string;
  73715. shader: string;
  73716. };
  73717. }
  73718. declare module BABYLON {
  73719. /** @hidden */
  73720. export var bonesDeclaration: {
  73721. name: string;
  73722. shader: string;
  73723. };
  73724. }
  73725. declare module BABYLON {
  73726. /** @hidden */
  73727. export var morphTargetsVertexGlobalDeclaration: {
  73728. name: string;
  73729. shader: string;
  73730. };
  73731. }
  73732. declare module BABYLON {
  73733. /** @hidden */
  73734. export var morphTargetsVertexDeclaration: {
  73735. name: string;
  73736. shader: string;
  73737. };
  73738. }
  73739. declare module BABYLON {
  73740. /** @hidden */
  73741. export var instancesDeclaration: {
  73742. name: string;
  73743. shader: string;
  73744. };
  73745. }
  73746. declare module BABYLON {
  73747. /** @hidden */
  73748. export var helperFunctions: {
  73749. name: string;
  73750. shader: string;
  73751. };
  73752. }
  73753. declare module BABYLON {
  73754. /** @hidden */
  73755. export var morphTargetsVertex: {
  73756. name: string;
  73757. shader: string;
  73758. };
  73759. }
  73760. declare module BABYLON {
  73761. /** @hidden */
  73762. export var instancesVertex: {
  73763. name: string;
  73764. shader: string;
  73765. };
  73766. }
  73767. declare module BABYLON {
  73768. /** @hidden */
  73769. export var bonesVertex: {
  73770. name: string;
  73771. shader: string;
  73772. };
  73773. }
  73774. declare module BABYLON {
  73775. /** @hidden */
  73776. export var shadowMapVertexShader: {
  73777. name: string;
  73778. shader: string;
  73779. };
  73780. }
  73781. declare module BABYLON {
  73782. /** @hidden */
  73783. export var depthBoxBlurPixelShader: {
  73784. name: string;
  73785. shader: string;
  73786. };
  73787. }
  73788. declare module BABYLON {
  73789. /**
  73790. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73791. */
  73792. export interface ICustomShaderOptions {
  73793. /**
  73794. * Gets or sets the custom shader name to use
  73795. */
  73796. shaderName: string;
  73797. /**
  73798. * The list of attribute names used in the shader
  73799. */
  73800. attributes?: string[];
  73801. /**
  73802. * The list of unifrom names used in the shader
  73803. */
  73804. uniforms?: string[];
  73805. /**
  73806. * The list of sampler names used in the shader
  73807. */
  73808. samplers?: string[];
  73809. /**
  73810. * The list of defines used in the shader
  73811. */
  73812. defines?: string[];
  73813. }
  73814. /**
  73815. * Interface to implement to create a shadow generator compatible with BJS.
  73816. */
  73817. export interface IShadowGenerator {
  73818. /**
  73819. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73820. * @returns The render target texture if present otherwise, null
  73821. */
  73822. getShadowMap(): Nullable<RenderTargetTexture>;
  73823. /**
  73824. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73825. * @returns The render target texture if the shadow map is present otherwise, null
  73826. */
  73827. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73828. /**
  73829. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73830. * @param subMesh The submesh we want to render in the shadow map
  73831. * @param useInstances Defines wether will draw in the map using instances
  73832. * @returns true if ready otherwise, false
  73833. */
  73834. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73835. /**
  73836. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73837. * @param defines Defines of the material we want to update
  73838. * @param lightIndex Index of the light in the enabled light list of the material
  73839. */
  73840. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73841. /**
  73842. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73843. * defined in the generator but impacting the effect).
  73844. * It implies the unifroms available on the materials are the standard BJS ones.
  73845. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73846. * @param effect The effect we are binfing the information for
  73847. */
  73848. bindShadowLight(lightIndex: string, effect: Effect): void;
  73849. /**
  73850. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73851. * (eq to shadow prjection matrix * light transform matrix)
  73852. * @returns The transform matrix used to create the shadow map
  73853. */
  73854. getTransformMatrix(): Matrix;
  73855. /**
  73856. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73857. * Cube and 2D textures for instance.
  73858. */
  73859. recreateShadowMap(): void;
  73860. /**
  73861. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73862. * @param onCompiled Callback triggered at the and of the effects compilation
  73863. * @param options Sets of optional options forcing the compilation with different modes
  73864. */
  73865. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73866. useInstances: boolean;
  73867. }>): void;
  73868. /**
  73869. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73870. * @param options Sets of optional options forcing the compilation with different modes
  73871. * @returns A promise that resolves when the compilation completes
  73872. */
  73873. forceCompilationAsync(options?: Partial<{
  73874. useInstances: boolean;
  73875. }>): Promise<void>;
  73876. /**
  73877. * Serializes the shadow generator setup to a json object.
  73878. * @returns The serialized JSON object
  73879. */
  73880. serialize(): any;
  73881. /**
  73882. * Disposes the Shadow map and related Textures and effects.
  73883. */
  73884. dispose(): void;
  73885. }
  73886. /**
  73887. * Default implementation IShadowGenerator.
  73888. * This is the main object responsible of generating shadows in the framework.
  73889. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73890. */
  73891. export class ShadowGenerator implements IShadowGenerator {
  73892. /**
  73893. * Shadow generator mode None: no filtering applied.
  73894. */
  73895. static readonly FILTER_NONE: number;
  73896. /**
  73897. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73898. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73899. */
  73900. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73901. /**
  73902. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73903. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73904. */
  73905. static readonly FILTER_POISSONSAMPLING: number;
  73906. /**
  73907. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73908. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73909. */
  73910. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73911. /**
  73912. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73913. * edge artifacts on steep falloff.
  73914. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73915. */
  73916. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73917. /**
  73918. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73919. * edge artifacts on steep falloff.
  73920. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73921. */
  73922. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73923. /**
  73924. * Shadow generator mode PCF: Percentage Closer Filtering
  73925. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73926. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73927. */
  73928. static readonly FILTER_PCF: number;
  73929. /**
  73930. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73931. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73932. * Contact Hardening
  73933. */
  73934. static readonly FILTER_PCSS: number;
  73935. /**
  73936. * Reserved for PCF and PCSS
  73937. * Highest Quality.
  73938. *
  73939. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73940. *
  73941. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73942. */
  73943. static readonly QUALITY_HIGH: number;
  73944. /**
  73945. * Reserved for PCF and PCSS
  73946. * Good tradeoff for quality/perf cross devices
  73947. *
  73948. * Execute PCF on a 3*3 kernel.
  73949. *
  73950. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73951. */
  73952. static readonly QUALITY_MEDIUM: number;
  73953. /**
  73954. * Reserved for PCF and PCSS
  73955. * The lowest quality but the fastest.
  73956. *
  73957. * Execute PCF on a 1*1 kernel.
  73958. *
  73959. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73960. */
  73961. static readonly QUALITY_LOW: number;
  73962. /** Gets or sets the custom shader name to use */
  73963. customShaderOptions: ICustomShaderOptions;
  73964. /**
  73965. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73966. */
  73967. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73968. /**
  73969. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73970. */
  73971. onAfterShadowMapRenderObservable: Observable<Effect>;
  73972. /**
  73973. * Observable triggered before a mesh is rendered in the shadow map.
  73974. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73975. */
  73976. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73977. /**
  73978. * Observable triggered after a mesh is rendered in the shadow map.
  73979. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73980. */
  73981. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73982. private _bias;
  73983. /**
  73984. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73985. */
  73986. /**
  73987. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73988. */
  73989. bias: number;
  73990. private _normalBias;
  73991. /**
  73992. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73993. */
  73994. /**
  73995. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73996. */
  73997. normalBias: number;
  73998. private _blurBoxOffset;
  73999. /**
  74000. * Gets the blur box offset: offset applied during the blur pass.
  74001. * Only useful if useKernelBlur = false
  74002. */
  74003. /**
  74004. * Sets the blur box offset: offset applied during the blur pass.
  74005. * Only useful if useKernelBlur = false
  74006. */
  74007. blurBoxOffset: number;
  74008. private _blurScale;
  74009. /**
  74010. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74011. * 2 means half of the size.
  74012. */
  74013. /**
  74014. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74015. * 2 means half of the size.
  74016. */
  74017. blurScale: number;
  74018. private _blurKernel;
  74019. /**
  74020. * Gets the blur kernel: kernel size of the blur pass.
  74021. * Only useful if useKernelBlur = true
  74022. */
  74023. /**
  74024. * Sets the blur kernel: kernel size of the blur pass.
  74025. * Only useful if useKernelBlur = true
  74026. */
  74027. blurKernel: number;
  74028. private _useKernelBlur;
  74029. /**
  74030. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74031. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74032. */
  74033. /**
  74034. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74035. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74036. */
  74037. useKernelBlur: boolean;
  74038. private _depthScale;
  74039. /**
  74040. * Gets the depth scale used in ESM mode.
  74041. */
  74042. /**
  74043. * Sets the depth scale used in ESM mode.
  74044. * This can override the scale stored on the light.
  74045. */
  74046. depthScale: number;
  74047. private _filter;
  74048. /**
  74049. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74050. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74051. */
  74052. /**
  74053. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74054. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74055. */
  74056. filter: number;
  74057. /**
  74058. * Gets if the current filter is set to Poisson Sampling.
  74059. */
  74060. /**
  74061. * Sets the current filter to Poisson Sampling.
  74062. */
  74063. usePoissonSampling: boolean;
  74064. /**
  74065. * Gets if the current filter is set to ESM.
  74066. */
  74067. /**
  74068. * Sets the current filter is to ESM.
  74069. */
  74070. useExponentialShadowMap: boolean;
  74071. /**
  74072. * Gets if the current filter is set to filtered ESM.
  74073. */
  74074. /**
  74075. * Gets if the current filter is set to filtered ESM.
  74076. */
  74077. useBlurExponentialShadowMap: boolean;
  74078. /**
  74079. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74080. * exponential to prevent steep falloff artifacts).
  74081. */
  74082. /**
  74083. * Sets the current filter to "close ESM" (using the inverse of the
  74084. * exponential to prevent steep falloff artifacts).
  74085. */
  74086. useCloseExponentialShadowMap: boolean;
  74087. /**
  74088. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74089. * exponential to prevent steep falloff artifacts).
  74090. */
  74091. /**
  74092. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74093. * exponential to prevent steep falloff artifacts).
  74094. */
  74095. useBlurCloseExponentialShadowMap: boolean;
  74096. /**
  74097. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74098. */
  74099. /**
  74100. * Sets the current filter to "PCF" (percentage closer filtering).
  74101. */
  74102. usePercentageCloserFiltering: boolean;
  74103. private _filteringQuality;
  74104. /**
  74105. * Gets the PCF or PCSS Quality.
  74106. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74107. */
  74108. /**
  74109. * Sets the PCF or PCSS Quality.
  74110. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74111. */
  74112. filteringQuality: number;
  74113. /**
  74114. * Gets if the current filter is set to "PCSS" (contact hardening).
  74115. */
  74116. /**
  74117. * Sets the current filter to "PCSS" (contact hardening).
  74118. */
  74119. useContactHardeningShadow: boolean;
  74120. private _contactHardeningLightSizeUVRatio;
  74121. /**
  74122. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74123. * Using a ratio helps keeping shape stability independently of the map size.
  74124. *
  74125. * It does not account for the light projection as it was having too much
  74126. * instability during the light setup or during light position changes.
  74127. *
  74128. * Only valid if useContactHardeningShadow is true.
  74129. */
  74130. /**
  74131. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74132. * Using a ratio helps keeping shape stability independently of the map size.
  74133. *
  74134. * It does not account for the light projection as it was having too much
  74135. * instability during the light setup or during light position changes.
  74136. *
  74137. * Only valid if useContactHardeningShadow is true.
  74138. */
  74139. contactHardeningLightSizeUVRatio: number;
  74140. private _darkness;
  74141. /** Gets or sets the actual darkness of a shadow */
  74142. darkness: number;
  74143. /**
  74144. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74145. * 0 means strongest and 1 would means no shadow.
  74146. * @returns the darkness.
  74147. */
  74148. getDarkness(): number;
  74149. /**
  74150. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74151. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74152. * @returns the shadow generator allowing fluent coding.
  74153. */
  74154. setDarkness(darkness: number): ShadowGenerator;
  74155. private _transparencyShadow;
  74156. /** Gets or sets the ability to have transparent shadow */
  74157. transparencyShadow: boolean;
  74158. /**
  74159. * Sets the ability to have transparent shadow (boolean).
  74160. * @param transparent True if transparent else False
  74161. * @returns the shadow generator allowing fluent coding
  74162. */
  74163. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74164. private _shadowMap;
  74165. private _shadowMap2;
  74166. /**
  74167. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74168. * @returns The render target texture if present otherwise, null
  74169. */
  74170. getShadowMap(): Nullable<RenderTargetTexture>;
  74171. /**
  74172. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74173. * @returns The render target texture if the shadow map is present otherwise, null
  74174. */
  74175. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74176. /**
  74177. * Gets the class name of that object
  74178. * @returns "ShadowGenerator"
  74179. */
  74180. getClassName(): string;
  74181. /**
  74182. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74183. * @param mesh Mesh to add
  74184. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74185. * @returns the Shadow Generator itself
  74186. */
  74187. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74188. /**
  74189. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74190. * @param mesh Mesh to remove
  74191. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74192. * @returns the Shadow Generator itself
  74193. */
  74194. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74195. /**
  74196. * Controls the extent to which the shadows fade out at the edge of the frustum
  74197. * Used only by directionals and spots
  74198. */
  74199. frustumEdgeFalloff: number;
  74200. private _light;
  74201. /**
  74202. * Returns the associated light object.
  74203. * @returns the light generating the shadow
  74204. */
  74205. getLight(): IShadowLight;
  74206. /**
  74207. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74208. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74209. * It might on the other hand introduce peter panning.
  74210. */
  74211. forceBackFacesOnly: boolean;
  74212. private _scene;
  74213. private _lightDirection;
  74214. private _effect;
  74215. private _viewMatrix;
  74216. private _projectionMatrix;
  74217. private _transformMatrix;
  74218. private _cachedPosition;
  74219. private _cachedDirection;
  74220. private _cachedDefines;
  74221. private _currentRenderID;
  74222. private _boxBlurPostprocess;
  74223. private _kernelBlurXPostprocess;
  74224. private _kernelBlurYPostprocess;
  74225. private _blurPostProcesses;
  74226. private _mapSize;
  74227. private _currentFaceIndex;
  74228. private _currentFaceIndexCache;
  74229. private _textureType;
  74230. private _defaultTextureMatrix;
  74231. /** @hidden */
  74232. static _SceneComponentInitialization: (scene: Scene) => void;
  74233. /**
  74234. * Creates a ShadowGenerator object.
  74235. * A ShadowGenerator is the required tool to use the shadows.
  74236. * Each light casting shadows needs to use its own ShadowGenerator.
  74237. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74238. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74239. * @param light The light object generating the shadows.
  74240. * @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.
  74241. */
  74242. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74243. private _initializeGenerator;
  74244. private _initializeShadowMap;
  74245. private _initializeBlurRTTAndPostProcesses;
  74246. private _renderForShadowMap;
  74247. private _renderSubMeshForShadowMap;
  74248. private _applyFilterValues;
  74249. /**
  74250. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74251. * @param onCompiled Callback triggered at the and of the effects compilation
  74252. * @param options Sets of optional options forcing the compilation with different modes
  74253. */
  74254. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74255. useInstances: boolean;
  74256. }>): void;
  74257. /**
  74258. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74259. * @param options Sets of optional options forcing the compilation with different modes
  74260. * @returns A promise that resolves when the compilation completes
  74261. */
  74262. forceCompilationAsync(options?: Partial<{
  74263. useInstances: boolean;
  74264. }>): Promise<void>;
  74265. /**
  74266. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74267. * @param subMesh The submesh we want to render in the shadow map
  74268. * @param useInstances Defines wether will draw in the map using instances
  74269. * @returns true if ready otherwise, false
  74270. */
  74271. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74272. /**
  74273. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74274. * @param defines Defines of the material we want to update
  74275. * @param lightIndex Index of the light in the enabled light list of the material
  74276. */
  74277. prepareDefines(defines: any, lightIndex: number): void;
  74278. /**
  74279. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74280. * defined in the generator but impacting the effect).
  74281. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74282. * @param effect The effect we are binfing the information for
  74283. */
  74284. bindShadowLight(lightIndex: string, effect: Effect): void;
  74285. /**
  74286. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74287. * (eq to shadow prjection matrix * light transform matrix)
  74288. * @returns The transform matrix used to create the shadow map
  74289. */
  74290. getTransformMatrix(): Matrix;
  74291. /**
  74292. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74293. * Cube and 2D textures for instance.
  74294. */
  74295. recreateShadowMap(): void;
  74296. private _disposeBlurPostProcesses;
  74297. private _disposeRTTandPostProcesses;
  74298. /**
  74299. * Disposes the ShadowGenerator.
  74300. * Returns nothing.
  74301. */
  74302. dispose(): void;
  74303. /**
  74304. * Serializes the shadow generator setup to a json object.
  74305. * @returns The serialized JSON object
  74306. */
  74307. serialize(): any;
  74308. /**
  74309. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74310. * @param parsedShadowGenerator The JSON object to parse
  74311. * @param scene The scene to create the shadow map for
  74312. * @returns The parsed shadow generator
  74313. */
  74314. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74315. }
  74316. }
  74317. declare module BABYLON {
  74318. /**
  74319. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74320. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74321. * 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.
  74322. */
  74323. export abstract class Light extends Node {
  74324. /**
  74325. * Falloff Default: light is falling off following the material specification:
  74326. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74327. */
  74328. static readonly FALLOFF_DEFAULT: number;
  74329. /**
  74330. * Falloff Physical: light is falling off following the inverse squared distance law.
  74331. */
  74332. static readonly FALLOFF_PHYSICAL: number;
  74333. /**
  74334. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74335. * to enhance interoperability with other engines.
  74336. */
  74337. static readonly FALLOFF_GLTF: number;
  74338. /**
  74339. * Falloff Standard: light is falling off like in the standard material
  74340. * to enhance interoperability with other materials.
  74341. */
  74342. static readonly FALLOFF_STANDARD: number;
  74343. /**
  74344. * If every light affecting the material is in this lightmapMode,
  74345. * material.lightmapTexture adds or multiplies
  74346. * (depends on material.useLightmapAsShadowmap)
  74347. * after every other light calculations.
  74348. */
  74349. static readonly LIGHTMAP_DEFAULT: number;
  74350. /**
  74351. * material.lightmapTexture as only diffuse lighting from this light
  74352. * adds only specular lighting from this light
  74353. * adds dynamic shadows
  74354. */
  74355. static readonly LIGHTMAP_SPECULAR: number;
  74356. /**
  74357. * material.lightmapTexture as only lighting
  74358. * no light calculation from this light
  74359. * only adds dynamic shadows from this light
  74360. */
  74361. static readonly LIGHTMAP_SHADOWSONLY: number;
  74362. /**
  74363. * Each light type uses the default quantity according to its type:
  74364. * point/spot lights use luminous intensity
  74365. * directional lights use illuminance
  74366. */
  74367. static readonly INTENSITYMODE_AUTOMATIC: number;
  74368. /**
  74369. * lumen (lm)
  74370. */
  74371. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74372. /**
  74373. * candela (lm/sr)
  74374. */
  74375. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74376. /**
  74377. * lux (lm/m^2)
  74378. */
  74379. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74380. /**
  74381. * nit (cd/m^2)
  74382. */
  74383. static readonly INTENSITYMODE_LUMINANCE: number;
  74384. /**
  74385. * Light type const id of the point light.
  74386. */
  74387. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74388. /**
  74389. * Light type const id of the directional light.
  74390. */
  74391. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74392. /**
  74393. * Light type const id of the spot light.
  74394. */
  74395. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74396. /**
  74397. * Light type const id of the hemispheric light.
  74398. */
  74399. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74400. /**
  74401. * Diffuse gives the basic color to an object.
  74402. */
  74403. diffuse: Color3;
  74404. /**
  74405. * Specular produces a highlight color on an object.
  74406. * Note: This is note affecting PBR materials.
  74407. */
  74408. specular: Color3;
  74409. /**
  74410. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74411. * falling off base on range or angle.
  74412. * This can be set to any values in Light.FALLOFF_x.
  74413. *
  74414. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74415. * other types of materials.
  74416. */
  74417. falloffType: number;
  74418. /**
  74419. * Strength of the light.
  74420. * Note: By default it is define in the framework own unit.
  74421. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74422. */
  74423. intensity: number;
  74424. private _range;
  74425. protected _inverseSquaredRange: number;
  74426. /**
  74427. * Defines how far from the source the light is impacting in scene units.
  74428. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74429. */
  74430. /**
  74431. * Defines how far from the source the light is impacting in scene units.
  74432. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74433. */
  74434. range: number;
  74435. /**
  74436. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74437. * of light.
  74438. */
  74439. private _photometricScale;
  74440. private _intensityMode;
  74441. /**
  74442. * Gets the photometric scale used to interpret the intensity.
  74443. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74444. */
  74445. /**
  74446. * Sets the photometric scale used to interpret the intensity.
  74447. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74448. */
  74449. intensityMode: number;
  74450. private _radius;
  74451. /**
  74452. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74453. */
  74454. /**
  74455. * sets the light radius used by PBR Materials to simulate soft area lights.
  74456. */
  74457. radius: number;
  74458. private _renderPriority;
  74459. /**
  74460. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74461. * exceeding the number allowed of the materials.
  74462. */
  74463. renderPriority: number;
  74464. private _shadowEnabled;
  74465. /**
  74466. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74467. * the current shadow generator.
  74468. */
  74469. /**
  74470. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74471. * the current shadow generator.
  74472. */
  74473. shadowEnabled: boolean;
  74474. private _includedOnlyMeshes;
  74475. /**
  74476. * Gets the only meshes impacted by this light.
  74477. */
  74478. /**
  74479. * Sets the only meshes impacted by this light.
  74480. */
  74481. includedOnlyMeshes: AbstractMesh[];
  74482. private _excludedMeshes;
  74483. /**
  74484. * Gets the meshes not impacted by this light.
  74485. */
  74486. /**
  74487. * Sets the meshes not impacted by this light.
  74488. */
  74489. excludedMeshes: AbstractMesh[];
  74490. private _excludeWithLayerMask;
  74491. /**
  74492. * Gets the layer id use to find what meshes are not impacted by the light.
  74493. * Inactive if 0
  74494. */
  74495. /**
  74496. * Sets the layer id use to find what meshes are not impacted by the light.
  74497. * Inactive if 0
  74498. */
  74499. excludeWithLayerMask: number;
  74500. private _includeOnlyWithLayerMask;
  74501. /**
  74502. * Gets the layer id use to find what meshes are impacted by the light.
  74503. * Inactive if 0
  74504. */
  74505. /**
  74506. * Sets the layer id use to find what meshes are impacted by the light.
  74507. * Inactive if 0
  74508. */
  74509. includeOnlyWithLayerMask: number;
  74510. private _lightmapMode;
  74511. /**
  74512. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74513. */
  74514. /**
  74515. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74516. */
  74517. lightmapMode: number;
  74518. /**
  74519. * Shadow generator associted to the light.
  74520. * @hidden Internal use only.
  74521. */
  74522. _shadowGenerator: Nullable<IShadowGenerator>;
  74523. /**
  74524. * @hidden Internal use only.
  74525. */
  74526. _excludedMeshesIds: string[];
  74527. /**
  74528. * @hidden Internal use only.
  74529. */
  74530. _includedOnlyMeshesIds: string[];
  74531. /**
  74532. * The current light unifom buffer.
  74533. * @hidden Internal use only.
  74534. */
  74535. _uniformBuffer: UniformBuffer;
  74536. /**
  74537. * Creates a Light object in the scene.
  74538. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74539. * @param name The firendly name of the light
  74540. * @param scene The scene the light belongs too
  74541. */
  74542. constructor(name: string, scene: Scene);
  74543. protected abstract _buildUniformLayout(): void;
  74544. /**
  74545. * Sets the passed Effect "effect" with the Light information.
  74546. * @param effect The effect to update
  74547. * @param lightIndex The index of the light in the effect to update
  74548. * @returns The light
  74549. */
  74550. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74551. /**
  74552. * Returns the string "Light".
  74553. * @returns the class name
  74554. */
  74555. getClassName(): string;
  74556. /** @hidden */
  74557. readonly _isLight: boolean;
  74558. /**
  74559. * Converts the light information to a readable string for debug purpose.
  74560. * @param fullDetails Supports for multiple levels of logging within scene loading
  74561. * @returns the human readable light info
  74562. */
  74563. toString(fullDetails?: boolean): string;
  74564. /** @hidden */
  74565. protected _syncParentEnabledState(): void;
  74566. /**
  74567. * Set the enabled state of this node.
  74568. * @param value - the new enabled state
  74569. */
  74570. setEnabled(value: boolean): void;
  74571. /**
  74572. * Returns the Light associated shadow generator if any.
  74573. * @return the associated shadow generator.
  74574. */
  74575. getShadowGenerator(): Nullable<IShadowGenerator>;
  74576. /**
  74577. * Returns a Vector3, the absolute light position in the World.
  74578. * @returns the world space position of the light
  74579. */
  74580. getAbsolutePosition(): Vector3;
  74581. /**
  74582. * Specifies if the light will affect the passed mesh.
  74583. * @param mesh The mesh to test against the light
  74584. * @return true the mesh is affected otherwise, false.
  74585. */
  74586. canAffectMesh(mesh: AbstractMesh): boolean;
  74587. /**
  74588. * Sort function to order lights for rendering.
  74589. * @param a First Light object to compare to second.
  74590. * @param b Second Light object to compare first.
  74591. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74592. */
  74593. static CompareLightsPriority(a: Light, b: Light): number;
  74594. /**
  74595. * Releases resources associated with this node.
  74596. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74597. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74598. */
  74599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74600. /**
  74601. * Returns the light type ID (integer).
  74602. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74603. */
  74604. getTypeID(): number;
  74605. /**
  74606. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74607. * @returns the scaled intensity in intensity mode unit
  74608. */
  74609. getScaledIntensity(): number;
  74610. /**
  74611. * Returns a new Light object, named "name", from the current one.
  74612. * @param name The name of the cloned light
  74613. * @returns the new created light
  74614. */
  74615. clone(name: string): Nullable<Light>;
  74616. /**
  74617. * Serializes the current light into a Serialization object.
  74618. * @returns the serialized object.
  74619. */
  74620. serialize(): any;
  74621. /**
  74622. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74623. * This new light is named "name" and added to the passed scene.
  74624. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74625. * @param name The friendly name of the light
  74626. * @param scene The scene the new light will belong to
  74627. * @returns the constructor function
  74628. */
  74629. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74630. /**
  74631. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74632. * @param parsedLight The JSON representation of the light
  74633. * @param scene The scene to create the parsed light in
  74634. * @returns the created light after parsing
  74635. */
  74636. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74637. private _hookArrayForExcluded;
  74638. private _hookArrayForIncludedOnly;
  74639. private _resyncMeshes;
  74640. /**
  74641. * Forces the meshes to update their light related information in their rendering used effects
  74642. * @hidden Internal Use Only
  74643. */
  74644. _markMeshesAsLightDirty(): void;
  74645. /**
  74646. * Recomputes the cached photometric scale if needed.
  74647. */
  74648. private _computePhotometricScale;
  74649. /**
  74650. * Returns the Photometric Scale according to the light type and intensity mode.
  74651. */
  74652. private _getPhotometricScale;
  74653. /**
  74654. * Reorder the light in the scene according to their defined priority.
  74655. * @hidden Internal Use Only
  74656. */
  74657. _reorderLightsInScene(): void;
  74658. /**
  74659. * Prepares the list of defines specific to the light type.
  74660. * @param defines the list of defines
  74661. * @param lightIndex defines the index of the light for the effect
  74662. */
  74663. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74664. }
  74665. }
  74666. declare module BABYLON {
  74667. /**
  74668. * Creates an instance based on a source mesh.
  74669. */
  74670. export class InstancedMesh extends AbstractMesh {
  74671. private _sourceMesh;
  74672. private _currentLOD;
  74673. /** @hidden */
  74674. _indexInSourceMeshInstanceArray: number;
  74675. constructor(name: string, source: Mesh);
  74676. /**
  74677. * Returns the string "InstancedMesh".
  74678. */
  74679. getClassName(): string;
  74680. /** Gets the list of lights affecting that mesh */
  74681. readonly lightSources: Light[];
  74682. _resyncLightSources(): void;
  74683. _resyncLighSource(light: Light): void;
  74684. _removeLightSource(light: Light): void;
  74685. /**
  74686. * If the source mesh receives shadows
  74687. */
  74688. readonly receiveShadows: boolean;
  74689. /**
  74690. * The material of the source mesh
  74691. */
  74692. readonly material: Nullable<Material>;
  74693. /**
  74694. * Visibility of the source mesh
  74695. */
  74696. readonly visibility: number;
  74697. /**
  74698. * Skeleton of the source mesh
  74699. */
  74700. readonly skeleton: Nullable<Skeleton>;
  74701. /**
  74702. * Rendering ground id of the source mesh
  74703. */
  74704. renderingGroupId: number;
  74705. /**
  74706. * Returns the total number of vertices (integer).
  74707. */
  74708. getTotalVertices(): number;
  74709. /**
  74710. * Returns a positive integer : the total number of indices in this mesh geometry.
  74711. * @returns the numner of indices or zero if the mesh has no geometry.
  74712. */
  74713. getTotalIndices(): number;
  74714. /**
  74715. * The source mesh of the instance
  74716. */
  74717. readonly sourceMesh: Mesh;
  74718. /**
  74719. * Is this node ready to be used/rendered
  74720. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74721. * @return {boolean} is it ready
  74722. */
  74723. isReady(completeCheck?: boolean): boolean;
  74724. /**
  74725. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74726. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74727. * @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.
  74728. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74729. */
  74730. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74731. /**
  74732. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74733. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74734. * The `data` are either a numeric array either a Float32Array.
  74735. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74736. * 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).
  74737. * Note that a new underlying VertexBuffer object is created each call.
  74738. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74739. *
  74740. * Possible `kind` values :
  74741. * - VertexBuffer.PositionKind
  74742. * - VertexBuffer.UVKind
  74743. * - VertexBuffer.UV2Kind
  74744. * - VertexBuffer.UV3Kind
  74745. * - VertexBuffer.UV4Kind
  74746. * - VertexBuffer.UV5Kind
  74747. * - VertexBuffer.UV6Kind
  74748. * - VertexBuffer.ColorKind
  74749. * - VertexBuffer.MatricesIndicesKind
  74750. * - VertexBuffer.MatricesIndicesExtraKind
  74751. * - VertexBuffer.MatricesWeightsKind
  74752. * - VertexBuffer.MatricesWeightsExtraKind
  74753. *
  74754. * Returns the Mesh.
  74755. */
  74756. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74757. /**
  74758. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74759. * If the mesh has no geometry, it is simply returned as it is.
  74760. * The `data` are either a numeric array either a Float32Array.
  74761. * No new underlying VertexBuffer object is created.
  74762. * 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.
  74763. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74764. *
  74765. * Possible `kind` values :
  74766. * - VertexBuffer.PositionKind
  74767. * - VertexBuffer.UVKind
  74768. * - VertexBuffer.UV2Kind
  74769. * - VertexBuffer.UV3Kind
  74770. * - VertexBuffer.UV4Kind
  74771. * - VertexBuffer.UV5Kind
  74772. * - VertexBuffer.UV6Kind
  74773. * - VertexBuffer.ColorKind
  74774. * - VertexBuffer.MatricesIndicesKind
  74775. * - VertexBuffer.MatricesIndicesExtraKind
  74776. * - VertexBuffer.MatricesWeightsKind
  74777. * - VertexBuffer.MatricesWeightsExtraKind
  74778. *
  74779. * Returns the Mesh.
  74780. */
  74781. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74782. /**
  74783. * Sets the mesh indices.
  74784. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74785. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74786. * This method creates a new index buffer each call.
  74787. * Returns the Mesh.
  74788. */
  74789. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74790. /**
  74791. * Boolean : True if the mesh owns the requested kind of data.
  74792. */
  74793. isVerticesDataPresent(kind: string): boolean;
  74794. /**
  74795. * Returns an array of indices (IndicesArray).
  74796. */
  74797. getIndices(): Nullable<IndicesArray>;
  74798. readonly _positions: Nullable<Vector3[]>;
  74799. /**
  74800. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74801. * This means the mesh underlying bounding box and sphere are recomputed.
  74802. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74803. * @returns the current mesh
  74804. */
  74805. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74806. /** @hidden */
  74807. _preActivate(): InstancedMesh;
  74808. /** @hidden */
  74809. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74810. /** @hidden */
  74811. _postActivate(): void;
  74812. getWorldMatrix(): Matrix;
  74813. readonly isAnInstance: boolean;
  74814. /**
  74815. * Returns the current associated LOD AbstractMesh.
  74816. */
  74817. getLOD(camera: Camera): AbstractMesh;
  74818. /** @hidden */
  74819. _syncSubMeshes(): InstancedMesh;
  74820. /** @hidden */
  74821. _generatePointsArray(): boolean;
  74822. /**
  74823. * Creates a new InstancedMesh from the current mesh.
  74824. * - name (string) : the cloned mesh name
  74825. * - newParent (optional Node) : the optional Node to parent the clone to.
  74826. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74827. *
  74828. * Returns the clone.
  74829. */
  74830. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74831. /**
  74832. * Disposes the InstancedMesh.
  74833. * Returns nothing.
  74834. */
  74835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74836. }
  74837. }
  74838. declare module BABYLON {
  74839. /**
  74840. * Defines the options associated with the creation of a shader material.
  74841. */
  74842. export interface IShaderMaterialOptions {
  74843. /**
  74844. * Does the material work in alpha blend mode
  74845. */
  74846. needAlphaBlending: boolean;
  74847. /**
  74848. * Does the material work in alpha test mode
  74849. */
  74850. needAlphaTesting: boolean;
  74851. /**
  74852. * The list of attribute names used in the shader
  74853. */
  74854. attributes: string[];
  74855. /**
  74856. * The list of unifrom names used in the shader
  74857. */
  74858. uniforms: string[];
  74859. /**
  74860. * The list of UBO names used in the shader
  74861. */
  74862. uniformBuffers: string[];
  74863. /**
  74864. * The list of sampler names used in the shader
  74865. */
  74866. samplers: string[];
  74867. /**
  74868. * The list of defines used in the shader
  74869. */
  74870. defines: string[];
  74871. }
  74872. /**
  74873. * 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.
  74874. *
  74875. * This returned material effects how the mesh will look based on the code in the shaders.
  74876. *
  74877. * @see http://doc.babylonjs.com/how_to/shader_material
  74878. */
  74879. export class ShaderMaterial extends Material {
  74880. private _shaderPath;
  74881. private _options;
  74882. private _textures;
  74883. private _textureArrays;
  74884. private _floats;
  74885. private _ints;
  74886. private _floatsArrays;
  74887. private _colors3;
  74888. private _colors3Arrays;
  74889. private _colors4;
  74890. private _colors4Arrays;
  74891. private _vectors2;
  74892. private _vectors3;
  74893. private _vectors4;
  74894. private _matrices;
  74895. private _matrices3x3;
  74896. private _matrices2x2;
  74897. private _vectors2Arrays;
  74898. private _vectors3Arrays;
  74899. private _vectors4Arrays;
  74900. private _cachedWorldViewMatrix;
  74901. private _cachedWorldViewProjectionMatrix;
  74902. private _renderId;
  74903. /**
  74904. * Instantiate a new shader material.
  74905. * 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.
  74906. * This returned material effects how the mesh will look based on the code in the shaders.
  74907. * @see http://doc.babylonjs.com/how_to/shader_material
  74908. * @param name Define the name of the material in the scene
  74909. * @param scene Define the scene the material belongs to
  74910. * @param shaderPath Defines the route to the shader code in one of three ways:
  74911. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74912. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74913. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74914. * @param options Define the options used to create the shader
  74915. */
  74916. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74917. /**
  74918. * Gets the options used to compile the shader.
  74919. * They can be modified to trigger a new compilation
  74920. */
  74921. readonly options: IShaderMaterialOptions;
  74922. /**
  74923. * Gets the current class name of the material e.g. "ShaderMaterial"
  74924. * Mainly use in serialization.
  74925. * @returns the class name
  74926. */
  74927. getClassName(): string;
  74928. /**
  74929. * Specifies if the material will require alpha blending
  74930. * @returns a boolean specifying if alpha blending is needed
  74931. */
  74932. needAlphaBlending(): boolean;
  74933. /**
  74934. * Specifies if this material should be rendered in alpha test mode
  74935. * @returns a boolean specifying if an alpha test is needed.
  74936. */
  74937. needAlphaTesting(): boolean;
  74938. private _checkUniform;
  74939. /**
  74940. * Set a texture in the shader.
  74941. * @param name Define the name of the uniform samplers as defined in the shader
  74942. * @param texture Define the texture to bind to this sampler
  74943. * @return the material itself allowing "fluent" like uniform updates
  74944. */
  74945. setTexture(name: string, texture: Texture): ShaderMaterial;
  74946. /**
  74947. * Set a texture array in the shader.
  74948. * @param name Define the name of the uniform sampler array as defined in the shader
  74949. * @param textures Define the list of textures to bind to this sampler
  74950. * @return the material itself allowing "fluent" like uniform updates
  74951. */
  74952. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74953. /**
  74954. * Set a float in the shader.
  74955. * @param name Define the name of the uniform as defined in the shader
  74956. * @param value Define the value to give to the uniform
  74957. * @return the material itself allowing "fluent" like uniform updates
  74958. */
  74959. setFloat(name: string, value: number): ShaderMaterial;
  74960. /**
  74961. * Set a int in the shader.
  74962. * @param name Define the name of the uniform as defined in the shader
  74963. * @param value Define the value to give to the uniform
  74964. * @return the material itself allowing "fluent" like uniform updates
  74965. */
  74966. setInt(name: string, value: number): ShaderMaterial;
  74967. /**
  74968. * Set an array of floats in the shader.
  74969. * @param name Define the name of the uniform as defined in the shader
  74970. * @param value Define the value to give to the uniform
  74971. * @return the material itself allowing "fluent" like uniform updates
  74972. */
  74973. setFloats(name: string, value: number[]): ShaderMaterial;
  74974. /**
  74975. * Set a vec3 in the shader from a Color3.
  74976. * @param name Define the name of the uniform as defined in the shader
  74977. * @param value Define the value to give to the uniform
  74978. * @return the material itself allowing "fluent" like uniform updates
  74979. */
  74980. setColor3(name: string, value: Color3): ShaderMaterial;
  74981. /**
  74982. * Set a vec3 array in the shader from a Color3 array.
  74983. * @param name Define the name of the uniform as defined in the shader
  74984. * @param value Define the value to give to the uniform
  74985. * @return the material itself allowing "fluent" like uniform updates
  74986. */
  74987. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74988. /**
  74989. * Set a vec4 in the shader from a Color4.
  74990. * @param name Define the name of the uniform as defined in the shader
  74991. * @param value Define the value to give to the uniform
  74992. * @return the material itself allowing "fluent" like uniform updates
  74993. */
  74994. setColor4(name: string, value: Color4): ShaderMaterial;
  74995. /**
  74996. * Set a vec4 array in the shader from a Color4 array.
  74997. * @param name Define the name of the uniform as defined in the shader
  74998. * @param value Define the value to give to the uniform
  74999. * @return the material itself allowing "fluent" like uniform updates
  75000. */
  75001. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  75002. /**
  75003. * Set a vec2 in the shader from a Vector2.
  75004. * @param name Define the name of the uniform as defined in the shader
  75005. * @param value Define the value to give to the uniform
  75006. * @return the material itself allowing "fluent" like uniform updates
  75007. */
  75008. setVector2(name: string, value: Vector2): ShaderMaterial;
  75009. /**
  75010. * Set a vec3 in the shader from a Vector3.
  75011. * @param name Define the name of the uniform as defined in the shader
  75012. * @param value Define the value to give to the uniform
  75013. * @return the material itself allowing "fluent" like uniform updates
  75014. */
  75015. setVector3(name: string, value: Vector3): ShaderMaterial;
  75016. /**
  75017. * Set a vec4 in the shader from a Vector4.
  75018. * @param name Define the name of the uniform as defined in the shader
  75019. * @param value Define the value to give to the uniform
  75020. * @return the material itself allowing "fluent" like uniform updates
  75021. */
  75022. setVector4(name: string, value: Vector4): ShaderMaterial;
  75023. /**
  75024. * Set a mat4 in the shader from a Matrix.
  75025. * @param name Define the name of the uniform as defined in the shader
  75026. * @param value Define the value to give to the uniform
  75027. * @return the material itself allowing "fluent" like uniform updates
  75028. */
  75029. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75030. /**
  75031. * Set a mat3 in the shader from a Float32Array.
  75032. * @param name Define the name of the uniform as defined in the shader
  75033. * @param value Define the value to give to the uniform
  75034. * @return the material itself allowing "fluent" like uniform updates
  75035. */
  75036. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75037. /**
  75038. * Set a mat2 in the shader from a Float32Array.
  75039. * @param name Define the name of the uniform as defined in the shader
  75040. * @param value Define the value to give to the uniform
  75041. * @return the material itself allowing "fluent" like uniform updates
  75042. */
  75043. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75044. /**
  75045. * Set a vec2 array in the shader from a number array.
  75046. * @param name Define the name of the uniform as defined in the shader
  75047. * @param value Define the value to give to the uniform
  75048. * @return the material itself allowing "fluent" like uniform updates
  75049. */
  75050. setArray2(name: string, value: number[]): ShaderMaterial;
  75051. /**
  75052. * Set a vec3 array in the shader from a number array.
  75053. * @param name Define the name of the uniform as defined in the shader
  75054. * @param value Define the value to give to the uniform
  75055. * @return the material itself allowing "fluent" like uniform updates
  75056. */
  75057. setArray3(name: string, value: number[]): ShaderMaterial;
  75058. /**
  75059. * Set a vec4 array in the shader from a number array.
  75060. * @param name Define the name of the uniform as defined in the shader
  75061. * @param value Define the value to give to the uniform
  75062. * @return the material itself allowing "fluent" like uniform updates
  75063. */
  75064. setArray4(name: string, value: number[]): ShaderMaterial;
  75065. private _checkCache;
  75066. /**
  75067. * Specifies that the submesh is ready to be used
  75068. * @param mesh defines the mesh to check
  75069. * @param subMesh defines which submesh to check
  75070. * @param useInstances specifies that instances should be used
  75071. * @returns a boolean indicating that the submesh is ready or not
  75072. */
  75073. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75074. /**
  75075. * Checks if the material is ready to render the requested mesh
  75076. * @param mesh Define the mesh to render
  75077. * @param useInstances Define whether or not the material is used with instances
  75078. * @returns true if ready, otherwise false
  75079. */
  75080. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75081. /**
  75082. * Binds the world matrix to the material
  75083. * @param world defines the world transformation matrix
  75084. */
  75085. bindOnlyWorldMatrix(world: Matrix): void;
  75086. /**
  75087. * Binds the material to the mesh
  75088. * @param world defines the world transformation matrix
  75089. * @param mesh defines the mesh to bind the material to
  75090. */
  75091. bind(world: Matrix, mesh?: Mesh): void;
  75092. /**
  75093. * Gets the active textures from the material
  75094. * @returns an array of textures
  75095. */
  75096. getActiveTextures(): BaseTexture[];
  75097. /**
  75098. * Specifies if the material uses a texture
  75099. * @param texture defines the texture to check against the material
  75100. * @returns a boolean specifying if the material uses the texture
  75101. */
  75102. hasTexture(texture: BaseTexture): boolean;
  75103. /**
  75104. * Makes a duplicate of the material, and gives it a new name
  75105. * @param name defines the new name for the duplicated material
  75106. * @returns the cloned material
  75107. */
  75108. clone(name: string): ShaderMaterial;
  75109. /**
  75110. * Disposes the material
  75111. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75112. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75113. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75114. */
  75115. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75116. /**
  75117. * Serializes this material in a JSON representation
  75118. * @returns the serialized material object
  75119. */
  75120. serialize(): any;
  75121. /**
  75122. * Creates a shader material from parsed shader material data
  75123. * @param source defines the JSON represnetation of the material
  75124. * @param scene defines the hosting scene
  75125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75126. * @returns a new material
  75127. */
  75128. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75129. }
  75130. }
  75131. declare module BABYLON {
  75132. /** @hidden */
  75133. export var clipPlaneFragmentDeclaration: {
  75134. name: string;
  75135. shader: string;
  75136. };
  75137. }
  75138. declare module BABYLON {
  75139. /** @hidden */
  75140. export var clipPlaneFragment: {
  75141. name: string;
  75142. shader: string;
  75143. };
  75144. }
  75145. declare module BABYLON {
  75146. /** @hidden */
  75147. export var colorPixelShader: {
  75148. name: string;
  75149. shader: string;
  75150. };
  75151. }
  75152. declare module BABYLON {
  75153. /** @hidden */
  75154. export var clipPlaneVertexDeclaration: {
  75155. name: string;
  75156. shader: string;
  75157. };
  75158. }
  75159. declare module BABYLON {
  75160. /** @hidden */
  75161. export var clipPlaneVertex: {
  75162. name: string;
  75163. shader: string;
  75164. };
  75165. }
  75166. declare module BABYLON {
  75167. /** @hidden */
  75168. export var colorVertexShader: {
  75169. name: string;
  75170. shader: string;
  75171. };
  75172. }
  75173. declare module BABYLON {
  75174. /**
  75175. * Line mesh
  75176. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75177. */
  75178. export class LinesMesh extends Mesh {
  75179. /**
  75180. * If vertex color should be applied to the mesh
  75181. */
  75182. readonly useVertexColor?: boolean | undefined;
  75183. /**
  75184. * If vertex alpha should be applied to the mesh
  75185. */
  75186. readonly useVertexAlpha?: boolean | undefined;
  75187. /**
  75188. * Color of the line (Default: White)
  75189. */
  75190. color: Color3;
  75191. /**
  75192. * Alpha of the line (Default: 1)
  75193. */
  75194. alpha: number;
  75195. /**
  75196. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75197. * This margin is expressed in world space coordinates, so its value may vary.
  75198. * Default value is 0.1
  75199. */
  75200. intersectionThreshold: number;
  75201. private _colorShader;
  75202. private color4;
  75203. /**
  75204. * Creates a new LinesMesh
  75205. * @param name defines the name
  75206. * @param scene defines the hosting scene
  75207. * @param parent defines the parent mesh if any
  75208. * @param source defines the optional source LinesMesh used to clone data from
  75209. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75210. * When false, achieved by calling a clone(), also passing False.
  75211. * This will make creation of children, recursive.
  75212. * @param useVertexColor defines if this LinesMesh supports vertex color
  75213. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75214. */
  75215. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75216. /**
  75217. * If vertex color should be applied to the mesh
  75218. */
  75219. useVertexColor?: boolean | undefined,
  75220. /**
  75221. * If vertex alpha should be applied to the mesh
  75222. */
  75223. useVertexAlpha?: boolean | undefined);
  75224. private _addClipPlaneDefine;
  75225. private _removeClipPlaneDefine;
  75226. isReady(): boolean;
  75227. /**
  75228. * Returns the string "LineMesh"
  75229. */
  75230. getClassName(): string;
  75231. /**
  75232. * @hidden
  75233. */
  75234. /**
  75235. * @hidden
  75236. */
  75237. material: Material;
  75238. /**
  75239. * @hidden
  75240. */
  75241. readonly checkCollisions: boolean;
  75242. /** @hidden */
  75243. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75244. /** @hidden */
  75245. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75246. /**
  75247. * Disposes of the line mesh
  75248. * @param doNotRecurse If children should be disposed
  75249. */
  75250. dispose(doNotRecurse?: boolean): void;
  75251. /**
  75252. * Returns a new LineMesh object cloned from the current one.
  75253. */
  75254. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75255. /**
  75256. * Creates a new InstancedLinesMesh object from the mesh model.
  75257. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75258. * @param name defines the name of the new instance
  75259. * @returns a new InstancedLinesMesh
  75260. */
  75261. createInstance(name: string): InstancedLinesMesh;
  75262. }
  75263. /**
  75264. * Creates an instance based on a source LinesMesh
  75265. */
  75266. export class InstancedLinesMesh extends InstancedMesh {
  75267. /**
  75268. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75269. * This margin is expressed in world space coordinates, so its value may vary.
  75270. * Initilized with the intersectionThreshold value of the source LinesMesh
  75271. */
  75272. intersectionThreshold: number;
  75273. constructor(name: string, source: LinesMesh);
  75274. /**
  75275. * Returns the string "InstancedLinesMesh".
  75276. */
  75277. getClassName(): string;
  75278. }
  75279. }
  75280. declare module BABYLON {
  75281. /**
  75282. * Mesh representing the gorund
  75283. */
  75284. export class GroundMesh extends Mesh {
  75285. /** If octree should be generated */
  75286. generateOctree: boolean;
  75287. private _heightQuads;
  75288. /** @hidden */
  75289. _subdivisionsX: number;
  75290. /** @hidden */
  75291. _subdivisionsY: number;
  75292. /** @hidden */
  75293. _width: number;
  75294. /** @hidden */
  75295. _height: number;
  75296. /** @hidden */
  75297. _minX: number;
  75298. /** @hidden */
  75299. _maxX: number;
  75300. /** @hidden */
  75301. _minZ: number;
  75302. /** @hidden */
  75303. _maxZ: number;
  75304. constructor(name: string, scene: Scene);
  75305. /**
  75306. * "GroundMesh"
  75307. * @returns "GroundMesh"
  75308. */
  75309. getClassName(): string;
  75310. /**
  75311. * The minimum of x and y subdivisions
  75312. */
  75313. readonly subdivisions: number;
  75314. /**
  75315. * X subdivisions
  75316. */
  75317. readonly subdivisionsX: number;
  75318. /**
  75319. * Y subdivisions
  75320. */
  75321. readonly subdivisionsY: number;
  75322. /**
  75323. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75324. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75325. * @param chunksCount the number of subdivisions for x and y
  75326. * @param octreeBlocksSize (Default: 32)
  75327. */
  75328. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75329. /**
  75330. * Returns a height (y) value in the Worl system :
  75331. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75332. * @param x x coordinate
  75333. * @param z z coordinate
  75334. * @returns the ground y position if (x, z) are outside the ground surface.
  75335. */
  75336. getHeightAtCoordinates(x: number, z: number): number;
  75337. /**
  75338. * Returns a normalized vector (Vector3) orthogonal to the ground
  75339. * at the ground coordinates (x, z) expressed in the World system.
  75340. * @param x x coordinate
  75341. * @param z z coordinate
  75342. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75343. */
  75344. getNormalAtCoordinates(x: number, z: number): Vector3;
  75345. /**
  75346. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75347. * at the ground coordinates (x, z) expressed in the World system.
  75348. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75349. * @param x x coordinate
  75350. * @param z z coordinate
  75351. * @param ref vector to store the result
  75352. * @returns the GroundMesh.
  75353. */
  75354. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75355. /**
  75356. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75357. * if the ground has been updated.
  75358. * This can be used in the render loop.
  75359. * @returns the GroundMesh.
  75360. */
  75361. updateCoordinateHeights(): GroundMesh;
  75362. private _getFacetAt;
  75363. private _initHeightQuads;
  75364. private _computeHeightQuads;
  75365. /**
  75366. * Serializes this ground mesh
  75367. * @param serializationObject object to write serialization to
  75368. */
  75369. serialize(serializationObject: any): void;
  75370. /**
  75371. * Parses a serialized ground mesh
  75372. * @param parsedMesh the serialized mesh
  75373. * @param scene the scene to create the ground mesh in
  75374. * @returns the created ground mesh
  75375. */
  75376. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75377. }
  75378. }
  75379. declare module BABYLON {
  75380. /**
  75381. * Interface for Physics-Joint data
  75382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75383. */
  75384. export interface PhysicsJointData {
  75385. /**
  75386. * The main pivot of the joint
  75387. */
  75388. mainPivot?: Vector3;
  75389. /**
  75390. * The connected pivot of the joint
  75391. */
  75392. connectedPivot?: Vector3;
  75393. /**
  75394. * The main axis of the joint
  75395. */
  75396. mainAxis?: Vector3;
  75397. /**
  75398. * The connected axis of the joint
  75399. */
  75400. connectedAxis?: Vector3;
  75401. /**
  75402. * The collision of the joint
  75403. */
  75404. collision?: boolean;
  75405. /**
  75406. * Native Oimo/Cannon/Energy data
  75407. */
  75408. nativeParams?: any;
  75409. }
  75410. /**
  75411. * This is a holder class for the physics joint created by the physics plugin
  75412. * It holds a set of functions to control the underlying joint
  75413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75414. */
  75415. export class PhysicsJoint {
  75416. /**
  75417. * The type of the physics joint
  75418. */
  75419. type: number;
  75420. /**
  75421. * The data for the physics joint
  75422. */
  75423. jointData: PhysicsJointData;
  75424. private _physicsJoint;
  75425. protected _physicsPlugin: IPhysicsEnginePlugin;
  75426. /**
  75427. * Initializes the physics joint
  75428. * @param type The type of the physics joint
  75429. * @param jointData The data for the physics joint
  75430. */
  75431. constructor(
  75432. /**
  75433. * The type of the physics joint
  75434. */
  75435. type: number,
  75436. /**
  75437. * The data for the physics joint
  75438. */
  75439. jointData: PhysicsJointData);
  75440. /**
  75441. * Gets the physics joint
  75442. */
  75443. /**
  75444. * Sets the physics joint
  75445. */
  75446. physicsJoint: any;
  75447. /**
  75448. * Sets the physics plugin
  75449. */
  75450. physicsPlugin: IPhysicsEnginePlugin;
  75451. /**
  75452. * Execute a function that is physics-plugin specific.
  75453. * @param {Function} func the function that will be executed.
  75454. * It accepts two parameters: the physics world and the physics joint
  75455. */
  75456. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75457. /**
  75458. * Distance-Joint type
  75459. */
  75460. static DistanceJoint: number;
  75461. /**
  75462. * Hinge-Joint type
  75463. */
  75464. static HingeJoint: number;
  75465. /**
  75466. * Ball-and-Socket joint type
  75467. */
  75468. static BallAndSocketJoint: number;
  75469. /**
  75470. * Wheel-Joint type
  75471. */
  75472. static WheelJoint: number;
  75473. /**
  75474. * Slider-Joint type
  75475. */
  75476. static SliderJoint: number;
  75477. /**
  75478. * Prismatic-Joint type
  75479. */
  75480. static PrismaticJoint: number;
  75481. /**
  75482. * Universal-Joint type
  75483. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75484. */
  75485. static UniversalJoint: number;
  75486. /**
  75487. * Hinge-Joint 2 type
  75488. */
  75489. static Hinge2Joint: number;
  75490. /**
  75491. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75492. */
  75493. static PointToPointJoint: number;
  75494. /**
  75495. * Spring-Joint type
  75496. */
  75497. static SpringJoint: number;
  75498. /**
  75499. * Lock-Joint type
  75500. */
  75501. static LockJoint: number;
  75502. }
  75503. /**
  75504. * A class representing a physics distance joint
  75505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75506. */
  75507. export class DistanceJoint extends PhysicsJoint {
  75508. /**
  75509. *
  75510. * @param jointData The data for the Distance-Joint
  75511. */
  75512. constructor(jointData: DistanceJointData);
  75513. /**
  75514. * Update the predefined distance.
  75515. * @param maxDistance The maximum preferred distance
  75516. * @param minDistance The minimum preferred distance
  75517. */
  75518. updateDistance(maxDistance: number, minDistance?: number): void;
  75519. }
  75520. /**
  75521. * Represents a Motor-Enabled Joint
  75522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75523. */
  75524. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75525. /**
  75526. * Initializes the Motor-Enabled Joint
  75527. * @param type The type of the joint
  75528. * @param jointData The physica joint data for the joint
  75529. */
  75530. constructor(type: number, jointData: PhysicsJointData);
  75531. /**
  75532. * Set the motor values.
  75533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75534. * @param force the force to apply
  75535. * @param maxForce max force for this motor.
  75536. */
  75537. setMotor(force?: number, maxForce?: number): void;
  75538. /**
  75539. * Set the motor's limits.
  75540. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75541. * @param upperLimit The upper limit of the motor
  75542. * @param lowerLimit The lower limit of the motor
  75543. */
  75544. setLimit(upperLimit: number, lowerLimit?: number): void;
  75545. }
  75546. /**
  75547. * This class represents a single physics Hinge-Joint
  75548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75549. */
  75550. export class HingeJoint extends MotorEnabledJoint {
  75551. /**
  75552. * Initializes the Hinge-Joint
  75553. * @param jointData The joint data for the Hinge-Joint
  75554. */
  75555. constructor(jointData: PhysicsJointData);
  75556. /**
  75557. * Set the motor values.
  75558. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75559. * @param {number} force the force to apply
  75560. * @param {number} maxForce max force for this motor.
  75561. */
  75562. setMotor(force?: number, maxForce?: number): void;
  75563. /**
  75564. * Set the motor's limits.
  75565. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75566. * @param upperLimit The upper limit of the motor
  75567. * @param lowerLimit The lower limit of the motor
  75568. */
  75569. setLimit(upperLimit: number, lowerLimit?: number): void;
  75570. }
  75571. /**
  75572. * This class represents a dual hinge physics joint (same as wheel joint)
  75573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75574. */
  75575. export class Hinge2Joint extends MotorEnabledJoint {
  75576. /**
  75577. * Initializes the Hinge2-Joint
  75578. * @param jointData The joint data for the Hinge2-Joint
  75579. */
  75580. constructor(jointData: PhysicsJointData);
  75581. /**
  75582. * Set the motor values.
  75583. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75584. * @param {number} targetSpeed the speed the motor is to reach
  75585. * @param {number} maxForce max force for this motor.
  75586. * @param {motorIndex} the motor's index, 0 or 1.
  75587. */
  75588. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75589. /**
  75590. * Set the motor limits.
  75591. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75592. * @param {number} upperLimit the upper limit
  75593. * @param {number} lowerLimit lower limit
  75594. * @param {motorIndex} the motor's index, 0 or 1.
  75595. */
  75596. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75597. }
  75598. /**
  75599. * Interface for a motor enabled joint
  75600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75601. */
  75602. export interface IMotorEnabledJoint {
  75603. /**
  75604. * Physics joint
  75605. */
  75606. physicsJoint: any;
  75607. /**
  75608. * Sets the motor of the motor-enabled joint
  75609. * @param force The force of the motor
  75610. * @param maxForce The maximum force of the motor
  75611. * @param motorIndex The index of the motor
  75612. */
  75613. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75614. /**
  75615. * Sets the limit of the motor
  75616. * @param upperLimit The upper limit of the motor
  75617. * @param lowerLimit The lower limit of the motor
  75618. * @param motorIndex The index of the motor
  75619. */
  75620. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75621. }
  75622. /**
  75623. * Joint data for a Distance-Joint
  75624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75625. */
  75626. export interface DistanceJointData extends PhysicsJointData {
  75627. /**
  75628. * Max distance the 2 joint objects can be apart
  75629. */
  75630. maxDistance: number;
  75631. }
  75632. /**
  75633. * Joint data from a spring joint
  75634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75635. */
  75636. export interface SpringJointData extends PhysicsJointData {
  75637. /**
  75638. * Length of the spring
  75639. */
  75640. length: number;
  75641. /**
  75642. * Stiffness of the spring
  75643. */
  75644. stiffness: number;
  75645. /**
  75646. * Damping of the spring
  75647. */
  75648. damping: number;
  75649. /** this callback will be called when applying the force to the impostors. */
  75650. forceApplicationCallback: () => void;
  75651. }
  75652. }
  75653. declare module BABYLON {
  75654. /**
  75655. * Holds the data for the raycast result
  75656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75657. */
  75658. export class PhysicsRaycastResult {
  75659. private _hasHit;
  75660. private _hitDistance;
  75661. private _hitNormalWorld;
  75662. private _hitPointWorld;
  75663. private _rayFromWorld;
  75664. private _rayToWorld;
  75665. /**
  75666. * Gets if there was a hit
  75667. */
  75668. readonly hasHit: boolean;
  75669. /**
  75670. * Gets the distance from the hit
  75671. */
  75672. readonly hitDistance: number;
  75673. /**
  75674. * Gets the hit normal/direction in the world
  75675. */
  75676. readonly hitNormalWorld: Vector3;
  75677. /**
  75678. * Gets the hit point in the world
  75679. */
  75680. readonly hitPointWorld: Vector3;
  75681. /**
  75682. * Gets the ray "start point" of the ray in the world
  75683. */
  75684. readonly rayFromWorld: Vector3;
  75685. /**
  75686. * Gets the ray "end point" of the ray in the world
  75687. */
  75688. readonly rayToWorld: Vector3;
  75689. /**
  75690. * Sets the hit data (normal & point in world space)
  75691. * @param hitNormalWorld defines the normal in world space
  75692. * @param hitPointWorld defines the point in world space
  75693. */
  75694. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75695. /**
  75696. * Sets the distance from the start point to the hit point
  75697. * @param distance
  75698. */
  75699. setHitDistance(distance: number): void;
  75700. /**
  75701. * Calculates the distance manually
  75702. */
  75703. calculateHitDistance(): void;
  75704. /**
  75705. * Resets all the values to default
  75706. * @param from The from point on world space
  75707. * @param to The to point on world space
  75708. */
  75709. reset(from?: Vector3, to?: Vector3): void;
  75710. }
  75711. /**
  75712. * Interface for the size containing width and height
  75713. */
  75714. interface IXYZ {
  75715. /**
  75716. * X
  75717. */
  75718. x: number;
  75719. /**
  75720. * Y
  75721. */
  75722. y: number;
  75723. /**
  75724. * Z
  75725. */
  75726. z: number;
  75727. }
  75728. }
  75729. declare module BABYLON {
  75730. /**
  75731. * Interface used to describe a physics joint
  75732. */
  75733. export interface PhysicsImpostorJoint {
  75734. /** Defines the main impostor to which the joint is linked */
  75735. mainImpostor: PhysicsImpostor;
  75736. /** Defines the impostor that is connected to the main impostor using this joint */
  75737. connectedImpostor: PhysicsImpostor;
  75738. /** Defines the joint itself */
  75739. joint: PhysicsJoint;
  75740. }
  75741. /** @hidden */
  75742. export interface IPhysicsEnginePlugin {
  75743. world: any;
  75744. name: string;
  75745. setGravity(gravity: Vector3): void;
  75746. setTimeStep(timeStep: number): void;
  75747. getTimeStep(): number;
  75748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75750. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75751. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75752. removePhysicsBody(impostor: PhysicsImpostor): void;
  75753. generateJoint(joint: PhysicsImpostorJoint): void;
  75754. removeJoint(joint: PhysicsImpostorJoint): void;
  75755. isSupported(): boolean;
  75756. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75757. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75758. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75759. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75760. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75761. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75762. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75763. getBodyMass(impostor: PhysicsImpostor): number;
  75764. getBodyFriction(impostor: PhysicsImpostor): number;
  75765. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75766. getBodyRestitution(impostor: PhysicsImpostor): number;
  75767. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75768. getBodyPressure?(impostor: PhysicsImpostor): number;
  75769. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75770. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75771. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75772. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75773. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75774. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75775. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75776. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75777. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75778. sleepBody(impostor: PhysicsImpostor): void;
  75779. wakeUpBody(impostor: PhysicsImpostor): void;
  75780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75781. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75782. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75783. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75784. getRadius(impostor: PhysicsImpostor): number;
  75785. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75786. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75787. dispose(): void;
  75788. }
  75789. /**
  75790. * Interface used to define a physics engine
  75791. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75792. */
  75793. export interface IPhysicsEngine {
  75794. /**
  75795. * Gets the gravity vector used by the simulation
  75796. */
  75797. gravity: Vector3;
  75798. /**
  75799. * Sets the gravity vector used by the simulation
  75800. * @param gravity defines the gravity vector to use
  75801. */
  75802. setGravity(gravity: Vector3): void;
  75803. /**
  75804. * Set the time step of the physics engine.
  75805. * Default is 1/60.
  75806. * To slow it down, enter 1/600 for example.
  75807. * To speed it up, 1/30
  75808. * @param newTimeStep the new timestep to apply to this world.
  75809. */
  75810. setTimeStep(newTimeStep: number): void;
  75811. /**
  75812. * Get the time step of the physics engine.
  75813. * @returns the current time step
  75814. */
  75815. getTimeStep(): number;
  75816. /**
  75817. * Release all resources
  75818. */
  75819. dispose(): void;
  75820. /**
  75821. * Gets the name of the current physics plugin
  75822. * @returns the name of the plugin
  75823. */
  75824. getPhysicsPluginName(): string;
  75825. /**
  75826. * Adding a new impostor for the impostor tracking.
  75827. * This will be done by the impostor itself.
  75828. * @param impostor the impostor to add
  75829. */
  75830. addImpostor(impostor: PhysicsImpostor): void;
  75831. /**
  75832. * Remove an impostor from the engine.
  75833. * This impostor and its mesh will not longer be updated by the physics engine.
  75834. * @param impostor the impostor to remove
  75835. */
  75836. removeImpostor(impostor: PhysicsImpostor): void;
  75837. /**
  75838. * Add a joint to the physics engine
  75839. * @param mainImpostor defines the main impostor to which the joint is added.
  75840. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75841. * @param joint defines the joint that will connect both impostors.
  75842. */
  75843. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75844. /**
  75845. * Removes a joint from the simulation
  75846. * @param mainImpostor defines the impostor used with the joint
  75847. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75848. * @param joint defines the joint to remove
  75849. */
  75850. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75851. /**
  75852. * Gets the current plugin used to run the simulation
  75853. * @returns current plugin
  75854. */
  75855. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75856. /**
  75857. * Gets the list of physic impostors
  75858. * @returns an array of PhysicsImpostor
  75859. */
  75860. getImpostors(): Array<PhysicsImpostor>;
  75861. /**
  75862. * Gets the impostor for a physics enabled object
  75863. * @param object defines the object impersonated by the impostor
  75864. * @returns the PhysicsImpostor or null if not found
  75865. */
  75866. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75867. /**
  75868. * Gets the impostor for a physics body object
  75869. * @param body defines physics body used by the impostor
  75870. * @returns the PhysicsImpostor or null if not found
  75871. */
  75872. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75873. /**
  75874. * Does a raycast in the physics world
  75875. * @param from when should the ray start?
  75876. * @param to when should the ray end?
  75877. * @returns PhysicsRaycastResult
  75878. */
  75879. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75880. /**
  75881. * Called by the scene. No need to call it.
  75882. * @param delta defines the timespam between frames
  75883. */
  75884. _step(delta: number): void;
  75885. }
  75886. }
  75887. declare module BABYLON {
  75888. /**
  75889. * The interface for the physics imposter parameters
  75890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75891. */
  75892. export interface PhysicsImpostorParameters {
  75893. /**
  75894. * The mass of the physics imposter
  75895. */
  75896. mass: number;
  75897. /**
  75898. * The friction of the physics imposter
  75899. */
  75900. friction?: number;
  75901. /**
  75902. * The coefficient of restitution of the physics imposter
  75903. */
  75904. restitution?: number;
  75905. /**
  75906. * The native options of the physics imposter
  75907. */
  75908. nativeOptions?: any;
  75909. /**
  75910. * Specifies if the parent should be ignored
  75911. */
  75912. ignoreParent?: boolean;
  75913. /**
  75914. * Specifies if bi-directional transformations should be disabled
  75915. */
  75916. disableBidirectionalTransformation?: boolean;
  75917. /**
  75918. * The pressure inside the physics imposter, soft object only
  75919. */
  75920. pressure?: number;
  75921. /**
  75922. * The stiffness the physics imposter, soft object only
  75923. */
  75924. stiffness?: number;
  75925. /**
  75926. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75927. */
  75928. velocityIterations?: number;
  75929. /**
  75930. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75931. */
  75932. positionIterations?: number;
  75933. /**
  75934. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75935. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75936. * Add to fix multiple points
  75937. */
  75938. fixedPoints?: number;
  75939. /**
  75940. * The collision margin around a soft object
  75941. */
  75942. margin?: number;
  75943. /**
  75944. * The collision margin around a soft object
  75945. */
  75946. damping?: number;
  75947. /**
  75948. * The path for a rope based on an extrusion
  75949. */
  75950. path?: any;
  75951. /**
  75952. * The shape of an extrusion used for a rope based on an extrusion
  75953. */
  75954. shape?: any;
  75955. }
  75956. /**
  75957. * Interface for a physics-enabled object
  75958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75959. */
  75960. export interface IPhysicsEnabledObject {
  75961. /**
  75962. * The position of the physics-enabled object
  75963. */
  75964. position: Vector3;
  75965. /**
  75966. * The rotation of the physics-enabled object
  75967. */
  75968. rotationQuaternion: Nullable<Quaternion>;
  75969. /**
  75970. * The scale of the physics-enabled object
  75971. */
  75972. scaling: Vector3;
  75973. /**
  75974. * The rotation of the physics-enabled object
  75975. */
  75976. rotation?: Vector3;
  75977. /**
  75978. * The parent of the physics-enabled object
  75979. */
  75980. parent?: any;
  75981. /**
  75982. * The bounding info of the physics-enabled object
  75983. * @returns The bounding info of the physics-enabled object
  75984. */
  75985. getBoundingInfo(): BoundingInfo;
  75986. /**
  75987. * Computes the world matrix
  75988. * @param force Specifies if the world matrix should be computed by force
  75989. * @returns A world matrix
  75990. */
  75991. computeWorldMatrix(force: boolean): Matrix;
  75992. /**
  75993. * Gets the world matrix
  75994. * @returns A world matrix
  75995. */
  75996. getWorldMatrix?(): Matrix;
  75997. /**
  75998. * Gets the child meshes
  75999. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76000. * @returns An array of abstract meshes
  76001. */
  76002. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76003. /**
  76004. * Gets the vertex data
  76005. * @param kind The type of vertex data
  76006. * @returns A nullable array of numbers, or a float32 array
  76007. */
  76008. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76009. /**
  76010. * Gets the indices from the mesh
  76011. * @returns A nullable array of index arrays
  76012. */
  76013. getIndices?(): Nullable<IndicesArray>;
  76014. /**
  76015. * Gets the scene from the mesh
  76016. * @returns the indices array or null
  76017. */
  76018. getScene?(): Scene;
  76019. /**
  76020. * Gets the absolute position from the mesh
  76021. * @returns the absolute position
  76022. */
  76023. getAbsolutePosition(): Vector3;
  76024. /**
  76025. * Gets the absolute pivot point from the mesh
  76026. * @returns the absolute pivot point
  76027. */
  76028. getAbsolutePivotPoint(): Vector3;
  76029. /**
  76030. * Rotates the mesh
  76031. * @param axis The axis of rotation
  76032. * @param amount The amount of rotation
  76033. * @param space The space of the rotation
  76034. * @returns The rotation transform node
  76035. */
  76036. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76037. /**
  76038. * Translates the mesh
  76039. * @param axis The axis of translation
  76040. * @param distance The distance of translation
  76041. * @param space The space of the translation
  76042. * @returns The transform node
  76043. */
  76044. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76045. /**
  76046. * Sets the absolute position of the mesh
  76047. * @param absolutePosition The absolute position of the mesh
  76048. * @returns The transform node
  76049. */
  76050. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76051. /**
  76052. * Gets the class name of the mesh
  76053. * @returns The class name
  76054. */
  76055. getClassName(): string;
  76056. }
  76057. /**
  76058. * Represents a physics imposter
  76059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76060. */
  76061. export class PhysicsImpostor {
  76062. /**
  76063. * The physics-enabled object used as the physics imposter
  76064. */
  76065. object: IPhysicsEnabledObject;
  76066. /**
  76067. * The type of the physics imposter
  76068. */
  76069. type: number;
  76070. private _options;
  76071. private _scene?;
  76072. /**
  76073. * The default object size of the imposter
  76074. */
  76075. static DEFAULT_OBJECT_SIZE: Vector3;
  76076. /**
  76077. * The identity quaternion of the imposter
  76078. */
  76079. static IDENTITY_QUATERNION: Quaternion;
  76080. /** @hidden */
  76081. _pluginData: any;
  76082. private _physicsEngine;
  76083. private _physicsBody;
  76084. private _bodyUpdateRequired;
  76085. private _onBeforePhysicsStepCallbacks;
  76086. private _onAfterPhysicsStepCallbacks;
  76087. /** @hidden */
  76088. _onPhysicsCollideCallbacks: Array<{
  76089. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76090. otherImpostors: Array<PhysicsImpostor>;
  76091. }>;
  76092. private _deltaPosition;
  76093. private _deltaRotation;
  76094. private _deltaRotationConjugated;
  76095. /** @hidden */
  76096. _isFromLine: boolean;
  76097. private _parent;
  76098. private _isDisposed;
  76099. private static _tmpVecs;
  76100. private static _tmpQuat;
  76101. /**
  76102. * Specifies if the physics imposter is disposed
  76103. */
  76104. readonly isDisposed: boolean;
  76105. /**
  76106. * Gets the mass of the physics imposter
  76107. */
  76108. mass: number;
  76109. /**
  76110. * Gets the coefficient of friction
  76111. */
  76112. /**
  76113. * Sets the coefficient of friction
  76114. */
  76115. friction: number;
  76116. /**
  76117. * Gets the coefficient of restitution
  76118. */
  76119. /**
  76120. * Sets the coefficient of restitution
  76121. */
  76122. restitution: number;
  76123. /**
  76124. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76125. */
  76126. /**
  76127. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76128. */
  76129. pressure: number;
  76130. /**
  76131. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76132. */
  76133. /**
  76134. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76135. */
  76136. stiffness: number;
  76137. /**
  76138. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76139. */
  76140. /**
  76141. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76142. */
  76143. velocityIterations: number;
  76144. /**
  76145. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76146. */
  76147. /**
  76148. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76149. */
  76150. positionIterations: number;
  76151. /**
  76152. * The unique id of the physics imposter
  76153. * set by the physics engine when adding this impostor to the array
  76154. */
  76155. uniqueId: number;
  76156. /**
  76157. * @hidden
  76158. */
  76159. soft: boolean;
  76160. /**
  76161. * @hidden
  76162. */
  76163. segments: number;
  76164. private _joints;
  76165. /**
  76166. * Initializes the physics imposter
  76167. * @param object The physics-enabled object used as the physics imposter
  76168. * @param type The type of the physics imposter
  76169. * @param _options The options for the physics imposter
  76170. * @param _scene The Babylon scene
  76171. */
  76172. constructor(
  76173. /**
  76174. * The physics-enabled object used as the physics imposter
  76175. */
  76176. object: IPhysicsEnabledObject,
  76177. /**
  76178. * The type of the physics imposter
  76179. */
  76180. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76181. /**
  76182. * This function will completly initialize this impostor.
  76183. * It will create a new body - but only if this mesh has no parent.
  76184. * If it has, this impostor will not be used other than to define the impostor
  76185. * of the child mesh.
  76186. * @hidden
  76187. */
  76188. _init(): void;
  76189. private _getPhysicsParent;
  76190. /**
  76191. * Should a new body be generated.
  76192. * @returns boolean specifying if body initialization is required
  76193. */
  76194. isBodyInitRequired(): boolean;
  76195. /**
  76196. * Sets the updated scaling
  76197. * @param updated Specifies if the scaling is updated
  76198. */
  76199. setScalingUpdated(): void;
  76200. /**
  76201. * Force a regeneration of this or the parent's impostor's body.
  76202. * Use under cautious - This will remove all joints already implemented.
  76203. */
  76204. forceUpdate(): void;
  76205. /**
  76206. * Gets the body that holds this impostor. Either its own, or its parent.
  76207. */
  76208. /**
  76209. * Set the physics body. Used mainly by the physics engine/plugin
  76210. */
  76211. physicsBody: any;
  76212. /**
  76213. * Get the parent of the physics imposter
  76214. * @returns Physics imposter or null
  76215. */
  76216. /**
  76217. * Sets the parent of the physics imposter
  76218. */
  76219. parent: Nullable<PhysicsImpostor>;
  76220. /**
  76221. * Resets the update flags
  76222. */
  76223. resetUpdateFlags(): void;
  76224. /**
  76225. * Gets the object extend size
  76226. * @returns the object extend size
  76227. */
  76228. getObjectExtendSize(): Vector3;
  76229. /**
  76230. * Gets the object center
  76231. * @returns The object center
  76232. */
  76233. getObjectCenter(): Vector3;
  76234. /**
  76235. * Get a specific parametes from the options parameter
  76236. * @param paramName The object parameter name
  76237. * @returns The object parameter
  76238. */
  76239. getParam(paramName: string): any;
  76240. /**
  76241. * Sets a specific parameter in the options given to the physics plugin
  76242. * @param paramName The parameter name
  76243. * @param value The value of the parameter
  76244. */
  76245. setParam(paramName: string, value: number): void;
  76246. /**
  76247. * Specifically change the body's mass option. Won't recreate the physics body object
  76248. * @param mass The mass of the physics imposter
  76249. */
  76250. setMass(mass: number): void;
  76251. /**
  76252. * Gets the linear velocity
  76253. * @returns linear velocity or null
  76254. */
  76255. getLinearVelocity(): Nullable<Vector3>;
  76256. /**
  76257. * Sets the linear velocity
  76258. * @param velocity linear velocity or null
  76259. */
  76260. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76261. /**
  76262. * Gets the angular velocity
  76263. * @returns angular velocity or null
  76264. */
  76265. getAngularVelocity(): Nullable<Vector3>;
  76266. /**
  76267. * Sets the angular velocity
  76268. * @param velocity The velocity or null
  76269. */
  76270. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76271. /**
  76272. * Execute a function with the physics plugin native code
  76273. * Provide a function the will have two variables - the world object and the physics body object
  76274. * @param func The function to execute with the physics plugin native code
  76275. */
  76276. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76277. /**
  76278. * Register a function that will be executed before the physics world is stepping forward
  76279. * @param func The function to execute before the physics world is stepped forward
  76280. */
  76281. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76282. /**
  76283. * Unregister a function that will be executed before the physics world is stepping forward
  76284. * @param func The function to execute before the physics world is stepped forward
  76285. */
  76286. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76287. /**
  76288. * Register a function that will be executed after the physics step
  76289. * @param func The function to execute after physics step
  76290. */
  76291. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76292. /**
  76293. * Unregisters a function that will be executed after the physics step
  76294. * @param func The function to execute after physics step
  76295. */
  76296. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76297. /**
  76298. * register a function that will be executed when this impostor collides against a different body
  76299. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76300. * @param func Callback that is executed on collision
  76301. */
  76302. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76303. /**
  76304. * Unregisters the physics imposter on contact
  76305. * @param collideAgainst The physics object to collide against
  76306. * @param func Callback to execute on collision
  76307. */
  76308. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76309. private _tmpQuat;
  76310. private _tmpQuat2;
  76311. /**
  76312. * Get the parent rotation
  76313. * @returns The parent rotation
  76314. */
  76315. getParentsRotation(): Quaternion;
  76316. /**
  76317. * this function is executed by the physics engine.
  76318. */
  76319. beforeStep: () => void;
  76320. /**
  76321. * this function is executed by the physics engine
  76322. */
  76323. afterStep: () => void;
  76324. /**
  76325. * Legacy collision detection event support
  76326. */
  76327. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76328. /**
  76329. * event and body object due to cannon's event-based architecture.
  76330. */
  76331. onCollide: (e: {
  76332. body: any;
  76333. }) => void;
  76334. /**
  76335. * Apply a force
  76336. * @param force The force to apply
  76337. * @param contactPoint The contact point for the force
  76338. * @returns The physics imposter
  76339. */
  76340. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76341. /**
  76342. * Apply an impulse
  76343. * @param force The impulse force
  76344. * @param contactPoint The contact point for the impulse force
  76345. * @returns The physics imposter
  76346. */
  76347. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76348. /**
  76349. * A help function to create a joint
  76350. * @param otherImpostor A physics imposter used to create a joint
  76351. * @param jointType The type of joint
  76352. * @param jointData The data for the joint
  76353. * @returns The physics imposter
  76354. */
  76355. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76356. /**
  76357. * Add a joint to this impostor with a different impostor
  76358. * @param otherImpostor A physics imposter used to add a joint
  76359. * @param joint The joint to add
  76360. * @returns The physics imposter
  76361. */
  76362. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76363. /**
  76364. * Add an anchor to a cloth impostor
  76365. * @param otherImpostor rigid impostor to anchor to
  76366. * @param width ratio across width from 0 to 1
  76367. * @param height ratio up height from 0 to 1
  76368. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76369. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76370. * @returns impostor the soft imposter
  76371. */
  76372. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76373. /**
  76374. * Add a hook to a rope impostor
  76375. * @param otherImpostor rigid impostor to anchor to
  76376. * @param length ratio across rope from 0 to 1
  76377. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76378. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76379. * @returns impostor the rope imposter
  76380. */
  76381. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76382. /**
  76383. * Will keep this body still, in a sleep mode.
  76384. * @returns the physics imposter
  76385. */
  76386. sleep(): PhysicsImpostor;
  76387. /**
  76388. * Wake the body up.
  76389. * @returns The physics imposter
  76390. */
  76391. wakeUp(): PhysicsImpostor;
  76392. /**
  76393. * Clones the physics imposter
  76394. * @param newObject The physics imposter clones to this physics-enabled object
  76395. * @returns A nullable physics imposter
  76396. */
  76397. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76398. /**
  76399. * Disposes the physics imposter
  76400. */
  76401. dispose(): void;
  76402. /**
  76403. * Sets the delta position
  76404. * @param position The delta position amount
  76405. */
  76406. setDeltaPosition(position: Vector3): void;
  76407. /**
  76408. * Sets the delta rotation
  76409. * @param rotation The delta rotation amount
  76410. */
  76411. setDeltaRotation(rotation: Quaternion): void;
  76412. /**
  76413. * Gets the box size of the physics imposter and stores the result in the input parameter
  76414. * @param result Stores the box size
  76415. * @returns The physics imposter
  76416. */
  76417. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76418. /**
  76419. * Gets the radius of the physics imposter
  76420. * @returns Radius of the physics imposter
  76421. */
  76422. getRadius(): number;
  76423. /**
  76424. * Sync a bone with this impostor
  76425. * @param bone The bone to sync to the impostor.
  76426. * @param boneMesh The mesh that the bone is influencing.
  76427. * @param jointPivot The pivot of the joint / bone in local space.
  76428. * @param distToJoint Optional distance from the impostor to the joint.
  76429. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76430. */
  76431. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76432. /**
  76433. * Sync impostor to a bone
  76434. * @param bone The bone that the impostor will be synced to.
  76435. * @param boneMesh The mesh that the bone is influencing.
  76436. * @param jointPivot The pivot of the joint / bone in local space.
  76437. * @param distToJoint Optional distance from the impostor to the joint.
  76438. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76439. * @param boneAxis Optional vector3 axis the bone is aligned with
  76440. */
  76441. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76442. /**
  76443. * No-Imposter type
  76444. */
  76445. static NoImpostor: number;
  76446. /**
  76447. * Sphere-Imposter type
  76448. */
  76449. static SphereImpostor: number;
  76450. /**
  76451. * Box-Imposter type
  76452. */
  76453. static BoxImpostor: number;
  76454. /**
  76455. * Plane-Imposter type
  76456. */
  76457. static PlaneImpostor: number;
  76458. /**
  76459. * Mesh-imposter type
  76460. */
  76461. static MeshImpostor: number;
  76462. /**
  76463. * Capsule-Impostor type (Ammo.js plugin only)
  76464. */
  76465. static CapsuleImpostor: number;
  76466. /**
  76467. * Cylinder-Imposter type
  76468. */
  76469. static CylinderImpostor: number;
  76470. /**
  76471. * Particle-Imposter type
  76472. */
  76473. static ParticleImpostor: number;
  76474. /**
  76475. * Heightmap-Imposter type
  76476. */
  76477. static HeightmapImpostor: number;
  76478. /**
  76479. * ConvexHull-Impostor type (Ammo.js plugin only)
  76480. */
  76481. static ConvexHullImpostor: number;
  76482. /**
  76483. * Rope-Imposter type
  76484. */
  76485. static RopeImpostor: number;
  76486. /**
  76487. * Cloth-Imposter type
  76488. */
  76489. static ClothImpostor: number;
  76490. /**
  76491. * Softbody-Imposter type
  76492. */
  76493. static SoftbodyImpostor: number;
  76494. }
  76495. }
  76496. declare module BABYLON {
  76497. /**
  76498. * @hidden
  76499. **/
  76500. export class _CreationDataStorage {
  76501. closePath?: boolean;
  76502. closeArray?: boolean;
  76503. idx: number[];
  76504. dashSize: number;
  76505. gapSize: number;
  76506. path3D: Path3D;
  76507. pathArray: Vector3[][];
  76508. arc: number;
  76509. radius: number;
  76510. cap: number;
  76511. tessellation: number;
  76512. }
  76513. /**
  76514. * @hidden
  76515. **/
  76516. class _InstanceDataStorage {
  76517. visibleInstances: any;
  76518. batchCache: _InstancesBatch;
  76519. instancesBufferSize: number;
  76520. instancesBuffer: Nullable<Buffer>;
  76521. instancesData: Float32Array;
  76522. overridenInstanceCount: number;
  76523. isFrozen: boolean;
  76524. previousBatch: Nullable<_InstancesBatch>;
  76525. hardwareInstancedRendering: boolean;
  76526. sideOrientation: number;
  76527. }
  76528. /**
  76529. * @hidden
  76530. **/
  76531. export class _InstancesBatch {
  76532. mustReturn: boolean;
  76533. visibleInstances: Nullable<InstancedMesh[]>[];
  76534. renderSelf: boolean[];
  76535. hardwareInstancedRendering: boolean[];
  76536. }
  76537. /**
  76538. * Class used to represent renderable models
  76539. */
  76540. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76541. /**
  76542. * Mesh side orientation : usually the external or front surface
  76543. */
  76544. static readonly FRONTSIDE: number;
  76545. /**
  76546. * Mesh side orientation : usually the internal or back surface
  76547. */
  76548. static readonly BACKSIDE: number;
  76549. /**
  76550. * Mesh side orientation : both internal and external or front and back surfaces
  76551. */
  76552. static readonly DOUBLESIDE: number;
  76553. /**
  76554. * Mesh side orientation : by default, `FRONTSIDE`
  76555. */
  76556. static readonly DEFAULTSIDE: number;
  76557. /**
  76558. * Mesh cap setting : no cap
  76559. */
  76560. static readonly NO_CAP: number;
  76561. /**
  76562. * Mesh cap setting : one cap at the beginning of the mesh
  76563. */
  76564. static readonly CAP_START: number;
  76565. /**
  76566. * Mesh cap setting : one cap at the end of the mesh
  76567. */
  76568. static readonly CAP_END: number;
  76569. /**
  76570. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76571. */
  76572. static readonly CAP_ALL: number;
  76573. /**
  76574. * Mesh pattern setting : no flip or rotate
  76575. */
  76576. static readonly NO_FLIP: number;
  76577. /**
  76578. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76579. */
  76580. static readonly FLIP_TILE: number;
  76581. /**
  76582. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76583. */
  76584. static readonly ROTATE_TILE: number;
  76585. /**
  76586. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76587. */
  76588. static readonly FLIP_ROW: number;
  76589. /**
  76590. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76591. */
  76592. static readonly ROTATE_ROW: number;
  76593. /**
  76594. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76595. */
  76596. static readonly FLIP_N_ROTATE_TILE: number;
  76597. /**
  76598. * Mesh pattern setting : rotate pattern and rotate
  76599. */
  76600. static readonly FLIP_N_ROTATE_ROW: number;
  76601. /**
  76602. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76603. */
  76604. static readonly CENTER: number;
  76605. /**
  76606. * Mesh tile positioning : part tiles on left
  76607. */
  76608. static readonly LEFT: number;
  76609. /**
  76610. * Mesh tile positioning : part tiles on right
  76611. */
  76612. static readonly RIGHT: number;
  76613. /**
  76614. * Mesh tile positioning : part tiles on top
  76615. */
  76616. static readonly TOP: number;
  76617. /**
  76618. * Mesh tile positioning : part tiles on bottom
  76619. */
  76620. static readonly BOTTOM: number;
  76621. /**
  76622. * Gets the default side orientation.
  76623. * @param orientation the orientation to value to attempt to get
  76624. * @returns the default orientation
  76625. * @hidden
  76626. */
  76627. static _GetDefaultSideOrientation(orientation?: number): number;
  76628. private _internalMeshDataInfo;
  76629. /**
  76630. * An event triggered before rendering the mesh
  76631. */
  76632. readonly onBeforeRenderObservable: Observable<Mesh>;
  76633. /**
  76634. * An event triggered before binding the mesh
  76635. */
  76636. readonly onBeforeBindObservable: Observable<Mesh>;
  76637. /**
  76638. * An event triggered after rendering the mesh
  76639. */
  76640. readonly onAfterRenderObservable: Observable<Mesh>;
  76641. /**
  76642. * An event triggered before drawing the mesh
  76643. */
  76644. readonly onBeforeDrawObservable: Observable<Mesh>;
  76645. private _onBeforeDrawObserver;
  76646. /**
  76647. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76648. */
  76649. onBeforeDraw: () => void;
  76650. /**
  76651. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76652. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76653. */
  76654. delayLoadState: number;
  76655. /**
  76656. * Gets the list of instances created from this mesh
  76657. * it is not supposed to be modified manually.
  76658. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76659. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76660. */
  76661. instances: InstancedMesh[];
  76662. /**
  76663. * Gets the file containing delay loading data for this mesh
  76664. */
  76665. delayLoadingFile: string;
  76666. /** @hidden */
  76667. _binaryInfo: any;
  76668. /**
  76669. * User defined function used to change how LOD level selection is done
  76670. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76671. */
  76672. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76673. /**
  76674. * Gets or sets the morph target manager
  76675. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76676. */
  76677. morphTargetManager: Nullable<MorphTargetManager>;
  76678. /** @hidden */
  76679. _creationDataStorage: Nullable<_CreationDataStorage>;
  76680. /** @hidden */
  76681. _geometry: Nullable<Geometry>;
  76682. /** @hidden */
  76683. _delayInfo: Array<string>;
  76684. /** @hidden */
  76685. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76686. /** @hidden */
  76687. _instanceDataStorage: _InstanceDataStorage;
  76688. private _effectiveMaterial;
  76689. /** @hidden */
  76690. _shouldGenerateFlatShading: boolean;
  76691. /** @hidden */
  76692. _originalBuilderSideOrientation: number;
  76693. /**
  76694. * Use this property to change the original side orientation defined at construction time
  76695. */
  76696. overrideMaterialSideOrientation: Nullable<number>;
  76697. /**
  76698. * Gets the source mesh (the one used to clone this one from)
  76699. */
  76700. readonly source: Nullable<Mesh>;
  76701. /**
  76702. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76703. */
  76704. isUnIndexed: boolean;
  76705. /**
  76706. * @constructor
  76707. * @param name The value used by scene.getMeshByName() to do a lookup.
  76708. * @param scene The scene to add this mesh to.
  76709. * @param parent The parent of this mesh, if it has one
  76710. * @param source An optional Mesh from which geometry is shared, cloned.
  76711. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76712. * When false, achieved by calling a clone(), also passing False.
  76713. * This will make creation of children, recursive.
  76714. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76715. */
  76716. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76717. /**
  76718. * Gets the class name
  76719. * @returns the string "Mesh".
  76720. */
  76721. getClassName(): string;
  76722. /** @hidden */
  76723. readonly _isMesh: boolean;
  76724. /**
  76725. * Returns a description of this mesh
  76726. * @param fullDetails define if full details about this mesh must be used
  76727. * @returns a descriptive string representing this mesh
  76728. */
  76729. toString(fullDetails?: boolean): string;
  76730. /** @hidden */
  76731. _unBindEffect(): void;
  76732. /**
  76733. * Gets a boolean indicating if this mesh has LOD
  76734. */
  76735. readonly hasLODLevels: boolean;
  76736. /**
  76737. * Gets the list of MeshLODLevel associated with the current mesh
  76738. * @returns an array of MeshLODLevel
  76739. */
  76740. getLODLevels(): MeshLODLevel[];
  76741. private _sortLODLevels;
  76742. /**
  76743. * Add a mesh as LOD level triggered at the given distance.
  76744. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76745. * @param distance The distance from the center of the object to show this level
  76746. * @param mesh The mesh to be added as LOD level (can be null)
  76747. * @return This mesh (for chaining)
  76748. */
  76749. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76750. /**
  76751. * Returns the LOD level mesh at the passed distance or null if not found.
  76752. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76753. * @param distance The distance from the center of the object to show this level
  76754. * @returns a Mesh or `null`
  76755. */
  76756. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76757. /**
  76758. * Remove a mesh from the LOD array
  76759. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76760. * @param mesh defines the mesh to be removed
  76761. * @return This mesh (for chaining)
  76762. */
  76763. removeLODLevel(mesh: Mesh): Mesh;
  76764. /**
  76765. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76766. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76767. * @param camera defines the camera to use to compute distance
  76768. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76769. * @return This mesh (for chaining)
  76770. */
  76771. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76772. /**
  76773. * Gets the mesh internal Geometry object
  76774. */
  76775. readonly geometry: Nullable<Geometry>;
  76776. /**
  76777. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76778. * @returns the total number of vertices
  76779. */
  76780. getTotalVertices(): number;
  76781. /**
  76782. * Returns the content of an associated vertex buffer
  76783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76784. * - VertexBuffer.PositionKind
  76785. * - VertexBuffer.UVKind
  76786. * - VertexBuffer.UV2Kind
  76787. * - VertexBuffer.UV3Kind
  76788. * - VertexBuffer.UV4Kind
  76789. * - VertexBuffer.UV5Kind
  76790. * - VertexBuffer.UV6Kind
  76791. * - VertexBuffer.ColorKind
  76792. * - VertexBuffer.MatricesIndicesKind
  76793. * - VertexBuffer.MatricesIndicesExtraKind
  76794. * - VertexBuffer.MatricesWeightsKind
  76795. * - VertexBuffer.MatricesWeightsExtraKind
  76796. * @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
  76797. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76798. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76799. */
  76800. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76801. /**
  76802. * Returns the mesh VertexBuffer object from the requested `kind`
  76803. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76804. * - VertexBuffer.PositionKind
  76805. * - VertexBuffer.NormalKind
  76806. * - VertexBuffer.UVKind
  76807. * - VertexBuffer.UV2Kind
  76808. * - VertexBuffer.UV3Kind
  76809. * - VertexBuffer.UV4Kind
  76810. * - VertexBuffer.UV5Kind
  76811. * - VertexBuffer.UV6Kind
  76812. * - VertexBuffer.ColorKind
  76813. * - VertexBuffer.MatricesIndicesKind
  76814. * - VertexBuffer.MatricesIndicesExtraKind
  76815. * - VertexBuffer.MatricesWeightsKind
  76816. * - VertexBuffer.MatricesWeightsExtraKind
  76817. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76818. */
  76819. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76820. /**
  76821. * Tests if a specific vertex buffer is associated with this mesh
  76822. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76823. * - VertexBuffer.PositionKind
  76824. * - VertexBuffer.NormalKind
  76825. * - VertexBuffer.UVKind
  76826. * - VertexBuffer.UV2Kind
  76827. * - VertexBuffer.UV3Kind
  76828. * - VertexBuffer.UV4Kind
  76829. * - VertexBuffer.UV5Kind
  76830. * - VertexBuffer.UV6Kind
  76831. * - VertexBuffer.ColorKind
  76832. * - VertexBuffer.MatricesIndicesKind
  76833. * - VertexBuffer.MatricesIndicesExtraKind
  76834. * - VertexBuffer.MatricesWeightsKind
  76835. * - VertexBuffer.MatricesWeightsExtraKind
  76836. * @returns a boolean
  76837. */
  76838. isVerticesDataPresent(kind: string): boolean;
  76839. /**
  76840. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76841. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76842. * - VertexBuffer.PositionKind
  76843. * - VertexBuffer.UVKind
  76844. * - VertexBuffer.UV2Kind
  76845. * - VertexBuffer.UV3Kind
  76846. * - VertexBuffer.UV4Kind
  76847. * - VertexBuffer.UV5Kind
  76848. * - VertexBuffer.UV6Kind
  76849. * - VertexBuffer.ColorKind
  76850. * - VertexBuffer.MatricesIndicesKind
  76851. * - VertexBuffer.MatricesIndicesExtraKind
  76852. * - VertexBuffer.MatricesWeightsKind
  76853. * - VertexBuffer.MatricesWeightsExtraKind
  76854. * @returns a boolean
  76855. */
  76856. isVertexBufferUpdatable(kind: string): boolean;
  76857. /**
  76858. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76859. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76860. * - VertexBuffer.PositionKind
  76861. * - VertexBuffer.NormalKind
  76862. * - VertexBuffer.UVKind
  76863. * - VertexBuffer.UV2Kind
  76864. * - VertexBuffer.UV3Kind
  76865. * - VertexBuffer.UV4Kind
  76866. * - VertexBuffer.UV5Kind
  76867. * - VertexBuffer.UV6Kind
  76868. * - VertexBuffer.ColorKind
  76869. * - VertexBuffer.MatricesIndicesKind
  76870. * - VertexBuffer.MatricesIndicesExtraKind
  76871. * - VertexBuffer.MatricesWeightsKind
  76872. * - VertexBuffer.MatricesWeightsExtraKind
  76873. * @returns an array of strings
  76874. */
  76875. getVerticesDataKinds(): string[];
  76876. /**
  76877. * Returns a positive integer : the total number of indices in this mesh geometry.
  76878. * @returns the numner of indices or zero if the mesh has no geometry.
  76879. */
  76880. getTotalIndices(): number;
  76881. /**
  76882. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76883. * @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.
  76884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76885. * @returns the indices array or an empty array if the mesh has no geometry
  76886. */
  76887. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76888. readonly isBlocked: boolean;
  76889. /**
  76890. * Determine if the current mesh is ready to be rendered
  76891. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76892. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76893. * @returns true if all associated assets are ready (material, textures, shaders)
  76894. */
  76895. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76896. /**
  76897. * 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.
  76898. */
  76899. readonly areNormalsFrozen: boolean;
  76900. /**
  76901. * 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.
  76902. * @returns the current mesh
  76903. */
  76904. freezeNormals(): Mesh;
  76905. /**
  76906. * 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
  76907. * @returns the current mesh
  76908. */
  76909. unfreezeNormals(): Mesh;
  76910. /**
  76911. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76912. */
  76913. overridenInstanceCount: number;
  76914. /** @hidden */
  76915. _preActivate(): Mesh;
  76916. /** @hidden */
  76917. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76918. /** @hidden */
  76919. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76920. /**
  76921. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76922. * This means the mesh underlying bounding box and sphere are recomputed.
  76923. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76924. * @returns the current mesh
  76925. */
  76926. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76927. /** @hidden */
  76928. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76929. /**
  76930. * This function will subdivide the mesh into multiple submeshes
  76931. * @param count defines the expected number of submeshes
  76932. */
  76933. subdivide(count: number): void;
  76934. /**
  76935. * Copy a FloatArray into a specific associated vertex buffer
  76936. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76937. * - VertexBuffer.PositionKind
  76938. * - VertexBuffer.UVKind
  76939. * - VertexBuffer.UV2Kind
  76940. * - VertexBuffer.UV3Kind
  76941. * - VertexBuffer.UV4Kind
  76942. * - VertexBuffer.UV5Kind
  76943. * - VertexBuffer.UV6Kind
  76944. * - VertexBuffer.ColorKind
  76945. * - VertexBuffer.MatricesIndicesKind
  76946. * - VertexBuffer.MatricesIndicesExtraKind
  76947. * - VertexBuffer.MatricesWeightsKind
  76948. * - VertexBuffer.MatricesWeightsExtraKind
  76949. * @param data defines the data source
  76950. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76951. * @param stride defines the data stride size (can be null)
  76952. * @returns the current mesh
  76953. */
  76954. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76955. /**
  76956. * Flags an associated vertex buffer as updatable
  76957. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76958. * - VertexBuffer.PositionKind
  76959. * - VertexBuffer.UVKind
  76960. * - VertexBuffer.UV2Kind
  76961. * - VertexBuffer.UV3Kind
  76962. * - VertexBuffer.UV4Kind
  76963. * - VertexBuffer.UV5Kind
  76964. * - VertexBuffer.UV6Kind
  76965. * - VertexBuffer.ColorKind
  76966. * - VertexBuffer.MatricesIndicesKind
  76967. * - VertexBuffer.MatricesIndicesExtraKind
  76968. * - VertexBuffer.MatricesWeightsKind
  76969. * - VertexBuffer.MatricesWeightsExtraKind
  76970. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76971. */
  76972. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76973. /**
  76974. * Sets the mesh global Vertex Buffer
  76975. * @param buffer defines the buffer to use
  76976. * @returns the current mesh
  76977. */
  76978. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76979. /**
  76980. * Update a specific associated vertex buffer
  76981. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76982. * - VertexBuffer.PositionKind
  76983. * - VertexBuffer.UVKind
  76984. * - VertexBuffer.UV2Kind
  76985. * - VertexBuffer.UV3Kind
  76986. * - VertexBuffer.UV4Kind
  76987. * - VertexBuffer.UV5Kind
  76988. * - VertexBuffer.UV6Kind
  76989. * - VertexBuffer.ColorKind
  76990. * - VertexBuffer.MatricesIndicesKind
  76991. * - VertexBuffer.MatricesIndicesExtraKind
  76992. * - VertexBuffer.MatricesWeightsKind
  76993. * - VertexBuffer.MatricesWeightsExtraKind
  76994. * @param data defines the data source
  76995. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76996. * @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)
  76997. * @returns the current mesh
  76998. */
  76999. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77000. /**
  77001. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77002. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77003. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77004. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77005. * @returns the current mesh
  77006. */
  77007. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77008. /**
  77009. * Creates a un-shared specific occurence of the geometry for the mesh.
  77010. * @returns the current mesh
  77011. */
  77012. makeGeometryUnique(): Mesh;
  77013. /**
  77014. * Set the index buffer of this mesh
  77015. * @param indices defines the source data
  77016. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77017. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77018. * @returns the current mesh
  77019. */
  77020. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77021. /**
  77022. * Update the current index buffer
  77023. * @param indices defines the source data
  77024. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77025. * @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)
  77026. * @returns the current mesh
  77027. */
  77028. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77029. /**
  77030. * Invert the geometry to move from a right handed system to a left handed one.
  77031. * @returns the current mesh
  77032. */
  77033. toLeftHanded(): Mesh;
  77034. /** @hidden */
  77035. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77036. /** @hidden */
  77037. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  77038. /**
  77039. * Registers for this mesh a javascript function called just before the rendering process
  77040. * @param func defines the function to call before rendering this mesh
  77041. * @returns the current mesh
  77042. */
  77043. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77044. /**
  77045. * Disposes a previously registered javascript function called before the rendering
  77046. * @param func defines the function to remove
  77047. * @returns the current mesh
  77048. */
  77049. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77050. /**
  77051. * Registers for this mesh a javascript function called just after the rendering is complete
  77052. * @param func defines the function to call after rendering this mesh
  77053. * @returns the current mesh
  77054. */
  77055. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77056. /**
  77057. * Disposes a previously registered javascript function called after the rendering.
  77058. * @param func defines the function to remove
  77059. * @returns the current mesh
  77060. */
  77061. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77062. /** @hidden */
  77063. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77064. /** @hidden */
  77065. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77066. /** @hidden */
  77067. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77068. /** @hidden */
  77069. _rebuild(): void;
  77070. /** @hidden */
  77071. _freeze(): void;
  77072. /** @hidden */
  77073. _unFreeze(): void;
  77074. /**
  77075. * 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
  77076. * @param subMesh defines the subMesh to render
  77077. * @param enableAlphaMode defines if alpha mode can be changed
  77078. * @returns the current mesh
  77079. */
  77080. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77081. private _onBeforeDraw;
  77082. /**
  77083. * Renormalize the mesh and patch it up if there are no weights
  77084. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77085. * However in the case of zero weights then we set just a single influence to 1.
  77086. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77087. */
  77088. cleanMatrixWeights(): void;
  77089. private normalizeSkinFourWeights;
  77090. private normalizeSkinWeightsAndExtra;
  77091. /**
  77092. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77093. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77094. * the user know there was an issue with importing the mesh
  77095. * @returns a validation object with skinned, valid and report string
  77096. */
  77097. validateSkinning(): {
  77098. skinned: boolean;
  77099. valid: boolean;
  77100. report: string;
  77101. };
  77102. /** @hidden */
  77103. _checkDelayState(): Mesh;
  77104. private _queueLoad;
  77105. /**
  77106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77107. * A mesh is in the frustum if its bounding box intersects the frustum
  77108. * @param frustumPlanes defines the frustum to test
  77109. * @returns true if the mesh is in the frustum planes
  77110. */
  77111. isInFrustum(frustumPlanes: Plane[]): boolean;
  77112. /**
  77113. * Sets the mesh material by the material or multiMaterial `id` property
  77114. * @param id is a string identifying the material or the multiMaterial
  77115. * @returns the current mesh
  77116. */
  77117. setMaterialByID(id: string): Mesh;
  77118. /**
  77119. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77120. * @returns an array of IAnimatable
  77121. */
  77122. getAnimatables(): IAnimatable[];
  77123. /**
  77124. * Modifies the mesh geometry according to the passed transformation matrix.
  77125. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77126. * The mesh normals are modified using the same transformation.
  77127. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77128. * @param transform defines the transform matrix to use
  77129. * @see http://doc.babylonjs.com/resources/baking_transformations
  77130. * @returns the current mesh
  77131. */
  77132. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77133. /**
  77134. * Modifies the mesh geometry according to its own current World Matrix.
  77135. * The mesh World Matrix is then reset.
  77136. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77137. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77138. * @see http://doc.babylonjs.com/resources/baking_transformations
  77139. * @returns the current mesh
  77140. */
  77141. bakeCurrentTransformIntoVertices(): Mesh;
  77142. /** @hidden */
  77143. readonly _positions: Nullable<Vector3[]>;
  77144. /** @hidden */
  77145. _resetPointsArrayCache(): Mesh;
  77146. /** @hidden */
  77147. _generatePointsArray(): boolean;
  77148. /**
  77149. * Returns a new Mesh object generated from the current mesh properties.
  77150. * This method must not get confused with createInstance()
  77151. * @param name is a string, the name given to the new mesh
  77152. * @param newParent can be any Node object (default `null`)
  77153. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77154. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77155. * @returns a new mesh
  77156. */
  77157. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77158. /**
  77159. * Releases resources associated with this mesh.
  77160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77162. */
  77163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77164. /**
  77165. * Modifies the mesh geometry according to a displacement map.
  77166. * 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.
  77167. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77168. * @param url is a string, the URL from the image file is to be downloaded.
  77169. * @param minHeight is the lower limit of the displacement.
  77170. * @param maxHeight is the upper limit of the displacement.
  77171. * @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.
  77172. * @param uvOffset is an optional vector2 used to offset UV.
  77173. * @param uvScale is an optional vector2 used to scale UV.
  77174. * @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.
  77175. * @returns the Mesh.
  77176. */
  77177. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77178. /**
  77179. * Modifies the mesh geometry according to a displacementMap buffer.
  77180. * 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.
  77181. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77182. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77183. * @param heightMapWidth is the width of the buffer image.
  77184. * @param heightMapHeight is the height of the buffer image.
  77185. * @param minHeight is the lower limit of the displacement.
  77186. * @param maxHeight is the upper limit of the displacement.
  77187. * @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.
  77188. * @param uvOffset is an optional vector2 used to offset UV.
  77189. * @param uvScale is an optional vector2 used to scale UV.
  77190. * @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.
  77191. * @returns the Mesh.
  77192. */
  77193. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77194. /**
  77195. * Modify the mesh to get a flat shading rendering.
  77196. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77197. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77198. * @returns current mesh
  77199. */
  77200. convertToFlatShadedMesh(): Mesh;
  77201. /**
  77202. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77203. * In other words, more vertices, no more indices and a single bigger VBO.
  77204. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77205. * @returns current mesh
  77206. */
  77207. convertToUnIndexedMesh(): Mesh;
  77208. /**
  77209. * Inverses facet orientations.
  77210. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77211. * @param flipNormals will also inverts the normals
  77212. * @returns current mesh
  77213. */
  77214. flipFaces(flipNormals?: boolean): Mesh;
  77215. /**
  77216. * Increase the number of facets and hence vertices in a mesh
  77217. * Vertex normals are interpolated from existing vertex normals
  77218. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77219. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77220. */
  77221. increaseVertices(numberPerEdge: number): void;
  77222. /**
  77223. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77224. * This will undo any application of covertToFlatShadedMesh
  77225. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77226. */
  77227. forceSharedVertices(): void;
  77228. /** @hidden */
  77229. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77230. /** @hidden */
  77231. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77232. /**
  77233. * Creates a new InstancedMesh object from the mesh model.
  77234. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77235. * @param name defines the name of the new instance
  77236. * @returns a new InstancedMesh
  77237. */
  77238. createInstance(name: string): InstancedMesh;
  77239. /**
  77240. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77241. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77242. * @returns the current mesh
  77243. */
  77244. synchronizeInstances(): Mesh;
  77245. /**
  77246. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77247. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77248. * This should be used together with the simplification to avoid disappearing triangles.
  77249. * @param successCallback an optional success callback to be called after the optimization finished.
  77250. * @returns the current mesh
  77251. */
  77252. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77253. /**
  77254. * Serialize current mesh
  77255. * @param serializationObject defines the object which will receive the serialization data
  77256. */
  77257. serialize(serializationObject: any): void;
  77258. /** @hidden */
  77259. _syncGeometryWithMorphTargetManager(): void;
  77260. /** @hidden */
  77261. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77262. /**
  77263. * Returns a new Mesh object parsed from the source provided.
  77264. * @param parsedMesh is the source
  77265. * @param scene defines the hosting scene
  77266. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77267. * @returns a new Mesh
  77268. */
  77269. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77270. /**
  77271. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77272. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77273. * @param name defines the name of the mesh to create
  77274. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77275. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77276. * @param closePath creates a seam between the first and the last points of each path of the path array
  77277. * @param offset is taken in account only if the `pathArray` is containing a single path
  77278. * @param scene defines the hosting scene
  77279. * @param updatable defines if the mesh must be flagged as updatable
  77280. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77281. * @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)
  77282. * @returns a new Mesh
  77283. */
  77284. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77285. /**
  77286. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77287. * @param name defines the name of the mesh to create
  77288. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77289. * @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
  77290. * @param scene defines the hosting scene
  77291. * @param updatable defines if the mesh must be flagged as updatable
  77292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77293. * @returns a new Mesh
  77294. */
  77295. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77296. /**
  77297. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77298. * @param name defines the name of the mesh to create
  77299. * @param size sets the size (float) of each box side (default 1)
  77300. * @param scene defines the hosting scene
  77301. * @param updatable defines if the mesh must be flagged as updatable
  77302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77303. * @returns a new Mesh
  77304. */
  77305. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77306. /**
  77307. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77308. * @param name defines the name of the mesh to create
  77309. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77310. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77311. * @param scene defines the hosting scene
  77312. * @param updatable defines if the mesh must be flagged as updatable
  77313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77314. * @returns a new Mesh
  77315. */
  77316. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77317. /**
  77318. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77319. * @param name defines the name of the mesh to create
  77320. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77321. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77322. * @param scene defines the hosting scene
  77323. * @returns a new Mesh
  77324. */
  77325. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77326. /**
  77327. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77328. * @param name defines the name of the mesh to create
  77329. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77330. * @param diameterTop set the top cap diameter (floats, default 1)
  77331. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77332. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77333. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77334. * @param scene defines the hosting scene
  77335. * @param updatable defines if the mesh must be flagged as updatable
  77336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77337. * @returns a new Mesh
  77338. */
  77339. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77340. /**
  77341. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77342. * @param name defines the name of the mesh to create
  77343. * @param diameter sets the diameter size (float) of the torus (default 1)
  77344. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77345. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77346. * @param scene defines the hosting scene
  77347. * @param updatable defines if the mesh must be flagged as updatable
  77348. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77349. * @returns a new Mesh
  77350. */
  77351. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77352. /**
  77353. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77354. * @param name defines the name of the mesh to create
  77355. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77356. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77357. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77358. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77359. * @param p the number of windings on X axis (positive integers, default 2)
  77360. * @param q the number of windings on Y axis (positive integers, default 3)
  77361. * @param scene defines the hosting scene
  77362. * @param updatable defines if the mesh must be flagged as updatable
  77363. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77364. * @returns a new Mesh
  77365. */
  77366. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77367. /**
  77368. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77369. * @param name defines the name of the mesh to create
  77370. * @param points is an array successive Vector3
  77371. * @param scene defines the hosting scene
  77372. * @param updatable defines if the mesh must be flagged as updatable
  77373. * @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).
  77374. * @returns a new Mesh
  77375. */
  77376. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77377. /**
  77378. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77379. * @param name defines the name of the mesh to create
  77380. * @param points is an array successive Vector3
  77381. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77382. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77383. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77384. * @param scene defines the hosting scene
  77385. * @param updatable defines if the mesh must be flagged as updatable
  77386. * @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)
  77387. * @returns a new Mesh
  77388. */
  77389. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77390. /**
  77391. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77393. * 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.
  77394. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77395. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77396. * Remember you can only change the shape positions, not their number when updating a polygon.
  77397. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77398. * @param name defines the name of the mesh to create
  77399. * @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
  77400. * @param scene defines the hosting scene
  77401. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77402. * @param updatable defines if the mesh must be flagged as updatable
  77403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77404. * @param earcutInjection can be used to inject your own earcut reference
  77405. * @returns a new Mesh
  77406. */
  77407. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77408. /**
  77409. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77410. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77411. * @param name defines the name of the mesh to create
  77412. * @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
  77413. * @param depth defines the height of extrusion
  77414. * @param scene defines the hosting scene
  77415. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77416. * @param updatable defines if the mesh must be flagged as updatable
  77417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77418. * @param earcutInjection can be used to inject your own earcut reference
  77419. * @returns a new Mesh
  77420. */
  77421. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77422. /**
  77423. * Creates an extruded shape mesh.
  77424. * 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
  77425. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77427. * @param name defines the name of the mesh to create
  77428. * @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
  77429. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77430. * @param scale is the value to scale the shape
  77431. * @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
  77432. * @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
  77433. * @param scene defines the hosting scene
  77434. * @param updatable defines if the mesh must be flagged as updatable
  77435. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77436. * @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)
  77437. * @returns a new Mesh
  77438. */
  77439. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77440. /**
  77441. * Creates an custom extruded shape mesh.
  77442. * The custom extrusion is a parametric shape.
  77443. * It has no predefined shape. Its final shape will depend on the input parameters.
  77444. * Please consider using the same method from the MeshBuilder class instead
  77445. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77446. * @param name defines the name of the mesh to create
  77447. * @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
  77448. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77449. * @param scaleFunction is a custom Javascript function called on each path point
  77450. * @param rotationFunction is a custom Javascript function called on each path point
  77451. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77452. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77453. * @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
  77454. * @param scene defines the hosting scene
  77455. * @param updatable defines if the mesh must be flagged as updatable
  77456. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77457. * @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)
  77458. * @returns a new Mesh
  77459. */
  77460. 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;
  77461. /**
  77462. * Creates lathe mesh.
  77463. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77464. * Please consider using the same method from the MeshBuilder class instead
  77465. * @param name defines the name of the mesh to create
  77466. * @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
  77467. * @param radius is the radius value of the lathe
  77468. * @param tessellation is the side number of the lathe.
  77469. * @param scene defines the hosting scene
  77470. * @param updatable defines if the mesh must be flagged as updatable
  77471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77472. * @returns a new Mesh
  77473. */
  77474. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77475. /**
  77476. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77477. * @param name defines the name of the mesh to create
  77478. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77479. * @param scene defines the hosting scene
  77480. * @param updatable defines if the mesh must be flagged as updatable
  77481. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77482. * @returns a new Mesh
  77483. */
  77484. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77485. /**
  77486. * Creates a ground mesh.
  77487. * Please consider using the same method from the MeshBuilder class instead
  77488. * @param name defines the name of the mesh to create
  77489. * @param width set the width of the ground
  77490. * @param height set the height of the ground
  77491. * @param subdivisions sets the number of subdivisions per side
  77492. * @param scene defines the hosting scene
  77493. * @param updatable defines if the mesh must be flagged as updatable
  77494. * @returns a new Mesh
  77495. */
  77496. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77497. /**
  77498. * Creates a tiled ground mesh.
  77499. * Please consider using the same method from the MeshBuilder class instead
  77500. * @param name defines the name of the mesh to create
  77501. * @param xmin set the ground minimum X coordinate
  77502. * @param zmin set the ground minimum Y coordinate
  77503. * @param xmax set the ground maximum X coordinate
  77504. * @param zmax set the ground maximum Z coordinate
  77505. * @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
  77506. * @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
  77507. * @param scene defines the hosting scene
  77508. * @param updatable defines if the mesh must be flagged as updatable
  77509. * @returns a new Mesh
  77510. */
  77511. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77512. w: number;
  77513. h: number;
  77514. }, precision: {
  77515. w: number;
  77516. h: number;
  77517. }, scene: Scene, updatable?: boolean): Mesh;
  77518. /**
  77519. * Creates a ground mesh from a height map.
  77520. * Please consider using the same method from the MeshBuilder class instead
  77521. * @see http://doc.babylonjs.com/babylon101/height_map
  77522. * @param name defines the name of the mesh to create
  77523. * @param url sets the URL of the height map image resource
  77524. * @param width set the ground width size
  77525. * @param height set the ground height size
  77526. * @param subdivisions sets the number of subdivision per side
  77527. * @param minHeight is the minimum altitude on the ground
  77528. * @param maxHeight is the maximum altitude on the ground
  77529. * @param scene defines the hosting scene
  77530. * @param updatable defines if the mesh must be flagged as updatable
  77531. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77532. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77533. * @returns a new Mesh
  77534. */
  77535. 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;
  77536. /**
  77537. * Creates a tube mesh.
  77538. * The tube is a parametric shape.
  77539. * It has no predefined shape. Its final shape will depend on the input parameters.
  77540. * Please consider using the same method from the MeshBuilder class instead
  77541. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77542. * @param name defines the name of the mesh to create
  77543. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77544. * @param radius sets the tube radius size
  77545. * @param tessellation is the number of sides on the tubular surface
  77546. * @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
  77547. * @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
  77548. * @param scene defines the hosting scene
  77549. * @param updatable defines if the mesh must be flagged as updatable
  77550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77551. * @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)
  77552. * @returns a new Mesh
  77553. */
  77554. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77555. (i: number, distance: number): number;
  77556. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77557. /**
  77558. * Creates a polyhedron mesh.
  77559. * Please consider using the same method from the MeshBuilder class instead.
  77560. * * 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
  77561. * * The parameter `size` (positive float, default 1) sets the polygon size
  77562. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77563. * * 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`
  77564. * * 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
  77565. * * 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)`)
  77566. * * 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
  77567. * * 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
  77568. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77569. * * If you create a double-sided mesh, you can choose what parts of 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
  77570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77571. * @param name defines the name of the mesh to create
  77572. * @param options defines the options used to create the mesh
  77573. * @param scene defines the hosting scene
  77574. * @returns a new Mesh
  77575. */
  77576. static CreatePolyhedron(name: string, options: {
  77577. type?: number;
  77578. size?: number;
  77579. sizeX?: number;
  77580. sizeY?: number;
  77581. sizeZ?: number;
  77582. custom?: any;
  77583. faceUV?: Vector4[];
  77584. faceColors?: Color4[];
  77585. updatable?: boolean;
  77586. sideOrientation?: number;
  77587. }, scene: Scene): Mesh;
  77588. /**
  77589. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77590. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77591. * * 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`)
  77592. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77593. * * 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
  77594. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77595. * * If you create a double-sided mesh, you can choose what parts of 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
  77596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77597. * @param name defines the name of the mesh
  77598. * @param options defines the options used to create the mesh
  77599. * @param scene defines the hosting scene
  77600. * @returns a new Mesh
  77601. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77602. */
  77603. static CreateIcoSphere(name: string, options: {
  77604. radius?: number;
  77605. flat?: boolean;
  77606. subdivisions?: number;
  77607. sideOrientation?: number;
  77608. updatable?: boolean;
  77609. }, scene: Scene): Mesh;
  77610. /**
  77611. * Creates a decal mesh.
  77612. * Please consider using the same method from the MeshBuilder class instead.
  77613. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77614. * @param name defines the name of the mesh
  77615. * @param sourceMesh defines the mesh receiving the decal
  77616. * @param position sets the position of the decal in world coordinates
  77617. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77618. * @param size sets the decal scaling
  77619. * @param angle sets the angle to rotate the decal
  77620. * @returns a new Mesh
  77621. */
  77622. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77623. /**
  77624. * Prepare internal position array for software CPU skinning
  77625. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77626. */
  77627. setPositionsForCPUSkinning(): Float32Array;
  77628. /**
  77629. * Prepare internal normal array for software CPU skinning
  77630. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77631. */
  77632. setNormalsForCPUSkinning(): Float32Array;
  77633. /**
  77634. * Updates the vertex buffer by applying transformation from the bones
  77635. * @param skeleton defines the skeleton to apply to current mesh
  77636. * @returns the current mesh
  77637. */
  77638. applySkeleton(skeleton: Skeleton): Mesh;
  77639. /**
  77640. * 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
  77641. * @param meshes defines the list of meshes to scan
  77642. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77643. */
  77644. static MinMax(meshes: AbstractMesh[]): {
  77645. min: Vector3;
  77646. max: Vector3;
  77647. };
  77648. /**
  77649. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77650. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77651. * @returns a vector3
  77652. */
  77653. static Center(meshesOrMinMaxVector: {
  77654. min: Vector3;
  77655. max: Vector3;
  77656. } | AbstractMesh[]): Vector3;
  77657. /**
  77658. * Merge the array of meshes into a single mesh for performance reasons.
  77659. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77660. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77661. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77662. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77663. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77664. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77665. * @returns a new mesh
  77666. */
  77667. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77668. /** @hidden */
  77669. addInstance(instance: InstancedMesh): void;
  77670. /** @hidden */
  77671. removeInstance(instance: InstancedMesh): void;
  77672. }
  77673. }
  77674. declare module BABYLON {
  77675. /**
  77676. * Interface used to define Action
  77677. */
  77678. export interface IAction {
  77679. /**
  77680. * Trigger for the action
  77681. */
  77682. trigger: number;
  77683. /** Options of the trigger */
  77684. triggerOptions: any;
  77685. /**
  77686. * Gets the trigger parameters
  77687. * @returns the trigger parameters
  77688. */
  77689. getTriggerParameter(): any;
  77690. /**
  77691. * Internal only - executes current action event
  77692. * @hidden
  77693. */
  77694. _executeCurrent(evt?: ActionEvent): void;
  77695. /**
  77696. * Serialize placeholder for child classes
  77697. * @param parent of child
  77698. * @returns the serialized object
  77699. */
  77700. serialize(parent: any): any;
  77701. /**
  77702. * Internal only
  77703. * @hidden
  77704. */
  77705. _prepare(): void;
  77706. /**
  77707. * Internal only - manager for action
  77708. * @hidden
  77709. */
  77710. _actionManager: AbstractActionManager;
  77711. /**
  77712. * Adds action to chain of actions, may be a DoNothingAction
  77713. * @param action defines the next action to execute
  77714. * @returns The action passed in
  77715. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77716. */
  77717. then(action: IAction): IAction;
  77718. }
  77719. /**
  77720. * The action to be carried out following a trigger
  77721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77722. */
  77723. export class Action implements IAction {
  77724. /** the trigger, with or without parameters, for the action */
  77725. triggerOptions: any;
  77726. /**
  77727. * Trigger for the action
  77728. */
  77729. trigger: number;
  77730. /**
  77731. * Internal only - manager for action
  77732. * @hidden
  77733. */
  77734. _actionManager: ActionManager;
  77735. private _nextActiveAction;
  77736. private _child;
  77737. private _condition?;
  77738. private _triggerParameter;
  77739. /**
  77740. * An event triggered prior to action being executed.
  77741. */
  77742. onBeforeExecuteObservable: Observable<Action>;
  77743. /**
  77744. * Creates a new Action
  77745. * @param triggerOptions the trigger, with or without parameters, for the action
  77746. * @param condition an optional determinant of action
  77747. */
  77748. constructor(
  77749. /** the trigger, with or without parameters, for the action */
  77750. triggerOptions: any, condition?: Condition);
  77751. /**
  77752. * Internal only
  77753. * @hidden
  77754. */
  77755. _prepare(): void;
  77756. /**
  77757. * Gets the trigger parameters
  77758. * @returns the trigger parameters
  77759. */
  77760. getTriggerParameter(): any;
  77761. /**
  77762. * Internal only - executes current action event
  77763. * @hidden
  77764. */
  77765. _executeCurrent(evt?: ActionEvent): void;
  77766. /**
  77767. * Execute placeholder for child classes
  77768. * @param evt optional action event
  77769. */
  77770. execute(evt?: ActionEvent): void;
  77771. /**
  77772. * Skips to next active action
  77773. */
  77774. skipToNextActiveAction(): void;
  77775. /**
  77776. * Adds action to chain of actions, may be a DoNothingAction
  77777. * @param action defines the next action to execute
  77778. * @returns The action passed in
  77779. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77780. */
  77781. then(action: Action): Action;
  77782. /**
  77783. * Internal only
  77784. * @hidden
  77785. */
  77786. _getProperty(propertyPath: string): string;
  77787. /**
  77788. * Internal only
  77789. * @hidden
  77790. */
  77791. _getEffectiveTarget(target: any, propertyPath: string): any;
  77792. /**
  77793. * Serialize placeholder for child classes
  77794. * @param parent of child
  77795. * @returns the serialized object
  77796. */
  77797. serialize(parent: any): any;
  77798. /**
  77799. * Internal only called by serialize
  77800. * @hidden
  77801. */
  77802. protected _serialize(serializedAction: any, parent?: any): any;
  77803. /**
  77804. * Internal only
  77805. * @hidden
  77806. */
  77807. static _SerializeValueAsString: (value: any) => string;
  77808. /**
  77809. * Internal only
  77810. * @hidden
  77811. */
  77812. static _GetTargetProperty: (target: Scene | Node) => {
  77813. name: string;
  77814. targetType: string;
  77815. value: string;
  77816. };
  77817. }
  77818. }
  77819. declare module BABYLON {
  77820. /**
  77821. * A Condition applied to an Action
  77822. */
  77823. export class Condition {
  77824. /**
  77825. * Internal only - manager for action
  77826. * @hidden
  77827. */
  77828. _actionManager: ActionManager;
  77829. /**
  77830. * Internal only
  77831. * @hidden
  77832. */
  77833. _evaluationId: number;
  77834. /**
  77835. * Internal only
  77836. * @hidden
  77837. */
  77838. _currentResult: boolean;
  77839. /**
  77840. * Creates a new Condition
  77841. * @param actionManager the manager of the action the condition is applied to
  77842. */
  77843. constructor(actionManager: ActionManager);
  77844. /**
  77845. * Check if the current condition is valid
  77846. * @returns a boolean
  77847. */
  77848. isValid(): boolean;
  77849. /**
  77850. * Internal only
  77851. * @hidden
  77852. */
  77853. _getProperty(propertyPath: string): string;
  77854. /**
  77855. * Internal only
  77856. * @hidden
  77857. */
  77858. _getEffectiveTarget(target: any, propertyPath: string): any;
  77859. /**
  77860. * Serialize placeholder for child classes
  77861. * @returns the serialized object
  77862. */
  77863. serialize(): any;
  77864. /**
  77865. * Internal only
  77866. * @hidden
  77867. */
  77868. protected _serialize(serializedCondition: any): any;
  77869. }
  77870. /**
  77871. * Defines specific conditional operators as extensions of Condition
  77872. */
  77873. export class ValueCondition extends Condition {
  77874. /** path to specify the property of the target the conditional operator uses */
  77875. propertyPath: string;
  77876. /** the value compared by the conditional operator against the current value of the property */
  77877. value: any;
  77878. /** the conditional operator, default ValueCondition.IsEqual */
  77879. operator: number;
  77880. /**
  77881. * Internal only
  77882. * @hidden
  77883. */
  77884. private static _IsEqual;
  77885. /**
  77886. * Internal only
  77887. * @hidden
  77888. */
  77889. private static _IsDifferent;
  77890. /**
  77891. * Internal only
  77892. * @hidden
  77893. */
  77894. private static _IsGreater;
  77895. /**
  77896. * Internal only
  77897. * @hidden
  77898. */
  77899. private static _IsLesser;
  77900. /**
  77901. * returns the number for IsEqual
  77902. */
  77903. static readonly IsEqual: number;
  77904. /**
  77905. * Returns the number for IsDifferent
  77906. */
  77907. static readonly IsDifferent: number;
  77908. /**
  77909. * Returns the number for IsGreater
  77910. */
  77911. static readonly IsGreater: number;
  77912. /**
  77913. * Returns the number for IsLesser
  77914. */
  77915. static readonly IsLesser: number;
  77916. /**
  77917. * Internal only The action manager for the condition
  77918. * @hidden
  77919. */
  77920. _actionManager: ActionManager;
  77921. /**
  77922. * Internal only
  77923. * @hidden
  77924. */
  77925. private _target;
  77926. /**
  77927. * Internal only
  77928. * @hidden
  77929. */
  77930. private _effectiveTarget;
  77931. /**
  77932. * Internal only
  77933. * @hidden
  77934. */
  77935. private _property;
  77936. /**
  77937. * Creates a new ValueCondition
  77938. * @param actionManager manager for the action the condition applies to
  77939. * @param target for the action
  77940. * @param propertyPath path to specify the property of the target the conditional operator uses
  77941. * @param value the value compared by the conditional operator against the current value of the property
  77942. * @param operator the conditional operator, default ValueCondition.IsEqual
  77943. */
  77944. constructor(actionManager: ActionManager, target: any,
  77945. /** path to specify the property of the target the conditional operator uses */
  77946. propertyPath: string,
  77947. /** the value compared by the conditional operator against the current value of the property */
  77948. value: any,
  77949. /** the conditional operator, default ValueCondition.IsEqual */
  77950. operator?: number);
  77951. /**
  77952. * Compares the given value with the property value for the specified conditional operator
  77953. * @returns the result of the comparison
  77954. */
  77955. isValid(): boolean;
  77956. /**
  77957. * Serialize the ValueCondition into a JSON compatible object
  77958. * @returns serialization object
  77959. */
  77960. serialize(): any;
  77961. /**
  77962. * Gets the name of the conditional operator for the ValueCondition
  77963. * @param operator the conditional operator
  77964. * @returns the name
  77965. */
  77966. static GetOperatorName(operator: number): string;
  77967. }
  77968. /**
  77969. * Defines a predicate condition as an extension of Condition
  77970. */
  77971. export class PredicateCondition extends Condition {
  77972. /** defines the predicate function used to validate the condition */
  77973. predicate: () => boolean;
  77974. /**
  77975. * Internal only - manager for action
  77976. * @hidden
  77977. */
  77978. _actionManager: ActionManager;
  77979. /**
  77980. * Creates a new PredicateCondition
  77981. * @param actionManager manager for the action the condition applies to
  77982. * @param predicate defines the predicate function used to validate the condition
  77983. */
  77984. constructor(actionManager: ActionManager,
  77985. /** defines the predicate function used to validate the condition */
  77986. predicate: () => boolean);
  77987. /**
  77988. * @returns the validity of the predicate condition
  77989. */
  77990. isValid(): boolean;
  77991. }
  77992. /**
  77993. * Defines a state condition as an extension of Condition
  77994. */
  77995. export class StateCondition extends Condition {
  77996. /** Value to compare with target state */
  77997. value: string;
  77998. /**
  77999. * Internal only - manager for action
  78000. * @hidden
  78001. */
  78002. _actionManager: ActionManager;
  78003. /**
  78004. * Internal only
  78005. * @hidden
  78006. */
  78007. private _target;
  78008. /**
  78009. * Creates a new StateCondition
  78010. * @param actionManager manager for the action the condition applies to
  78011. * @param target of the condition
  78012. * @param value to compare with target state
  78013. */
  78014. constructor(actionManager: ActionManager, target: any,
  78015. /** Value to compare with target state */
  78016. value: string);
  78017. /**
  78018. * Gets a boolean indicating if the current condition is met
  78019. * @returns the validity of the state
  78020. */
  78021. isValid(): boolean;
  78022. /**
  78023. * Serialize the StateCondition into a JSON compatible object
  78024. * @returns serialization object
  78025. */
  78026. serialize(): any;
  78027. }
  78028. }
  78029. declare module BABYLON {
  78030. /**
  78031. * This defines an action responsible to toggle a boolean once triggered.
  78032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78033. */
  78034. export class SwitchBooleanAction extends Action {
  78035. /**
  78036. * The path to the boolean property in the target object
  78037. */
  78038. propertyPath: string;
  78039. private _target;
  78040. private _effectiveTarget;
  78041. private _property;
  78042. /**
  78043. * Instantiate the action
  78044. * @param triggerOptions defines the trigger options
  78045. * @param target defines the object containing the boolean
  78046. * @param propertyPath defines the path to the boolean property in the target object
  78047. * @param condition defines the trigger related conditions
  78048. */
  78049. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78050. /** @hidden */
  78051. _prepare(): void;
  78052. /**
  78053. * Execute the action toggle the boolean value.
  78054. */
  78055. execute(): void;
  78056. /**
  78057. * Serializes the actions and its related information.
  78058. * @param parent defines the object to serialize in
  78059. * @returns the serialized object
  78060. */
  78061. serialize(parent: any): any;
  78062. }
  78063. /**
  78064. * This defines an action responsible to set a the state field of the target
  78065. * to a desired value once triggered.
  78066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78067. */
  78068. export class SetStateAction extends Action {
  78069. /**
  78070. * The value to store in the state field.
  78071. */
  78072. value: string;
  78073. private _target;
  78074. /**
  78075. * Instantiate the action
  78076. * @param triggerOptions defines the trigger options
  78077. * @param target defines the object containing the state property
  78078. * @param value defines the value to store in the state field
  78079. * @param condition defines the trigger related conditions
  78080. */
  78081. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78082. /**
  78083. * Execute the action and store the value on the target state property.
  78084. */
  78085. execute(): void;
  78086. /**
  78087. * Serializes the actions and its related information.
  78088. * @param parent defines the object to serialize in
  78089. * @returns the serialized object
  78090. */
  78091. serialize(parent: any): any;
  78092. }
  78093. /**
  78094. * This defines an action responsible to set a property of the target
  78095. * to a desired value once triggered.
  78096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78097. */
  78098. export class SetValueAction extends Action {
  78099. /**
  78100. * The path of the property to set in the target.
  78101. */
  78102. propertyPath: string;
  78103. /**
  78104. * The value to set in the property
  78105. */
  78106. value: any;
  78107. private _target;
  78108. private _effectiveTarget;
  78109. private _property;
  78110. /**
  78111. * Instantiate the action
  78112. * @param triggerOptions defines the trigger options
  78113. * @param target defines the object containing the property
  78114. * @param propertyPath defines the path of the property to set in the target
  78115. * @param value defines the value to set in the property
  78116. * @param condition defines the trigger related conditions
  78117. */
  78118. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78119. /** @hidden */
  78120. _prepare(): void;
  78121. /**
  78122. * Execute the action and set the targetted property to the desired value.
  78123. */
  78124. execute(): void;
  78125. /**
  78126. * Serializes the actions and its related information.
  78127. * @param parent defines the object to serialize in
  78128. * @returns the serialized object
  78129. */
  78130. serialize(parent: any): any;
  78131. }
  78132. /**
  78133. * This defines an action responsible to increment the target value
  78134. * to a desired value once triggered.
  78135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78136. */
  78137. export class IncrementValueAction extends Action {
  78138. /**
  78139. * The path of the property to increment in the target.
  78140. */
  78141. propertyPath: string;
  78142. /**
  78143. * The value we should increment the property by.
  78144. */
  78145. value: any;
  78146. private _target;
  78147. private _effectiveTarget;
  78148. private _property;
  78149. /**
  78150. * Instantiate the action
  78151. * @param triggerOptions defines the trigger options
  78152. * @param target defines the object containing the property
  78153. * @param propertyPath defines the path of the property to increment in the target
  78154. * @param value defines the value value we should increment the property by
  78155. * @param condition defines the trigger related conditions
  78156. */
  78157. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78158. /** @hidden */
  78159. _prepare(): void;
  78160. /**
  78161. * Execute the action and increment the target of the value amount.
  78162. */
  78163. execute(): void;
  78164. /**
  78165. * Serializes the actions and its related information.
  78166. * @param parent defines the object to serialize in
  78167. * @returns the serialized object
  78168. */
  78169. serialize(parent: any): any;
  78170. }
  78171. /**
  78172. * This defines an action responsible to start an animation once triggered.
  78173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78174. */
  78175. export class PlayAnimationAction extends Action {
  78176. /**
  78177. * Where the animation should start (animation frame)
  78178. */
  78179. from: number;
  78180. /**
  78181. * Where the animation should stop (animation frame)
  78182. */
  78183. to: number;
  78184. /**
  78185. * Define if the animation should loop or stop after the first play.
  78186. */
  78187. loop?: boolean;
  78188. private _target;
  78189. /**
  78190. * Instantiate the action
  78191. * @param triggerOptions defines the trigger options
  78192. * @param target defines the target animation or animation name
  78193. * @param from defines from where the animation should start (animation frame)
  78194. * @param end defines where the animation should stop (animation frame)
  78195. * @param loop defines if the animation should loop or stop after the first play
  78196. * @param condition defines the trigger related conditions
  78197. */
  78198. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78199. /** @hidden */
  78200. _prepare(): void;
  78201. /**
  78202. * Execute the action and play the animation.
  78203. */
  78204. execute(): void;
  78205. /**
  78206. * Serializes the actions and its related information.
  78207. * @param parent defines the object to serialize in
  78208. * @returns the serialized object
  78209. */
  78210. serialize(parent: any): any;
  78211. }
  78212. /**
  78213. * This defines an action responsible to stop an animation once triggered.
  78214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78215. */
  78216. export class StopAnimationAction extends Action {
  78217. private _target;
  78218. /**
  78219. * Instantiate the action
  78220. * @param triggerOptions defines the trigger options
  78221. * @param target defines the target animation or animation name
  78222. * @param condition defines the trigger related conditions
  78223. */
  78224. constructor(triggerOptions: any, target: any, condition?: Condition);
  78225. /** @hidden */
  78226. _prepare(): void;
  78227. /**
  78228. * Execute the action and stop the animation.
  78229. */
  78230. execute(): void;
  78231. /**
  78232. * Serializes the actions and its related information.
  78233. * @param parent defines the object to serialize in
  78234. * @returns the serialized object
  78235. */
  78236. serialize(parent: any): any;
  78237. }
  78238. /**
  78239. * This defines an action responsible that does nothing once triggered.
  78240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78241. */
  78242. export class DoNothingAction extends Action {
  78243. /**
  78244. * Instantiate the action
  78245. * @param triggerOptions defines the trigger options
  78246. * @param condition defines the trigger related conditions
  78247. */
  78248. constructor(triggerOptions?: any, condition?: Condition);
  78249. /**
  78250. * Execute the action and do nothing.
  78251. */
  78252. execute(): void;
  78253. /**
  78254. * Serializes the actions and its related information.
  78255. * @param parent defines the object to serialize in
  78256. * @returns the serialized object
  78257. */
  78258. serialize(parent: any): any;
  78259. }
  78260. /**
  78261. * This defines an action responsible to trigger several actions once triggered.
  78262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78263. */
  78264. export class CombineAction extends Action {
  78265. /**
  78266. * The list of aggregated animations to run.
  78267. */
  78268. children: Action[];
  78269. /**
  78270. * Instantiate the action
  78271. * @param triggerOptions defines the trigger options
  78272. * @param children defines the list of aggregated animations to run
  78273. * @param condition defines the trigger related conditions
  78274. */
  78275. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78276. /** @hidden */
  78277. _prepare(): void;
  78278. /**
  78279. * Execute the action and executes all the aggregated actions.
  78280. */
  78281. execute(evt: ActionEvent): void;
  78282. /**
  78283. * Serializes the actions and its related information.
  78284. * @param parent defines the object to serialize in
  78285. * @returns the serialized object
  78286. */
  78287. serialize(parent: any): any;
  78288. }
  78289. /**
  78290. * This defines an action responsible to run code (external event) once triggered.
  78291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78292. */
  78293. export class ExecuteCodeAction extends Action {
  78294. /**
  78295. * The callback function to run.
  78296. */
  78297. func: (evt: ActionEvent) => void;
  78298. /**
  78299. * Instantiate the action
  78300. * @param triggerOptions defines the trigger options
  78301. * @param func defines the callback function to run
  78302. * @param condition defines the trigger related conditions
  78303. */
  78304. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78305. /**
  78306. * Execute the action and run the attached code.
  78307. */
  78308. execute(evt: ActionEvent): void;
  78309. }
  78310. /**
  78311. * This defines an action responsible to set the parent property of the target once triggered.
  78312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78313. */
  78314. export class SetParentAction extends Action {
  78315. private _parent;
  78316. private _target;
  78317. /**
  78318. * Instantiate the action
  78319. * @param triggerOptions defines the trigger options
  78320. * @param target defines the target containing the parent property
  78321. * @param parent defines from where the animation should start (animation frame)
  78322. * @param condition defines the trigger related conditions
  78323. */
  78324. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78325. /** @hidden */
  78326. _prepare(): void;
  78327. /**
  78328. * Execute the action and set the parent property.
  78329. */
  78330. execute(): void;
  78331. /**
  78332. * Serializes the actions and its related information.
  78333. * @param parent defines the object to serialize in
  78334. * @returns the serialized object
  78335. */
  78336. serialize(parent: any): any;
  78337. }
  78338. }
  78339. declare module BABYLON {
  78340. /**
  78341. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78342. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78344. */
  78345. export class ActionManager extends AbstractActionManager {
  78346. /**
  78347. * Nothing
  78348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78349. */
  78350. static readonly NothingTrigger: number;
  78351. /**
  78352. * On pick
  78353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78354. */
  78355. static readonly OnPickTrigger: number;
  78356. /**
  78357. * On left pick
  78358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78359. */
  78360. static readonly OnLeftPickTrigger: number;
  78361. /**
  78362. * On right pick
  78363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78364. */
  78365. static readonly OnRightPickTrigger: number;
  78366. /**
  78367. * On center pick
  78368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78369. */
  78370. static readonly OnCenterPickTrigger: number;
  78371. /**
  78372. * On pick down
  78373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78374. */
  78375. static readonly OnPickDownTrigger: number;
  78376. /**
  78377. * On double pick
  78378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78379. */
  78380. static readonly OnDoublePickTrigger: number;
  78381. /**
  78382. * On pick up
  78383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78384. */
  78385. static readonly OnPickUpTrigger: number;
  78386. /**
  78387. * On pick out.
  78388. * This trigger will only be raised if you also declared a OnPickDown
  78389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78390. */
  78391. static readonly OnPickOutTrigger: number;
  78392. /**
  78393. * On long press
  78394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78395. */
  78396. static readonly OnLongPressTrigger: number;
  78397. /**
  78398. * On pointer over
  78399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78400. */
  78401. static readonly OnPointerOverTrigger: number;
  78402. /**
  78403. * On pointer out
  78404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78405. */
  78406. static readonly OnPointerOutTrigger: number;
  78407. /**
  78408. * On every frame
  78409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78410. */
  78411. static readonly OnEveryFrameTrigger: number;
  78412. /**
  78413. * On intersection enter
  78414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78415. */
  78416. static readonly OnIntersectionEnterTrigger: number;
  78417. /**
  78418. * On intersection exit
  78419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78420. */
  78421. static readonly OnIntersectionExitTrigger: number;
  78422. /**
  78423. * On key down
  78424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78425. */
  78426. static readonly OnKeyDownTrigger: number;
  78427. /**
  78428. * On key up
  78429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78430. */
  78431. static readonly OnKeyUpTrigger: number;
  78432. private _scene;
  78433. /**
  78434. * Creates a new action manager
  78435. * @param scene defines the hosting scene
  78436. */
  78437. constructor(scene: Scene);
  78438. /**
  78439. * Releases all associated resources
  78440. */
  78441. dispose(): void;
  78442. /**
  78443. * Gets hosting scene
  78444. * @returns the hosting scene
  78445. */
  78446. getScene(): Scene;
  78447. /**
  78448. * Does this action manager handles actions of any of the given triggers
  78449. * @param triggers defines the triggers to be tested
  78450. * @return a boolean indicating whether one (or more) of the triggers is handled
  78451. */
  78452. hasSpecificTriggers(triggers: number[]): boolean;
  78453. /**
  78454. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78455. * speed.
  78456. * @param triggerA defines the trigger to be tested
  78457. * @param triggerB defines the trigger to be tested
  78458. * @return a boolean indicating whether one (or more) of the triggers is handled
  78459. */
  78460. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78461. /**
  78462. * Does this action manager handles actions of a given trigger
  78463. * @param trigger defines the trigger to be tested
  78464. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78465. * @return whether the trigger is handled
  78466. */
  78467. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78468. /**
  78469. * Does this action manager has pointer triggers
  78470. */
  78471. readonly hasPointerTriggers: boolean;
  78472. /**
  78473. * Does this action manager has pick triggers
  78474. */
  78475. readonly hasPickTriggers: boolean;
  78476. /**
  78477. * Registers an action to this action manager
  78478. * @param action defines the action to be registered
  78479. * @return the action amended (prepared) after registration
  78480. */
  78481. registerAction(action: IAction): Nullable<IAction>;
  78482. /**
  78483. * Unregisters an action to this action manager
  78484. * @param action defines the action to be unregistered
  78485. * @return a boolean indicating whether the action has been unregistered
  78486. */
  78487. unregisterAction(action: IAction): Boolean;
  78488. /**
  78489. * Process a specific trigger
  78490. * @param trigger defines the trigger to process
  78491. * @param evt defines the event details to be processed
  78492. */
  78493. processTrigger(trigger: number, evt?: IActionEvent): void;
  78494. /** @hidden */
  78495. _getEffectiveTarget(target: any, propertyPath: string): any;
  78496. /** @hidden */
  78497. _getProperty(propertyPath: string): string;
  78498. /**
  78499. * Serialize this manager to a JSON object
  78500. * @param name defines the property name to store this manager
  78501. * @returns a JSON representation of this manager
  78502. */
  78503. serialize(name: string): any;
  78504. /**
  78505. * Creates a new ActionManager from a JSON data
  78506. * @param parsedActions defines the JSON data to read from
  78507. * @param object defines the hosting mesh
  78508. * @param scene defines the hosting scene
  78509. */
  78510. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78511. /**
  78512. * Get a trigger name by index
  78513. * @param trigger defines the trigger index
  78514. * @returns a trigger name
  78515. */
  78516. static GetTriggerName(trigger: number): string;
  78517. }
  78518. }
  78519. declare module BABYLON {
  78520. /**
  78521. * Class representing a ray with position and direction
  78522. */
  78523. export class Ray {
  78524. /** origin point */
  78525. origin: Vector3;
  78526. /** direction */
  78527. direction: Vector3;
  78528. /** length of the ray */
  78529. length: number;
  78530. private static readonly TmpVector3;
  78531. private _tmpRay;
  78532. /**
  78533. * Creates a new ray
  78534. * @param origin origin point
  78535. * @param direction direction
  78536. * @param length length of the ray
  78537. */
  78538. constructor(
  78539. /** origin point */
  78540. origin: Vector3,
  78541. /** direction */
  78542. direction: Vector3,
  78543. /** length of the ray */
  78544. length?: number);
  78545. /**
  78546. * Checks if the ray intersects a box
  78547. * @param minimum bound of the box
  78548. * @param maximum bound of the box
  78549. * @param intersectionTreshold extra extend to be added to the box in all direction
  78550. * @returns if the box was hit
  78551. */
  78552. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78553. /**
  78554. * Checks if the ray intersects a box
  78555. * @param box the bounding box to check
  78556. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78557. * @returns if the box was hit
  78558. */
  78559. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78560. /**
  78561. * If the ray hits a sphere
  78562. * @param sphere the bounding sphere to check
  78563. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78564. * @returns true if it hits the sphere
  78565. */
  78566. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78567. /**
  78568. * If the ray hits a triange
  78569. * @param vertex0 triangle vertex
  78570. * @param vertex1 triangle vertex
  78571. * @param vertex2 triangle vertex
  78572. * @returns intersection information if hit
  78573. */
  78574. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78575. /**
  78576. * Checks if ray intersects a plane
  78577. * @param plane the plane to check
  78578. * @returns the distance away it was hit
  78579. */
  78580. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78581. /**
  78582. * Checks if ray intersects a mesh
  78583. * @param mesh the mesh to check
  78584. * @param fastCheck if only the bounding box should checked
  78585. * @returns picking info of the intersecton
  78586. */
  78587. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78588. /**
  78589. * Checks if ray intersects a mesh
  78590. * @param meshes the meshes to check
  78591. * @param fastCheck if only the bounding box should checked
  78592. * @param results array to store result in
  78593. * @returns Array of picking infos
  78594. */
  78595. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78596. private _comparePickingInfo;
  78597. private static smallnum;
  78598. private static rayl;
  78599. /**
  78600. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78601. * @param sega the first point of the segment to test the intersection against
  78602. * @param segb the second point of the segment to test the intersection against
  78603. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78604. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78605. */
  78606. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78607. /**
  78608. * Update the ray from viewport position
  78609. * @param x position
  78610. * @param y y position
  78611. * @param viewportWidth viewport width
  78612. * @param viewportHeight viewport height
  78613. * @param world world matrix
  78614. * @param view view matrix
  78615. * @param projection projection matrix
  78616. * @returns this ray updated
  78617. */
  78618. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78619. /**
  78620. * Creates a ray with origin and direction of 0,0,0
  78621. * @returns the new ray
  78622. */
  78623. static Zero(): Ray;
  78624. /**
  78625. * Creates a new ray from screen space and viewport
  78626. * @param x position
  78627. * @param y y position
  78628. * @param viewportWidth viewport width
  78629. * @param viewportHeight viewport height
  78630. * @param world world matrix
  78631. * @param view view matrix
  78632. * @param projection projection matrix
  78633. * @returns new ray
  78634. */
  78635. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78636. /**
  78637. * 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
  78638. * transformed to the given world matrix.
  78639. * @param origin The origin point
  78640. * @param end The end point
  78641. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78642. * @returns the new ray
  78643. */
  78644. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78645. /**
  78646. * Transforms a ray by a matrix
  78647. * @param ray ray to transform
  78648. * @param matrix matrix to apply
  78649. * @returns the resulting new ray
  78650. */
  78651. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78652. /**
  78653. * Transforms a ray by a matrix
  78654. * @param ray ray to transform
  78655. * @param matrix matrix to apply
  78656. * @param result ray to store result in
  78657. */
  78658. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78659. /**
  78660. * Unproject a ray from screen space to object space
  78661. * @param sourceX defines the screen space x coordinate to use
  78662. * @param sourceY defines the screen space y coordinate to use
  78663. * @param viewportWidth defines the current width of the viewport
  78664. * @param viewportHeight defines the current height of the viewport
  78665. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78666. * @param view defines the view matrix to use
  78667. * @param projection defines the projection matrix to use
  78668. */
  78669. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78670. }
  78671. /**
  78672. * Type used to define predicate used to select faces when a mesh intersection is detected
  78673. */
  78674. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78675. interface Scene {
  78676. /** @hidden */
  78677. _tempPickingRay: Nullable<Ray>;
  78678. /** @hidden */
  78679. _cachedRayForTransform: Ray;
  78680. /** @hidden */
  78681. _pickWithRayInverseMatrix: Matrix;
  78682. /** @hidden */
  78683. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78684. /** @hidden */
  78685. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78686. }
  78687. }
  78688. declare module BABYLON {
  78689. interface Scene {
  78690. /** @hidden */
  78691. _pointerOverSprite: Nullable<Sprite>;
  78692. /** @hidden */
  78693. _pickedDownSprite: Nullable<Sprite>;
  78694. /** @hidden */
  78695. _tempSpritePickingRay: Nullable<Ray>;
  78696. /**
  78697. * All of the sprite managers added to this scene
  78698. * @see http://doc.babylonjs.com/babylon101/sprites
  78699. */
  78700. spriteManagers: Array<ISpriteManager>;
  78701. /**
  78702. * An event triggered when sprites rendering is about to start
  78703. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78704. */
  78705. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78706. /**
  78707. * An event triggered when sprites rendering is done
  78708. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78709. */
  78710. onAfterSpritesRenderingObservable: Observable<Scene>;
  78711. /** @hidden */
  78712. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78713. /** Launch a ray to try to pick a sprite in the scene
  78714. * @param x position on screen
  78715. * @param y position on screen
  78716. * @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
  78717. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78718. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78719. * @returns a PickingInfo
  78720. */
  78721. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78722. /** Use the given ray to pick a sprite in the scene
  78723. * @param ray The ray (in world space) to use to pick meshes
  78724. * @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
  78725. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78726. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78727. * @returns a PickingInfo
  78728. */
  78729. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78730. /**
  78731. * Force the sprite under the pointer
  78732. * @param sprite defines the sprite to use
  78733. */
  78734. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78735. /**
  78736. * Gets the sprite under the pointer
  78737. * @returns a Sprite or null if no sprite is under the pointer
  78738. */
  78739. getPointerOverSprite(): Nullable<Sprite>;
  78740. }
  78741. /**
  78742. * Defines the sprite scene component responsible to manage sprites
  78743. * in a given scene.
  78744. */
  78745. export class SpriteSceneComponent implements ISceneComponent {
  78746. /**
  78747. * The component name helpfull to identify the component in the list of scene components.
  78748. */
  78749. readonly name: string;
  78750. /**
  78751. * The scene the component belongs to.
  78752. */
  78753. scene: Scene;
  78754. /** @hidden */
  78755. private _spritePredicate;
  78756. /**
  78757. * Creates a new instance of the component for the given scene
  78758. * @param scene Defines the scene to register the component in
  78759. */
  78760. constructor(scene: Scene);
  78761. /**
  78762. * Registers the component in a given scene
  78763. */
  78764. register(): void;
  78765. /**
  78766. * Rebuilds the elements related to this component in case of
  78767. * context lost for instance.
  78768. */
  78769. rebuild(): void;
  78770. /**
  78771. * Disposes the component and the associated ressources.
  78772. */
  78773. dispose(): void;
  78774. private _pickSpriteButKeepRay;
  78775. private _pointerMove;
  78776. private _pointerDown;
  78777. private _pointerUp;
  78778. }
  78779. }
  78780. declare module BABYLON {
  78781. /** @hidden */
  78782. export var fogFragmentDeclaration: {
  78783. name: string;
  78784. shader: string;
  78785. };
  78786. }
  78787. declare module BABYLON {
  78788. /** @hidden */
  78789. export var fogFragment: {
  78790. name: string;
  78791. shader: string;
  78792. };
  78793. }
  78794. declare module BABYLON {
  78795. /** @hidden */
  78796. export var spritesPixelShader: {
  78797. name: string;
  78798. shader: string;
  78799. };
  78800. }
  78801. declare module BABYLON {
  78802. /** @hidden */
  78803. export var fogVertexDeclaration: {
  78804. name: string;
  78805. shader: string;
  78806. };
  78807. }
  78808. declare module BABYLON {
  78809. /** @hidden */
  78810. export var spritesVertexShader: {
  78811. name: string;
  78812. shader: string;
  78813. };
  78814. }
  78815. declare module BABYLON {
  78816. /**
  78817. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78818. */
  78819. export interface ISpriteManager extends IDisposable {
  78820. /**
  78821. * Restricts the camera to viewing objects with the same layerMask.
  78822. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78823. */
  78824. layerMask: number;
  78825. /**
  78826. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78827. */
  78828. isPickable: boolean;
  78829. /**
  78830. * Specifies the rendering group id for this mesh (0 by default)
  78831. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78832. */
  78833. renderingGroupId: number;
  78834. /**
  78835. * Defines the list of sprites managed by the manager.
  78836. */
  78837. sprites: Array<Sprite>;
  78838. /**
  78839. * Tests the intersection of a sprite with a specific ray.
  78840. * @param ray The ray we are sending to test the collision
  78841. * @param camera The camera space we are sending rays in
  78842. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78843. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78844. * @returns picking info or null.
  78845. */
  78846. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78847. /**
  78848. * Renders the list of sprites on screen.
  78849. */
  78850. render(): void;
  78851. }
  78852. /**
  78853. * Class used to manage multiple sprites on the same spritesheet
  78854. * @see http://doc.babylonjs.com/babylon101/sprites
  78855. */
  78856. export class SpriteManager implements ISpriteManager {
  78857. /** defines the manager's name */
  78858. name: string;
  78859. /** Gets the list of sprites */
  78860. sprites: Sprite[];
  78861. /** Gets or sets the rendering group id (0 by default) */
  78862. renderingGroupId: number;
  78863. /** Gets or sets camera layer mask */
  78864. layerMask: number;
  78865. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78866. fogEnabled: boolean;
  78867. /** Gets or sets a boolean indicating if the sprites are pickable */
  78868. isPickable: boolean;
  78869. /** Defines the default width of a cell in the spritesheet */
  78870. cellWidth: number;
  78871. /** Defines the default height of a cell in the spritesheet */
  78872. cellHeight: number;
  78873. /**
  78874. * An event triggered when the manager is disposed.
  78875. */
  78876. onDisposeObservable: Observable<SpriteManager>;
  78877. private _onDisposeObserver;
  78878. /**
  78879. * Callback called when the manager is disposed
  78880. */
  78881. onDispose: () => void;
  78882. private _capacity;
  78883. private _spriteTexture;
  78884. private _epsilon;
  78885. private _scene;
  78886. private _vertexData;
  78887. private _buffer;
  78888. private _vertexBuffers;
  78889. private _indexBuffer;
  78890. private _effectBase;
  78891. private _effectFog;
  78892. /**
  78893. * Gets or sets the spritesheet texture
  78894. */
  78895. texture: Texture;
  78896. /**
  78897. * Creates a new sprite manager
  78898. * @param name defines the manager's name
  78899. * @param imgUrl defines the sprite sheet url
  78900. * @param capacity defines the maximum allowed number of sprites
  78901. * @param cellSize defines the size of a sprite cell
  78902. * @param scene defines the hosting scene
  78903. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78904. * @param samplingMode defines the smapling mode to use with spritesheet
  78905. */
  78906. constructor(
  78907. /** defines the manager's name */
  78908. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78909. private _appendSpriteVertex;
  78910. /**
  78911. * Intersects the sprites with a ray
  78912. * @param ray defines the ray to intersect with
  78913. * @param camera defines the current active camera
  78914. * @param predicate defines a predicate used to select candidate sprites
  78915. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78916. * @returns null if no hit or a PickingInfo
  78917. */
  78918. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78919. /**
  78920. * Render all child sprites
  78921. */
  78922. render(): void;
  78923. /**
  78924. * Release associated resources
  78925. */
  78926. dispose(): void;
  78927. }
  78928. }
  78929. declare module BABYLON {
  78930. /**
  78931. * Class used to represent a sprite
  78932. * @see http://doc.babylonjs.com/babylon101/sprites
  78933. */
  78934. export class Sprite {
  78935. /** defines the name */
  78936. name: string;
  78937. /** Gets or sets the current world position */
  78938. position: Vector3;
  78939. /** Gets or sets the main color */
  78940. color: Color4;
  78941. /** Gets or sets the width */
  78942. width: number;
  78943. /** Gets or sets the height */
  78944. height: number;
  78945. /** Gets or sets rotation angle */
  78946. angle: number;
  78947. /** Gets or sets the cell index in the sprite sheet */
  78948. cellIndex: number;
  78949. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78950. invertU: number;
  78951. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78952. invertV: number;
  78953. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78954. disposeWhenFinishedAnimating: boolean;
  78955. /** Gets the list of attached animations */
  78956. animations: Animation[];
  78957. /** Gets or sets a boolean indicating if the sprite can be picked */
  78958. isPickable: boolean;
  78959. /**
  78960. * Gets or sets the associated action manager
  78961. */
  78962. actionManager: Nullable<ActionManager>;
  78963. private _animationStarted;
  78964. private _loopAnimation;
  78965. private _fromIndex;
  78966. private _toIndex;
  78967. private _delay;
  78968. private _direction;
  78969. private _manager;
  78970. private _time;
  78971. private _onAnimationEnd;
  78972. /**
  78973. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78974. */
  78975. isVisible: boolean;
  78976. /**
  78977. * Gets or sets the sprite size
  78978. */
  78979. size: number;
  78980. /**
  78981. * Creates a new Sprite
  78982. * @param name defines the name
  78983. * @param manager defines the manager
  78984. */
  78985. constructor(
  78986. /** defines the name */
  78987. name: string, manager: ISpriteManager);
  78988. /**
  78989. * Starts an animation
  78990. * @param from defines the initial key
  78991. * @param to defines the end key
  78992. * @param loop defines if the animation must loop
  78993. * @param delay defines the start delay (in ms)
  78994. * @param onAnimationEnd defines a callback to call when animation ends
  78995. */
  78996. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78997. /** Stops current animation (if any) */
  78998. stopAnimation(): void;
  78999. /** @hidden */
  79000. _animate(deltaTime: number): void;
  79001. /** Release associated resources */
  79002. dispose(): void;
  79003. }
  79004. }
  79005. declare module BABYLON {
  79006. /**
  79007. * Information about the result of picking within a scene
  79008. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79009. */
  79010. export class PickingInfo {
  79011. /** @hidden */
  79012. _pickingUnavailable: boolean;
  79013. /**
  79014. * If the pick collided with an object
  79015. */
  79016. hit: boolean;
  79017. /**
  79018. * Distance away where the pick collided
  79019. */
  79020. distance: number;
  79021. /**
  79022. * The location of pick collision
  79023. */
  79024. pickedPoint: Nullable<Vector3>;
  79025. /**
  79026. * The mesh corresponding the the pick collision
  79027. */
  79028. pickedMesh: Nullable<AbstractMesh>;
  79029. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79030. bu: number;
  79031. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79032. bv: number;
  79033. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79034. faceId: number;
  79035. /** Id of the the submesh that was picked */
  79036. subMeshId: number;
  79037. /** If a sprite was picked, this will be the sprite the pick collided with */
  79038. pickedSprite: Nullable<Sprite>;
  79039. /**
  79040. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79041. */
  79042. originMesh: Nullable<AbstractMesh>;
  79043. /**
  79044. * The ray that was used to perform the picking.
  79045. */
  79046. ray: Nullable<Ray>;
  79047. /**
  79048. * Gets the normal correspodning to the face the pick collided with
  79049. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79050. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79051. * @returns The normal correspodning to the face the pick collided with
  79052. */
  79053. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79054. /**
  79055. * Gets the texture coordinates of where the pick occured
  79056. * @returns the vector containing the coordnates of the texture
  79057. */
  79058. getTextureCoordinates(): Nullable<Vector2>;
  79059. }
  79060. }
  79061. declare module BABYLON {
  79062. /**
  79063. * Gather the list of pointer event types as constants.
  79064. */
  79065. export class PointerEventTypes {
  79066. /**
  79067. * 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.
  79068. */
  79069. static readonly POINTERDOWN: number;
  79070. /**
  79071. * The pointerup event is fired when a pointer is no longer active.
  79072. */
  79073. static readonly POINTERUP: number;
  79074. /**
  79075. * The pointermove event is fired when a pointer changes coordinates.
  79076. */
  79077. static readonly POINTERMOVE: number;
  79078. /**
  79079. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79080. */
  79081. static readonly POINTERWHEEL: number;
  79082. /**
  79083. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79084. */
  79085. static readonly POINTERPICK: number;
  79086. /**
  79087. * The pointertap event is fired when a the object has been touched and released without drag.
  79088. */
  79089. static readonly POINTERTAP: number;
  79090. /**
  79091. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79092. */
  79093. static readonly POINTERDOUBLETAP: number;
  79094. }
  79095. /**
  79096. * Base class of pointer info types.
  79097. */
  79098. export class PointerInfoBase {
  79099. /**
  79100. * Defines the type of event (PointerEventTypes)
  79101. */
  79102. type: number;
  79103. /**
  79104. * Defines the related dom event
  79105. */
  79106. event: PointerEvent | MouseWheelEvent;
  79107. /**
  79108. * Instantiates the base class of pointers info.
  79109. * @param type Defines the type of event (PointerEventTypes)
  79110. * @param event Defines the related dom event
  79111. */
  79112. constructor(
  79113. /**
  79114. * Defines the type of event (PointerEventTypes)
  79115. */
  79116. type: number,
  79117. /**
  79118. * Defines the related dom event
  79119. */
  79120. event: PointerEvent | MouseWheelEvent);
  79121. }
  79122. /**
  79123. * This class is used to store pointer related info for the onPrePointerObservable event.
  79124. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79125. */
  79126. export class PointerInfoPre extends PointerInfoBase {
  79127. /**
  79128. * Ray from a pointer if availible (eg. 6dof controller)
  79129. */
  79130. ray: Nullable<Ray>;
  79131. /**
  79132. * Defines the local position of the pointer on the canvas.
  79133. */
  79134. localPosition: Vector2;
  79135. /**
  79136. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79137. */
  79138. skipOnPointerObservable: boolean;
  79139. /**
  79140. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79141. * @param type Defines the type of event (PointerEventTypes)
  79142. * @param event Defines the related dom event
  79143. * @param localX Defines the local x coordinates of the pointer when the event occured
  79144. * @param localY Defines the local y coordinates of the pointer when the event occured
  79145. */
  79146. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79147. }
  79148. /**
  79149. * This type contains all the data related to a pointer event in Babylon.js.
  79150. * 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.
  79151. */
  79152. export class PointerInfo extends PointerInfoBase {
  79153. /**
  79154. * Defines the picking info associated to the info (if any)\
  79155. */
  79156. pickInfo: Nullable<PickingInfo>;
  79157. /**
  79158. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79159. * @param type Defines the type of event (PointerEventTypes)
  79160. * @param event Defines the related dom event
  79161. * @param pickInfo Defines the picking info associated to the info (if any)\
  79162. */
  79163. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79164. /**
  79165. * Defines the picking info associated to the info (if any)\
  79166. */
  79167. pickInfo: Nullable<PickingInfo>);
  79168. }
  79169. /**
  79170. * Data relating to a touch event on the screen.
  79171. */
  79172. export interface PointerTouch {
  79173. /**
  79174. * X coordinate of touch.
  79175. */
  79176. x: number;
  79177. /**
  79178. * Y coordinate of touch.
  79179. */
  79180. y: number;
  79181. /**
  79182. * Id of touch. Unique for each finger.
  79183. */
  79184. pointerId: number;
  79185. /**
  79186. * Event type passed from DOM.
  79187. */
  79188. type: any;
  79189. }
  79190. }
  79191. declare module BABYLON {
  79192. /**
  79193. * Manage the mouse inputs to control the movement of a free camera.
  79194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79195. */
  79196. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79197. /**
  79198. * Define if touch is enabled in the mouse input
  79199. */
  79200. touchEnabled: boolean;
  79201. /**
  79202. * Defines the camera the input is attached to.
  79203. */
  79204. camera: FreeCamera;
  79205. /**
  79206. * Defines the buttons associated with the input to handle camera move.
  79207. */
  79208. buttons: number[];
  79209. /**
  79210. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79211. */
  79212. angularSensibility: number;
  79213. private _pointerInput;
  79214. private _onMouseMove;
  79215. private _observer;
  79216. private previousPosition;
  79217. /**
  79218. * Observable for when a pointer move event occurs containing the move offset
  79219. */
  79220. onPointerMovedObservable: Observable<{
  79221. offsetX: number;
  79222. offsetY: number;
  79223. }>;
  79224. /**
  79225. * @hidden
  79226. * If the camera should be rotated automatically based on pointer movement
  79227. */
  79228. _allowCameraRotation: boolean;
  79229. /**
  79230. * Manage the mouse inputs to control the movement of a free camera.
  79231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79232. * @param touchEnabled Defines if touch is enabled or not
  79233. */
  79234. constructor(
  79235. /**
  79236. * Define if touch is enabled in the mouse input
  79237. */
  79238. touchEnabled?: boolean);
  79239. /**
  79240. * Attach the input controls to a specific dom element to get the input from.
  79241. * @param element Defines the element the controls should be listened from
  79242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79243. */
  79244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79245. /**
  79246. * Called on JS contextmenu event.
  79247. * Override this method to provide functionality.
  79248. */
  79249. protected onContextMenu(evt: PointerEvent): void;
  79250. /**
  79251. * Detach the current controls from the specified dom element.
  79252. * @param element Defines the element to stop listening the inputs from
  79253. */
  79254. detachControl(element: Nullable<HTMLElement>): void;
  79255. /**
  79256. * Gets the class name of the current intput.
  79257. * @returns the class name
  79258. */
  79259. getClassName(): string;
  79260. /**
  79261. * Get the friendly name associated with the input class.
  79262. * @returns the input friendly name
  79263. */
  79264. getSimpleName(): string;
  79265. }
  79266. }
  79267. declare module BABYLON {
  79268. /**
  79269. * Manage the touch inputs to control the movement of a free camera.
  79270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79271. */
  79272. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79273. /**
  79274. * Defines the camera the input is attached to.
  79275. */
  79276. camera: FreeCamera;
  79277. /**
  79278. * Defines the touch sensibility for rotation.
  79279. * The higher the faster.
  79280. */
  79281. touchAngularSensibility: number;
  79282. /**
  79283. * Defines the touch sensibility for move.
  79284. * The higher the faster.
  79285. */
  79286. touchMoveSensibility: number;
  79287. private _offsetX;
  79288. private _offsetY;
  79289. private _pointerPressed;
  79290. private _pointerInput;
  79291. private _observer;
  79292. private _onLostFocus;
  79293. /**
  79294. * Attach the input controls to a specific dom element to get the input from.
  79295. * @param element Defines the element the controls should be listened from
  79296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79297. */
  79298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79299. /**
  79300. * Detach the current controls from the specified dom element.
  79301. * @param element Defines the element to stop listening the inputs from
  79302. */
  79303. detachControl(element: Nullable<HTMLElement>): void;
  79304. /**
  79305. * Update the current camera state depending on the inputs that have been used this frame.
  79306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79307. */
  79308. checkInputs(): void;
  79309. /**
  79310. * Gets the class name of the current intput.
  79311. * @returns the class name
  79312. */
  79313. getClassName(): string;
  79314. /**
  79315. * Get the friendly name associated with the input class.
  79316. * @returns the input friendly name
  79317. */
  79318. getSimpleName(): string;
  79319. }
  79320. }
  79321. declare module BABYLON {
  79322. /**
  79323. * Default Inputs manager for the FreeCamera.
  79324. * It groups all the default supported inputs for ease of use.
  79325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79326. */
  79327. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79328. /**
  79329. * @hidden
  79330. */
  79331. _mouseInput: Nullable<FreeCameraMouseInput>;
  79332. /**
  79333. * Instantiates a new FreeCameraInputsManager.
  79334. * @param camera Defines the camera the inputs belong to
  79335. */
  79336. constructor(camera: FreeCamera);
  79337. /**
  79338. * Add keyboard input support to the input manager.
  79339. * @returns the current input manager
  79340. */
  79341. addKeyboard(): FreeCameraInputsManager;
  79342. /**
  79343. * Add mouse input support to the input manager.
  79344. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79345. * @returns the current input manager
  79346. */
  79347. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79348. /**
  79349. * Removes the mouse input support from the manager
  79350. * @returns the current input manager
  79351. */
  79352. removeMouse(): FreeCameraInputsManager;
  79353. /**
  79354. * Add touch input support to the input manager.
  79355. * @returns the current input manager
  79356. */
  79357. addTouch(): FreeCameraInputsManager;
  79358. /**
  79359. * Remove all attached input methods from a camera
  79360. */
  79361. clear(): void;
  79362. }
  79363. }
  79364. declare module BABYLON {
  79365. /**
  79366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79367. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79369. */
  79370. export class FreeCamera extends TargetCamera {
  79371. /**
  79372. * Define the collision ellipsoid of the camera.
  79373. * This is helpful to simulate a camera body like the player body around the camera
  79374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79375. */
  79376. ellipsoid: Vector3;
  79377. /**
  79378. * Define an offset for the position of the ellipsoid around the camera.
  79379. * This can be helpful to determine the center of the body near the gravity center of the body
  79380. * instead of its head.
  79381. */
  79382. ellipsoidOffset: Vector3;
  79383. /**
  79384. * Enable or disable collisions of the camera with the rest of the scene objects.
  79385. */
  79386. checkCollisions: boolean;
  79387. /**
  79388. * Enable or disable gravity on the camera.
  79389. */
  79390. applyGravity: boolean;
  79391. /**
  79392. * Define the input manager associated to the camera.
  79393. */
  79394. inputs: FreeCameraInputsManager;
  79395. /**
  79396. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79397. * Higher values reduce sensitivity.
  79398. */
  79399. /**
  79400. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79401. * Higher values reduce sensitivity.
  79402. */
  79403. angularSensibility: number;
  79404. /**
  79405. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79406. */
  79407. keysUp: number[];
  79408. /**
  79409. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79410. */
  79411. keysDown: number[];
  79412. /**
  79413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79414. */
  79415. keysLeft: number[];
  79416. /**
  79417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79418. */
  79419. keysRight: number[];
  79420. /**
  79421. * Event raised when the camera collide with a mesh in the scene.
  79422. */
  79423. onCollide: (collidedMesh: AbstractMesh) => void;
  79424. private _collider;
  79425. private _needMoveForGravity;
  79426. private _oldPosition;
  79427. private _diffPosition;
  79428. private _newPosition;
  79429. /** @hidden */
  79430. _localDirection: Vector3;
  79431. /** @hidden */
  79432. _transformedDirection: Vector3;
  79433. /**
  79434. * Instantiates a Free Camera.
  79435. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79436. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79438. * @param name Define the name of the camera in the scene
  79439. * @param position Define the start position of the camera in the scene
  79440. * @param scene Define the scene the camera belongs to
  79441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79442. */
  79443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79444. /**
  79445. * Attached controls to the current camera.
  79446. * @param element Defines the element the controls should be listened from
  79447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79448. */
  79449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79450. /**
  79451. * Detach the current controls from the camera.
  79452. * The camera will stop reacting to inputs.
  79453. * @param element Defines the element to stop listening the inputs from
  79454. */
  79455. detachControl(element: HTMLElement): void;
  79456. private _collisionMask;
  79457. /**
  79458. * Define a collision mask to limit the list of object the camera can collide with
  79459. */
  79460. collisionMask: number;
  79461. /** @hidden */
  79462. _collideWithWorld(displacement: Vector3): void;
  79463. private _onCollisionPositionChange;
  79464. /** @hidden */
  79465. _checkInputs(): void;
  79466. /** @hidden */
  79467. _decideIfNeedsToMove(): boolean;
  79468. /** @hidden */
  79469. _updatePosition(): void;
  79470. /**
  79471. * Destroy the camera and release the current resources hold by it.
  79472. */
  79473. dispose(): void;
  79474. /**
  79475. * Gets the current object class name.
  79476. * @return the class name
  79477. */
  79478. getClassName(): string;
  79479. }
  79480. }
  79481. declare module BABYLON {
  79482. /**
  79483. * Represents a gamepad control stick position
  79484. */
  79485. export class StickValues {
  79486. /**
  79487. * The x component of the control stick
  79488. */
  79489. x: number;
  79490. /**
  79491. * The y component of the control stick
  79492. */
  79493. y: number;
  79494. /**
  79495. * Initializes the gamepad x and y control stick values
  79496. * @param x The x component of the gamepad control stick value
  79497. * @param y The y component of the gamepad control stick value
  79498. */
  79499. constructor(
  79500. /**
  79501. * The x component of the control stick
  79502. */
  79503. x: number,
  79504. /**
  79505. * The y component of the control stick
  79506. */
  79507. y: number);
  79508. }
  79509. /**
  79510. * An interface which manages callbacks for gamepad button changes
  79511. */
  79512. export interface GamepadButtonChanges {
  79513. /**
  79514. * Called when a gamepad has been changed
  79515. */
  79516. changed: boolean;
  79517. /**
  79518. * Called when a gamepad press event has been triggered
  79519. */
  79520. pressChanged: boolean;
  79521. /**
  79522. * Called when a touch event has been triggered
  79523. */
  79524. touchChanged: boolean;
  79525. /**
  79526. * Called when a value has changed
  79527. */
  79528. valueChanged: boolean;
  79529. }
  79530. /**
  79531. * Represents a gamepad
  79532. */
  79533. export class Gamepad {
  79534. /**
  79535. * The id of the gamepad
  79536. */
  79537. id: string;
  79538. /**
  79539. * The index of the gamepad
  79540. */
  79541. index: number;
  79542. /**
  79543. * The browser gamepad
  79544. */
  79545. browserGamepad: any;
  79546. /**
  79547. * Specifies what type of gamepad this represents
  79548. */
  79549. type: number;
  79550. private _leftStick;
  79551. private _rightStick;
  79552. /** @hidden */
  79553. _isConnected: boolean;
  79554. private _leftStickAxisX;
  79555. private _leftStickAxisY;
  79556. private _rightStickAxisX;
  79557. private _rightStickAxisY;
  79558. /**
  79559. * Triggered when the left control stick has been changed
  79560. */
  79561. private _onleftstickchanged;
  79562. /**
  79563. * Triggered when the right control stick has been changed
  79564. */
  79565. private _onrightstickchanged;
  79566. /**
  79567. * Represents a gamepad controller
  79568. */
  79569. static GAMEPAD: number;
  79570. /**
  79571. * Represents a generic controller
  79572. */
  79573. static GENERIC: number;
  79574. /**
  79575. * Represents an XBox controller
  79576. */
  79577. static XBOX: number;
  79578. /**
  79579. * Represents a pose-enabled controller
  79580. */
  79581. static POSE_ENABLED: number;
  79582. /**
  79583. * Specifies whether the left control stick should be Y-inverted
  79584. */
  79585. protected _invertLeftStickY: boolean;
  79586. /**
  79587. * Specifies if the gamepad has been connected
  79588. */
  79589. readonly isConnected: boolean;
  79590. /**
  79591. * Initializes the gamepad
  79592. * @param id The id of the gamepad
  79593. * @param index The index of the gamepad
  79594. * @param browserGamepad The browser gamepad
  79595. * @param leftStickX The x component of the left joystick
  79596. * @param leftStickY The y component of the left joystick
  79597. * @param rightStickX The x component of the right joystick
  79598. * @param rightStickY The y component of the right joystick
  79599. */
  79600. constructor(
  79601. /**
  79602. * The id of the gamepad
  79603. */
  79604. id: string,
  79605. /**
  79606. * The index of the gamepad
  79607. */
  79608. index: number,
  79609. /**
  79610. * The browser gamepad
  79611. */
  79612. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79613. /**
  79614. * Callback triggered when the left joystick has changed
  79615. * @param callback
  79616. */
  79617. onleftstickchanged(callback: (values: StickValues) => void): void;
  79618. /**
  79619. * Callback triggered when the right joystick has changed
  79620. * @param callback
  79621. */
  79622. onrightstickchanged(callback: (values: StickValues) => void): void;
  79623. /**
  79624. * Gets the left joystick
  79625. */
  79626. /**
  79627. * Sets the left joystick values
  79628. */
  79629. leftStick: StickValues;
  79630. /**
  79631. * Gets the right joystick
  79632. */
  79633. /**
  79634. * Sets the right joystick value
  79635. */
  79636. rightStick: StickValues;
  79637. /**
  79638. * Updates the gamepad joystick positions
  79639. */
  79640. update(): void;
  79641. /**
  79642. * Disposes the gamepad
  79643. */
  79644. dispose(): void;
  79645. }
  79646. /**
  79647. * Represents a generic gamepad
  79648. */
  79649. export class GenericPad extends Gamepad {
  79650. private _buttons;
  79651. private _onbuttondown;
  79652. private _onbuttonup;
  79653. /**
  79654. * Observable triggered when a button has been pressed
  79655. */
  79656. onButtonDownObservable: Observable<number>;
  79657. /**
  79658. * Observable triggered when a button has been released
  79659. */
  79660. onButtonUpObservable: Observable<number>;
  79661. /**
  79662. * Callback triggered when a button has been pressed
  79663. * @param callback Called when a button has been pressed
  79664. */
  79665. onbuttondown(callback: (buttonPressed: number) => void): void;
  79666. /**
  79667. * Callback triggered when a button has been released
  79668. * @param callback Called when a button has been released
  79669. */
  79670. onbuttonup(callback: (buttonReleased: number) => void): void;
  79671. /**
  79672. * Initializes the generic gamepad
  79673. * @param id The id of the generic gamepad
  79674. * @param index The index of the generic gamepad
  79675. * @param browserGamepad The browser gamepad
  79676. */
  79677. constructor(id: string, index: number, browserGamepad: any);
  79678. private _setButtonValue;
  79679. /**
  79680. * Updates the generic gamepad
  79681. */
  79682. update(): void;
  79683. /**
  79684. * Disposes the generic gamepad
  79685. */
  79686. dispose(): void;
  79687. }
  79688. }
  79689. declare module BABYLON {
  79690. /**
  79691. * Defines the types of pose enabled controllers that are supported
  79692. */
  79693. export enum PoseEnabledControllerType {
  79694. /**
  79695. * HTC Vive
  79696. */
  79697. VIVE = 0,
  79698. /**
  79699. * Oculus Rift
  79700. */
  79701. OCULUS = 1,
  79702. /**
  79703. * Windows mixed reality
  79704. */
  79705. WINDOWS = 2,
  79706. /**
  79707. * Samsung gear VR
  79708. */
  79709. GEAR_VR = 3,
  79710. /**
  79711. * Google Daydream
  79712. */
  79713. DAYDREAM = 4,
  79714. /**
  79715. * Generic
  79716. */
  79717. GENERIC = 5
  79718. }
  79719. /**
  79720. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79721. */
  79722. export interface MutableGamepadButton {
  79723. /**
  79724. * Value of the button/trigger
  79725. */
  79726. value: number;
  79727. /**
  79728. * If the button/trigger is currently touched
  79729. */
  79730. touched: boolean;
  79731. /**
  79732. * If the button/trigger is currently pressed
  79733. */
  79734. pressed: boolean;
  79735. }
  79736. /**
  79737. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79738. * @hidden
  79739. */
  79740. export interface ExtendedGamepadButton extends GamepadButton {
  79741. /**
  79742. * If the button/trigger is currently pressed
  79743. */
  79744. readonly pressed: boolean;
  79745. /**
  79746. * If the button/trigger is currently touched
  79747. */
  79748. readonly touched: boolean;
  79749. /**
  79750. * Value of the button/trigger
  79751. */
  79752. readonly value: number;
  79753. }
  79754. /** @hidden */
  79755. export interface _GamePadFactory {
  79756. /**
  79757. * Returns wether or not the current gamepad can be created for this type of controller.
  79758. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79759. * @returns true if it can be created, otherwise false
  79760. */
  79761. canCreate(gamepadInfo: any): boolean;
  79762. /**
  79763. * Creates a new instance of the Gamepad.
  79764. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79765. * @returns the new gamepad instance
  79766. */
  79767. create(gamepadInfo: any): Gamepad;
  79768. }
  79769. /**
  79770. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79771. */
  79772. export class PoseEnabledControllerHelper {
  79773. /** @hidden */
  79774. static _ControllerFactories: _GamePadFactory[];
  79775. /** @hidden */
  79776. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79777. /**
  79778. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79779. * @param vrGamepad the gamepad to initialized
  79780. * @returns a vr controller of the type the gamepad identified as
  79781. */
  79782. static InitiateController(vrGamepad: any): Gamepad;
  79783. }
  79784. /**
  79785. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79786. */
  79787. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79788. private _deviceRoomPosition;
  79789. private _deviceRoomRotationQuaternion;
  79790. /**
  79791. * The device position in babylon space
  79792. */
  79793. devicePosition: Vector3;
  79794. /**
  79795. * The device rotation in babylon space
  79796. */
  79797. deviceRotationQuaternion: Quaternion;
  79798. /**
  79799. * The scale factor of the device in babylon space
  79800. */
  79801. deviceScaleFactor: number;
  79802. /**
  79803. * (Likely devicePosition should be used instead) The device position in its room space
  79804. */
  79805. position: Vector3;
  79806. /**
  79807. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79808. */
  79809. rotationQuaternion: Quaternion;
  79810. /**
  79811. * The type of controller (Eg. Windows mixed reality)
  79812. */
  79813. controllerType: PoseEnabledControllerType;
  79814. protected _calculatedPosition: Vector3;
  79815. private _calculatedRotation;
  79816. /**
  79817. * The raw pose from the device
  79818. */
  79819. rawPose: DevicePose;
  79820. private _trackPosition;
  79821. private _maxRotationDistFromHeadset;
  79822. private _draggedRoomRotation;
  79823. /**
  79824. * @hidden
  79825. */
  79826. _disableTrackPosition(fixedPosition: Vector3): void;
  79827. /**
  79828. * Internal, the mesh attached to the controller
  79829. * @hidden
  79830. */
  79831. _mesh: Nullable<AbstractMesh>;
  79832. private _poseControlledCamera;
  79833. private _leftHandSystemQuaternion;
  79834. /**
  79835. * Internal, matrix used to convert room space to babylon space
  79836. * @hidden
  79837. */
  79838. _deviceToWorld: Matrix;
  79839. /**
  79840. * Node to be used when casting a ray from the controller
  79841. * @hidden
  79842. */
  79843. _pointingPoseNode: Nullable<TransformNode>;
  79844. /**
  79845. * Name of the child mesh that can be used to cast a ray from the controller
  79846. */
  79847. static readonly POINTING_POSE: string;
  79848. /**
  79849. * Creates a new PoseEnabledController from a gamepad
  79850. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79851. */
  79852. constructor(browserGamepad: any);
  79853. private _workingMatrix;
  79854. /**
  79855. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79856. */
  79857. update(): void;
  79858. /**
  79859. * Updates only the pose device and mesh without doing any button event checking
  79860. */
  79861. protected _updatePoseAndMesh(): void;
  79862. /**
  79863. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79864. * @param poseData raw pose fromthe device
  79865. */
  79866. updateFromDevice(poseData: DevicePose): void;
  79867. /**
  79868. * @hidden
  79869. */
  79870. _meshAttachedObservable: Observable<AbstractMesh>;
  79871. /**
  79872. * Attaches a mesh to the controller
  79873. * @param mesh the mesh to be attached
  79874. */
  79875. attachToMesh(mesh: AbstractMesh): void;
  79876. /**
  79877. * Attaches the controllers mesh to a camera
  79878. * @param camera the camera the mesh should be attached to
  79879. */
  79880. attachToPoseControlledCamera(camera: TargetCamera): void;
  79881. /**
  79882. * Disposes of the controller
  79883. */
  79884. dispose(): void;
  79885. /**
  79886. * The mesh that is attached to the controller
  79887. */
  79888. readonly mesh: Nullable<AbstractMesh>;
  79889. /**
  79890. * Gets the ray of the controller in the direction the controller is pointing
  79891. * @param length the length the resulting ray should be
  79892. * @returns a ray in the direction the controller is pointing
  79893. */
  79894. getForwardRay(length?: number): Ray;
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /**
  79899. * Defines the WebVRController object that represents controllers tracked in 3D space
  79900. */
  79901. export abstract class WebVRController extends PoseEnabledController {
  79902. /**
  79903. * Internal, the default controller model for the controller
  79904. */
  79905. protected _defaultModel: AbstractMesh;
  79906. /**
  79907. * Fired when the trigger state has changed
  79908. */
  79909. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79910. /**
  79911. * Fired when the main button state has changed
  79912. */
  79913. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79914. /**
  79915. * Fired when the secondary button state has changed
  79916. */
  79917. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79918. /**
  79919. * Fired when the pad state has changed
  79920. */
  79921. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79922. /**
  79923. * Fired when controllers stick values have changed
  79924. */
  79925. onPadValuesChangedObservable: Observable<StickValues>;
  79926. /**
  79927. * Array of button availible on the controller
  79928. */
  79929. protected _buttons: Array<MutableGamepadButton>;
  79930. private _onButtonStateChange;
  79931. /**
  79932. * Fired when a controller button's state has changed
  79933. * @param callback the callback containing the button that was modified
  79934. */
  79935. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79936. /**
  79937. * X and Y axis corresponding to the controllers joystick
  79938. */
  79939. pad: StickValues;
  79940. /**
  79941. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79942. */
  79943. hand: string;
  79944. /**
  79945. * The default controller model for the controller
  79946. */
  79947. readonly defaultModel: AbstractMesh;
  79948. /**
  79949. * Creates a new WebVRController from a gamepad
  79950. * @param vrGamepad the gamepad that the WebVRController should be created from
  79951. */
  79952. constructor(vrGamepad: any);
  79953. /**
  79954. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79955. */
  79956. update(): void;
  79957. /**
  79958. * Function to be called when a button is modified
  79959. */
  79960. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79961. /**
  79962. * Loads a mesh and attaches it to the controller
  79963. * @param scene the scene the mesh should be added to
  79964. * @param meshLoaded callback for when the mesh has been loaded
  79965. */
  79966. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79967. private _setButtonValue;
  79968. private _changes;
  79969. private _checkChanges;
  79970. /**
  79971. * Disposes of th webVRCOntroller
  79972. */
  79973. dispose(): void;
  79974. }
  79975. }
  79976. declare module BABYLON {
  79977. /**
  79978. * The HemisphericLight simulates the ambient environment light,
  79979. * so the passed direction is the light reflection direction, not the incoming direction.
  79980. */
  79981. export class HemisphericLight extends Light {
  79982. /**
  79983. * The groundColor is the light in the opposite direction to the one specified during creation.
  79984. * 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.
  79985. */
  79986. groundColor: Color3;
  79987. /**
  79988. * The light reflection direction, not the incoming direction.
  79989. */
  79990. direction: Vector3;
  79991. /**
  79992. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79993. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79994. * The HemisphericLight can't cast shadows.
  79995. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79996. * @param name The friendly name of the light
  79997. * @param direction The direction of the light reflection
  79998. * @param scene The scene the light belongs to
  79999. */
  80000. constructor(name: string, direction: Vector3, scene: Scene);
  80001. protected _buildUniformLayout(): void;
  80002. /**
  80003. * Returns the string "HemisphericLight".
  80004. * @return The class name
  80005. */
  80006. getClassName(): string;
  80007. /**
  80008. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80009. * Returns the updated direction.
  80010. * @param target The target the direction should point to
  80011. * @return The computed direction
  80012. */
  80013. setDirectionToTarget(target: Vector3): Vector3;
  80014. /**
  80015. * Returns the shadow generator associated to the light.
  80016. * @returns Always null for hemispheric lights because it does not support shadows.
  80017. */
  80018. getShadowGenerator(): Nullable<IShadowGenerator>;
  80019. /**
  80020. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80021. * @param effect The effect to update
  80022. * @param lightIndex The index of the light in the effect to update
  80023. * @returns The hemispheric light
  80024. */
  80025. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80026. /**
  80027. * Computes the world matrix of the node
  80028. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80029. * @param useWasUpdatedFlag defines a reserved property
  80030. * @returns the world matrix
  80031. */
  80032. computeWorldMatrix(): Matrix;
  80033. /**
  80034. * Returns the integer 3.
  80035. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80036. */
  80037. getTypeID(): number;
  80038. /**
  80039. * Prepares the list of defines specific to the light type.
  80040. * @param defines the list of defines
  80041. * @param lightIndex defines the index of the light for the effect
  80042. */
  80043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80044. }
  80045. }
  80046. declare module BABYLON {
  80047. /** @hidden */
  80048. export var vrMultiviewToSingleviewPixelShader: {
  80049. name: string;
  80050. shader: string;
  80051. };
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * Renders to multiple views with a single draw call
  80056. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80057. */
  80058. export class MultiviewRenderTarget extends RenderTargetTexture {
  80059. /**
  80060. * Creates a multiview render target
  80061. * @param scene scene used with the render target
  80062. * @param size the size of the render target (used for each view)
  80063. */
  80064. constructor(scene: Scene, size?: number | {
  80065. width: number;
  80066. height: number;
  80067. } | {
  80068. ratio: number;
  80069. });
  80070. /**
  80071. * @hidden
  80072. * @param faceIndex the face index, if its a cube texture
  80073. */
  80074. _bindFrameBuffer(faceIndex?: number): void;
  80075. /**
  80076. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80077. * @returns the view count
  80078. */
  80079. getViewCount(): number;
  80080. }
  80081. }
  80082. declare module BABYLON {
  80083. interface Engine {
  80084. /**
  80085. * Creates a new multiview render target
  80086. * @param width defines the width of the texture
  80087. * @param height defines the height of the texture
  80088. * @returns the created multiview texture
  80089. */
  80090. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80091. /**
  80092. * Binds a multiview framebuffer to be drawn to
  80093. * @param multiviewTexture texture to bind
  80094. */
  80095. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80096. }
  80097. interface Camera {
  80098. /**
  80099. * @hidden
  80100. * 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)
  80101. */
  80102. _useMultiviewToSingleView: boolean;
  80103. /**
  80104. * @hidden
  80105. * 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)
  80106. */
  80107. _multiviewTexture: Nullable<RenderTargetTexture>;
  80108. /**
  80109. * @hidden
  80110. * ensures the multiview texture of the camera exists and has the specified width/height
  80111. * @param width height to set on the multiview texture
  80112. * @param height width to set on the multiview texture
  80113. */
  80114. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80115. }
  80116. interface Scene {
  80117. /** @hidden */
  80118. _transformMatrixR: Matrix;
  80119. /** @hidden */
  80120. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80121. /** @hidden */
  80122. _createMultiviewUbo(): void;
  80123. /** @hidden */
  80124. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80125. /** @hidden */
  80126. _renderMultiviewToSingleView(camera: Camera): void;
  80127. }
  80128. }
  80129. declare module BABYLON {
  80130. /**
  80131. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80132. * This will not be used for webXR as it supports displaying texture arrays directly
  80133. */
  80134. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80135. /**
  80136. * Initializes a VRMultiviewToSingleview
  80137. * @param name name of the post process
  80138. * @param camera camera to be applied to
  80139. * @param scaleFactor scaling factor to the size of the output texture
  80140. */
  80141. constructor(name: string, camera: Camera, scaleFactor: number);
  80142. }
  80143. }
  80144. declare module BABYLON {
  80145. interface Engine {
  80146. /** @hidden */
  80147. _vrDisplay: any;
  80148. /** @hidden */
  80149. _vrSupported: boolean;
  80150. /** @hidden */
  80151. _oldSize: Size;
  80152. /** @hidden */
  80153. _oldHardwareScaleFactor: number;
  80154. /** @hidden */
  80155. _vrExclusivePointerMode: boolean;
  80156. /** @hidden */
  80157. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80158. /** @hidden */
  80159. _onVRDisplayPointerRestricted: () => void;
  80160. /** @hidden */
  80161. _onVRDisplayPointerUnrestricted: () => void;
  80162. /** @hidden */
  80163. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80164. /** @hidden */
  80165. _onVrDisplayDisconnect: Nullable<() => void>;
  80166. /** @hidden */
  80167. _onVrDisplayPresentChange: Nullable<() => void>;
  80168. /**
  80169. * Observable signaled when VR display mode changes
  80170. */
  80171. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80172. /**
  80173. * Observable signaled when VR request present is complete
  80174. */
  80175. onVRRequestPresentComplete: Observable<boolean>;
  80176. /**
  80177. * Observable signaled when VR request present starts
  80178. */
  80179. onVRRequestPresentStart: Observable<Engine>;
  80180. /**
  80181. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80182. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80183. */
  80184. isInVRExclusivePointerMode: boolean;
  80185. /**
  80186. * Gets a boolean indicating if a webVR device was detected
  80187. * @returns true if a webVR device was detected
  80188. */
  80189. isVRDevicePresent(): boolean;
  80190. /**
  80191. * Gets the current webVR device
  80192. * @returns the current webVR device (or null)
  80193. */
  80194. getVRDevice(): any;
  80195. /**
  80196. * Initializes a webVR display and starts listening to display change events
  80197. * The onVRDisplayChangedObservable will be notified upon these changes
  80198. * @returns A promise containing a VRDisplay and if vr is supported
  80199. */
  80200. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80201. /** @hidden */
  80202. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80203. /**
  80204. * Call this function to switch to webVR mode
  80205. * Will do nothing if webVR is not supported or if there is no webVR device
  80206. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80207. */
  80208. enableVR(): void;
  80209. /** @hidden */
  80210. _onVRFullScreenTriggered(): void;
  80211. }
  80212. }
  80213. declare module BABYLON {
  80214. /**
  80215. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80216. * IMPORTANT!! The data is right-hand data.
  80217. * @export
  80218. * @interface DevicePose
  80219. */
  80220. export interface DevicePose {
  80221. /**
  80222. * The position of the device, values in array are [x,y,z].
  80223. */
  80224. readonly position: Nullable<Float32Array>;
  80225. /**
  80226. * The linearVelocity of the device, values in array are [x,y,z].
  80227. */
  80228. readonly linearVelocity: Nullable<Float32Array>;
  80229. /**
  80230. * The linearAcceleration of the device, values in array are [x,y,z].
  80231. */
  80232. readonly linearAcceleration: Nullable<Float32Array>;
  80233. /**
  80234. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80235. */
  80236. readonly orientation: Nullable<Float32Array>;
  80237. /**
  80238. * The angularVelocity of the device, values in array are [x,y,z].
  80239. */
  80240. readonly angularVelocity: Nullable<Float32Array>;
  80241. /**
  80242. * The angularAcceleration of the device, values in array are [x,y,z].
  80243. */
  80244. readonly angularAcceleration: Nullable<Float32Array>;
  80245. }
  80246. /**
  80247. * Interface representing a pose controlled object in Babylon.
  80248. * A pose controlled object has both regular pose values as well as pose values
  80249. * from an external device such as a VR head mounted display
  80250. */
  80251. export interface PoseControlled {
  80252. /**
  80253. * The position of the object in babylon space.
  80254. */
  80255. position: Vector3;
  80256. /**
  80257. * The rotation quaternion of the object in babylon space.
  80258. */
  80259. rotationQuaternion: Quaternion;
  80260. /**
  80261. * The position of the device in babylon space.
  80262. */
  80263. devicePosition?: Vector3;
  80264. /**
  80265. * The rotation quaternion of the device in babylon space.
  80266. */
  80267. deviceRotationQuaternion: Quaternion;
  80268. /**
  80269. * The raw pose coming from the device.
  80270. */
  80271. rawPose: Nullable<DevicePose>;
  80272. /**
  80273. * The scale of the device to be used when translating from device space to babylon space.
  80274. */
  80275. deviceScaleFactor: number;
  80276. /**
  80277. * Updates the poseControlled values based on the input device pose.
  80278. * @param poseData the pose data to update the object with
  80279. */
  80280. updateFromDevice(poseData: DevicePose): void;
  80281. }
  80282. /**
  80283. * Set of options to customize the webVRCamera
  80284. */
  80285. export interface WebVROptions {
  80286. /**
  80287. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80288. */
  80289. trackPosition?: boolean;
  80290. /**
  80291. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80292. */
  80293. positionScale?: number;
  80294. /**
  80295. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80296. */
  80297. displayName?: string;
  80298. /**
  80299. * Should the native controller meshes be initialized. (default: true)
  80300. */
  80301. controllerMeshes?: boolean;
  80302. /**
  80303. * Creating a default HemiLight only on controllers. (default: true)
  80304. */
  80305. defaultLightingOnControllers?: boolean;
  80306. /**
  80307. * If you don't want to use the default VR button of the helper. (default: false)
  80308. */
  80309. useCustomVRButton?: boolean;
  80310. /**
  80311. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80312. */
  80313. customVRButton?: HTMLButtonElement;
  80314. /**
  80315. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80316. */
  80317. rayLength?: number;
  80318. /**
  80319. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80320. */
  80321. defaultHeight?: number;
  80322. /**
  80323. * If multiview should be used if availible (default: false)
  80324. */
  80325. useMultiview?: boolean;
  80326. }
  80327. /**
  80328. * This represents a WebVR camera.
  80329. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80330. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80331. */
  80332. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80333. private webVROptions;
  80334. /**
  80335. * @hidden
  80336. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80337. */
  80338. _vrDevice: any;
  80339. /**
  80340. * The rawPose of the vrDevice.
  80341. */
  80342. rawPose: Nullable<DevicePose>;
  80343. private _onVREnabled;
  80344. private _specsVersion;
  80345. private _attached;
  80346. private _frameData;
  80347. protected _descendants: Array<Node>;
  80348. private _deviceRoomPosition;
  80349. /** @hidden */
  80350. _deviceRoomRotationQuaternion: Quaternion;
  80351. private _standingMatrix;
  80352. /**
  80353. * Represents device position in babylon space.
  80354. */
  80355. devicePosition: Vector3;
  80356. /**
  80357. * Represents device rotation in babylon space.
  80358. */
  80359. deviceRotationQuaternion: Quaternion;
  80360. /**
  80361. * The scale of the device to be used when translating from device space to babylon space.
  80362. */
  80363. deviceScaleFactor: number;
  80364. private _deviceToWorld;
  80365. private _worldToDevice;
  80366. /**
  80367. * References to the webVR controllers for the vrDevice.
  80368. */
  80369. controllers: Array<WebVRController>;
  80370. /**
  80371. * Emits an event when a controller is attached.
  80372. */
  80373. onControllersAttachedObservable: Observable<WebVRController[]>;
  80374. /**
  80375. * Emits an event when a controller's mesh has been loaded;
  80376. */
  80377. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80378. /**
  80379. * Emits an event when the HMD's pose has been updated.
  80380. */
  80381. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80382. private _poseSet;
  80383. /**
  80384. * If the rig cameras be used as parent instead of this camera.
  80385. */
  80386. rigParenting: boolean;
  80387. private _lightOnControllers;
  80388. private _defaultHeight?;
  80389. /**
  80390. * Instantiates a WebVRFreeCamera.
  80391. * @param name The name of the WebVRFreeCamera
  80392. * @param position The starting anchor position for the camera
  80393. * @param scene The scene the camera belongs to
  80394. * @param webVROptions a set of customizable options for the webVRCamera
  80395. */
  80396. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80397. /**
  80398. * Gets the device distance from the ground in meters.
  80399. * @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.
  80400. */
  80401. deviceDistanceToRoomGround(): number;
  80402. /**
  80403. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80404. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80405. */
  80406. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80407. /**
  80408. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80409. * @returns A promise with a boolean set to if the standing matrix is supported.
  80410. */
  80411. useStandingMatrixAsync(): Promise<boolean>;
  80412. /**
  80413. * Disposes the camera
  80414. */
  80415. dispose(): void;
  80416. /**
  80417. * Gets a vrController by name.
  80418. * @param name The name of the controller to retreive
  80419. * @returns the controller matching the name specified or null if not found
  80420. */
  80421. getControllerByName(name: string): Nullable<WebVRController>;
  80422. private _leftController;
  80423. /**
  80424. * The controller corresponding to the users left hand.
  80425. */
  80426. readonly leftController: Nullable<WebVRController>;
  80427. private _rightController;
  80428. /**
  80429. * The controller corresponding to the users right hand.
  80430. */
  80431. readonly rightController: Nullable<WebVRController>;
  80432. /**
  80433. * Casts a ray forward from the vrCamera's gaze.
  80434. * @param length Length of the ray (default: 100)
  80435. * @returns the ray corresponding to the gaze
  80436. */
  80437. getForwardRay(length?: number): Ray;
  80438. /**
  80439. * @hidden
  80440. * Updates the camera based on device's frame data
  80441. */
  80442. _checkInputs(): void;
  80443. /**
  80444. * Updates the poseControlled values based on the input device pose.
  80445. * @param poseData Pose coming from the device
  80446. */
  80447. updateFromDevice(poseData: DevicePose): void;
  80448. private _htmlElementAttached;
  80449. private _detachIfAttached;
  80450. /**
  80451. * WebVR's attach control will start broadcasting frames to the device.
  80452. * Note that in certain browsers (chrome for example) this function must be called
  80453. * within a user-interaction callback. Example:
  80454. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80455. *
  80456. * @param element html element to attach the vrDevice to
  80457. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80458. */
  80459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80460. /**
  80461. * Detaches the camera from the html element and disables VR
  80462. *
  80463. * @param element html element to detach from
  80464. */
  80465. detachControl(element: HTMLElement): void;
  80466. /**
  80467. * @returns the name of this class
  80468. */
  80469. getClassName(): string;
  80470. /**
  80471. * Calls resetPose on the vrDisplay
  80472. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80473. */
  80474. resetToCurrentRotation(): void;
  80475. /**
  80476. * @hidden
  80477. * Updates the rig cameras (left and right eye)
  80478. */
  80479. _updateRigCameras(): void;
  80480. private _workingVector;
  80481. private _oneVector;
  80482. private _workingMatrix;
  80483. private updateCacheCalled;
  80484. private _correctPositionIfNotTrackPosition;
  80485. /**
  80486. * @hidden
  80487. * Updates the cached values of the camera
  80488. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80489. */
  80490. _updateCache(ignoreParentClass?: boolean): void;
  80491. /**
  80492. * @hidden
  80493. * Get current device position in babylon world
  80494. */
  80495. _computeDevicePosition(): void;
  80496. /**
  80497. * Updates the current device position and rotation in the babylon world
  80498. */
  80499. update(): void;
  80500. /**
  80501. * @hidden
  80502. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80503. * @returns an identity matrix
  80504. */
  80505. _getViewMatrix(): Matrix;
  80506. private _tmpMatrix;
  80507. /**
  80508. * This function is called by the two RIG cameras.
  80509. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80510. * @hidden
  80511. */
  80512. _getWebVRViewMatrix(): Matrix;
  80513. /** @hidden */
  80514. _getWebVRProjectionMatrix(): Matrix;
  80515. private _onGamepadConnectedObserver;
  80516. private _onGamepadDisconnectedObserver;
  80517. private _updateCacheWhenTrackingDisabledObserver;
  80518. /**
  80519. * Initializes the controllers and their meshes
  80520. */
  80521. initControllers(): void;
  80522. }
  80523. }
  80524. declare module BABYLON {
  80525. /**
  80526. * Size options for a post process
  80527. */
  80528. export type PostProcessOptions = {
  80529. width: number;
  80530. height: number;
  80531. };
  80532. /**
  80533. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80534. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80535. */
  80536. export class PostProcess {
  80537. /** Name of the PostProcess. */
  80538. name: string;
  80539. /**
  80540. * Gets or sets the unique id of the post process
  80541. */
  80542. uniqueId: number;
  80543. /**
  80544. * Width of the texture to apply the post process on
  80545. */
  80546. width: number;
  80547. /**
  80548. * Height of the texture to apply the post process on
  80549. */
  80550. height: number;
  80551. /**
  80552. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80553. * @hidden
  80554. */
  80555. _outputTexture: Nullable<InternalTexture>;
  80556. /**
  80557. * Sampling mode used by the shader
  80558. * See https://doc.babylonjs.com/classes/3.1/texture
  80559. */
  80560. renderTargetSamplingMode: number;
  80561. /**
  80562. * Clear color to use when screen clearing
  80563. */
  80564. clearColor: Color4;
  80565. /**
  80566. * If the buffer needs to be cleared before applying the post process. (default: true)
  80567. * Should be set to false if shader will overwrite all previous pixels.
  80568. */
  80569. autoClear: boolean;
  80570. /**
  80571. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80572. */
  80573. alphaMode: number;
  80574. /**
  80575. * Sets the setAlphaBlendConstants of the babylon engine
  80576. */
  80577. alphaConstants: Color4;
  80578. /**
  80579. * Animations to be used for the post processing
  80580. */
  80581. animations: Animation[];
  80582. /**
  80583. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80584. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80585. */
  80586. enablePixelPerfectMode: boolean;
  80587. /**
  80588. * Force the postprocess to be applied without taking in account viewport
  80589. */
  80590. forceFullscreenViewport: boolean;
  80591. /**
  80592. * List of inspectable custom properties (used by the Inspector)
  80593. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80594. */
  80595. inspectableCustomProperties: IInspectable[];
  80596. /**
  80597. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80598. *
  80599. * | Value | Type | Description |
  80600. * | ----- | ----------------------------------- | ----------- |
  80601. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80602. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80603. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80604. *
  80605. */
  80606. scaleMode: number;
  80607. /**
  80608. * Force textures to be a power of two (default: false)
  80609. */
  80610. alwaysForcePOT: boolean;
  80611. private _samples;
  80612. /**
  80613. * Number of sample textures (default: 1)
  80614. */
  80615. samples: number;
  80616. /**
  80617. * Modify the scale of the post process to be the same as the viewport (default: false)
  80618. */
  80619. adaptScaleToCurrentViewport: boolean;
  80620. private _camera;
  80621. private _scene;
  80622. private _engine;
  80623. private _options;
  80624. private _reusable;
  80625. private _textureType;
  80626. /**
  80627. * Smart array of input and output textures for the post process.
  80628. * @hidden
  80629. */
  80630. _textures: SmartArray<InternalTexture>;
  80631. /**
  80632. * The index in _textures that corresponds to the output texture.
  80633. * @hidden
  80634. */
  80635. _currentRenderTextureInd: number;
  80636. private _effect;
  80637. private _samplers;
  80638. private _fragmentUrl;
  80639. private _vertexUrl;
  80640. private _parameters;
  80641. private _scaleRatio;
  80642. protected _indexParameters: any;
  80643. private _shareOutputWithPostProcess;
  80644. private _texelSize;
  80645. private _forcedOutputTexture;
  80646. /**
  80647. * Returns the fragment url or shader name used in the post process.
  80648. * @returns the fragment url or name in the shader store.
  80649. */
  80650. getEffectName(): string;
  80651. /**
  80652. * An event triggered when the postprocess is activated.
  80653. */
  80654. onActivateObservable: Observable<Camera>;
  80655. private _onActivateObserver;
  80656. /**
  80657. * A function that is added to the onActivateObservable
  80658. */
  80659. onActivate: Nullable<(camera: Camera) => void>;
  80660. /**
  80661. * An event triggered when the postprocess changes its size.
  80662. */
  80663. onSizeChangedObservable: Observable<PostProcess>;
  80664. private _onSizeChangedObserver;
  80665. /**
  80666. * A function that is added to the onSizeChangedObservable
  80667. */
  80668. onSizeChanged: (postProcess: PostProcess) => void;
  80669. /**
  80670. * An event triggered when the postprocess applies its effect.
  80671. */
  80672. onApplyObservable: Observable<Effect>;
  80673. private _onApplyObserver;
  80674. /**
  80675. * A function that is added to the onApplyObservable
  80676. */
  80677. onApply: (effect: Effect) => void;
  80678. /**
  80679. * An event triggered before rendering the postprocess
  80680. */
  80681. onBeforeRenderObservable: Observable<Effect>;
  80682. private _onBeforeRenderObserver;
  80683. /**
  80684. * A function that is added to the onBeforeRenderObservable
  80685. */
  80686. onBeforeRender: (effect: Effect) => void;
  80687. /**
  80688. * An event triggered after rendering the postprocess
  80689. */
  80690. onAfterRenderObservable: Observable<Effect>;
  80691. private _onAfterRenderObserver;
  80692. /**
  80693. * A function that is added to the onAfterRenderObservable
  80694. */
  80695. onAfterRender: (efect: Effect) => void;
  80696. /**
  80697. * 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
  80698. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80699. */
  80700. inputTexture: InternalTexture;
  80701. /**
  80702. * Gets the camera which post process is applied to.
  80703. * @returns The camera the post process is applied to.
  80704. */
  80705. getCamera(): Camera;
  80706. /**
  80707. * Gets the texel size of the postprocess.
  80708. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80709. */
  80710. readonly texelSize: Vector2;
  80711. /**
  80712. * Creates a new instance PostProcess
  80713. * @param name The name of the PostProcess.
  80714. * @param fragmentUrl The url of the fragment shader to be used.
  80715. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80716. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80717. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80718. * @param camera The camera to apply the render pass to.
  80719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80720. * @param engine The engine which the post process will be applied. (default: current engine)
  80721. * @param reusable If the post process can be reused on the same frame. (default: false)
  80722. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80723. * @param textureType Type of textures used when performing the post process. (default: 0)
  80724. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80725. * @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
  80726. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80727. */
  80728. constructor(
  80729. /** Name of the PostProcess. */
  80730. 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);
  80731. /**
  80732. * Gets a string idenfifying the name of the class
  80733. * @returns "PostProcess" string
  80734. */
  80735. getClassName(): string;
  80736. /**
  80737. * Gets the engine which this post process belongs to.
  80738. * @returns The engine the post process was enabled with.
  80739. */
  80740. getEngine(): Engine;
  80741. /**
  80742. * The effect that is created when initializing the post process.
  80743. * @returns The created effect corresponding the the postprocess.
  80744. */
  80745. getEffect(): Effect;
  80746. /**
  80747. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80748. * @param postProcess The post process to share the output with.
  80749. * @returns This post process.
  80750. */
  80751. shareOutputWith(postProcess: PostProcess): PostProcess;
  80752. /**
  80753. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80754. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80755. */
  80756. useOwnOutput(): void;
  80757. /**
  80758. * Updates the effect with the current post process compile time values and recompiles the shader.
  80759. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80760. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80761. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80762. * @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
  80763. * @param onCompiled Called when the shader has been compiled.
  80764. * @param onError Called if there is an error when compiling a shader.
  80765. */
  80766. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80767. /**
  80768. * The post process is reusable if it can be used multiple times within one frame.
  80769. * @returns If the post process is reusable
  80770. */
  80771. isReusable(): boolean;
  80772. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80773. markTextureDirty(): void;
  80774. /**
  80775. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80776. * 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.
  80777. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80778. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80779. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80780. * @returns The target texture that was bound to be written to.
  80781. */
  80782. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80783. /**
  80784. * If the post process is supported.
  80785. */
  80786. readonly isSupported: boolean;
  80787. /**
  80788. * The aspect ratio of the output texture.
  80789. */
  80790. readonly aspectRatio: number;
  80791. /**
  80792. * Get a value indicating if the post-process is ready to be used
  80793. * @returns true if the post-process is ready (shader is compiled)
  80794. */
  80795. isReady(): boolean;
  80796. /**
  80797. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80798. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80799. */
  80800. apply(): Nullable<Effect>;
  80801. private _disposeTextures;
  80802. /**
  80803. * Disposes the post process.
  80804. * @param camera The camera to dispose the post process on.
  80805. */
  80806. dispose(camera?: Camera): void;
  80807. }
  80808. }
  80809. declare module BABYLON {
  80810. /** @hidden */
  80811. export var kernelBlurVaryingDeclaration: {
  80812. name: string;
  80813. shader: string;
  80814. };
  80815. }
  80816. declare module BABYLON {
  80817. /** @hidden */
  80818. export var kernelBlurFragment: {
  80819. name: string;
  80820. shader: string;
  80821. };
  80822. }
  80823. declare module BABYLON {
  80824. /** @hidden */
  80825. export var kernelBlurFragment2: {
  80826. name: string;
  80827. shader: string;
  80828. };
  80829. }
  80830. declare module BABYLON {
  80831. /** @hidden */
  80832. export var kernelBlurPixelShader: {
  80833. name: string;
  80834. shader: string;
  80835. };
  80836. }
  80837. declare module BABYLON {
  80838. /** @hidden */
  80839. export var kernelBlurVertex: {
  80840. name: string;
  80841. shader: string;
  80842. };
  80843. }
  80844. declare module BABYLON {
  80845. /** @hidden */
  80846. export var kernelBlurVertexShader: {
  80847. name: string;
  80848. shader: string;
  80849. };
  80850. }
  80851. declare module BABYLON {
  80852. /**
  80853. * The Blur Post Process which blurs an image based on a kernel and direction.
  80854. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80855. */
  80856. export class BlurPostProcess extends PostProcess {
  80857. /** The direction in which to blur the image. */
  80858. direction: Vector2;
  80859. private blockCompilation;
  80860. protected _kernel: number;
  80861. protected _idealKernel: number;
  80862. protected _packedFloat: boolean;
  80863. private _staticDefines;
  80864. /**
  80865. * Sets the length in pixels of the blur sample region
  80866. */
  80867. /**
  80868. * Gets the length in pixels of the blur sample region
  80869. */
  80870. kernel: number;
  80871. /**
  80872. * Sets wether or not the blur needs to unpack/repack floats
  80873. */
  80874. /**
  80875. * Gets wether or not the blur is unpacking/repacking floats
  80876. */
  80877. packedFloat: boolean;
  80878. /**
  80879. * Creates a new instance BlurPostProcess
  80880. * @param name The name of the effect.
  80881. * @param direction The direction in which to blur the image.
  80882. * @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.
  80883. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80884. * @param camera The camera to apply the render pass to.
  80885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80886. * @param engine The engine which the post process will be applied. (default: current engine)
  80887. * @param reusable If the post process can be reused on the same frame. (default: false)
  80888. * @param textureType Type of textures used when performing the post process. (default: 0)
  80889. * @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)
  80890. */
  80891. constructor(name: string,
  80892. /** The direction in which to blur the image. */
  80893. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80894. /**
  80895. * Updates the effect with the current post process compile time values and recompiles the shader.
  80896. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80897. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80898. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80899. * @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
  80900. * @param onCompiled Called when the shader has been compiled.
  80901. * @param onError Called if there is an error when compiling a shader.
  80902. */
  80903. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80904. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80905. /**
  80906. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80907. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80908. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80909. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80910. * The gaps between physical kernels are compensated for in the weighting of the samples
  80911. * @param idealKernel Ideal blur kernel.
  80912. * @return Nearest best kernel.
  80913. */
  80914. protected _nearestBestKernel(idealKernel: number): number;
  80915. /**
  80916. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80917. * @param x The point on the Gaussian distribution to sample.
  80918. * @return the value of the Gaussian function at x.
  80919. */
  80920. protected _gaussianWeight(x: number): number;
  80921. /**
  80922. * Generates a string that can be used as a floating point number in GLSL.
  80923. * @param x Value to print.
  80924. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80925. * @return GLSL float string.
  80926. */
  80927. protected _glslFloat(x: number, decimalFigures?: number): string;
  80928. }
  80929. }
  80930. declare module BABYLON {
  80931. /**
  80932. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80933. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80934. * You can then easily use it as a reflectionTexture on a flat surface.
  80935. * In case the surface is not a plane, please consider relying on reflection probes.
  80936. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80937. */
  80938. export class MirrorTexture extends RenderTargetTexture {
  80939. private scene;
  80940. /**
  80941. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80942. * 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.
  80943. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80944. */
  80945. mirrorPlane: Plane;
  80946. /**
  80947. * Define the blur ratio used to blur the reflection if needed.
  80948. */
  80949. blurRatio: number;
  80950. /**
  80951. * Define the adaptive blur kernel used to blur the reflection if needed.
  80952. * This will autocompute the closest best match for the `blurKernel`
  80953. */
  80954. adaptiveBlurKernel: number;
  80955. /**
  80956. * Define the blur kernel used to blur the reflection if needed.
  80957. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80958. */
  80959. blurKernel: number;
  80960. /**
  80961. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80962. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80963. */
  80964. blurKernelX: number;
  80965. /**
  80966. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80967. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80968. */
  80969. blurKernelY: number;
  80970. private _autoComputeBlurKernel;
  80971. protected _onRatioRescale(): void;
  80972. private _updateGammaSpace;
  80973. private _imageProcessingConfigChangeObserver;
  80974. private _transformMatrix;
  80975. private _mirrorMatrix;
  80976. private _savedViewMatrix;
  80977. private _blurX;
  80978. private _blurY;
  80979. private _adaptiveBlurKernel;
  80980. private _blurKernelX;
  80981. private _blurKernelY;
  80982. private _blurRatio;
  80983. /**
  80984. * Instantiates a Mirror Texture.
  80985. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80986. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80987. * You can then easily use it as a reflectionTexture on a flat surface.
  80988. * In case the surface is not a plane, please consider relying on reflection probes.
  80989. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80990. * @param name
  80991. * @param size
  80992. * @param scene
  80993. * @param generateMipMaps
  80994. * @param type
  80995. * @param samplingMode
  80996. * @param generateDepthBuffer
  80997. */
  80998. constructor(name: string, size: number | {
  80999. width: number;
  81000. height: number;
  81001. } | {
  81002. ratio: number;
  81003. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81004. private _preparePostProcesses;
  81005. /**
  81006. * Clone the mirror texture.
  81007. * @returns the cloned texture
  81008. */
  81009. clone(): MirrorTexture;
  81010. /**
  81011. * Serialize the texture to a JSON representation you could use in Parse later on
  81012. * @returns the serialized JSON representation
  81013. */
  81014. serialize(): any;
  81015. /**
  81016. * Dispose the texture and release its associated resources.
  81017. */
  81018. dispose(): void;
  81019. }
  81020. }
  81021. declare module BABYLON {
  81022. /**
  81023. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81024. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81025. */
  81026. export class Texture extends BaseTexture {
  81027. /** @hidden */
  81028. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81029. /** @hidden */
  81030. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81031. /** @hidden */
  81032. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81033. /** nearest is mag = nearest and min = nearest and mip = linear */
  81034. static readonly NEAREST_SAMPLINGMODE: number;
  81035. /** nearest is mag = nearest and min = nearest and mip = linear */
  81036. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81038. static readonly BILINEAR_SAMPLINGMODE: number;
  81039. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81040. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81041. /** Trilinear is mag = linear and min = linear and mip = linear */
  81042. static readonly TRILINEAR_SAMPLINGMODE: number;
  81043. /** Trilinear is mag = linear and min = linear and mip = linear */
  81044. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81045. /** mag = nearest and min = nearest and mip = nearest */
  81046. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81047. /** mag = nearest and min = linear and mip = nearest */
  81048. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81049. /** mag = nearest and min = linear and mip = linear */
  81050. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81051. /** mag = nearest and min = linear and mip = none */
  81052. static readonly NEAREST_LINEAR: number;
  81053. /** mag = nearest and min = nearest and mip = none */
  81054. static readonly NEAREST_NEAREST: number;
  81055. /** mag = linear and min = nearest and mip = nearest */
  81056. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81057. /** mag = linear and min = nearest and mip = linear */
  81058. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81059. /** mag = linear and min = linear and mip = none */
  81060. static readonly LINEAR_LINEAR: number;
  81061. /** mag = linear and min = nearest and mip = none */
  81062. static readonly LINEAR_NEAREST: number;
  81063. /** Explicit coordinates mode */
  81064. static readonly EXPLICIT_MODE: number;
  81065. /** Spherical coordinates mode */
  81066. static readonly SPHERICAL_MODE: number;
  81067. /** Planar coordinates mode */
  81068. static readonly PLANAR_MODE: number;
  81069. /** Cubic coordinates mode */
  81070. static readonly CUBIC_MODE: number;
  81071. /** Projection coordinates mode */
  81072. static readonly PROJECTION_MODE: number;
  81073. /** Inverse Cubic coordinates mode */
  81074. static readonly SKYBOX_MODE: number;
  81075. /** Inverse Cubic coordinates mode */
  81076. static readonly INVCUBIC_MODE: number;
  81077. /** Equirectangular coordinates mode */
  81078. static readonly EQUIRECTANGULAR_MODE: number;
  81079. /** Equirectangular Fixed coordinates mode */
  81080. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81081. /** Equirectangular Fixed Mirrored coordinates mode */
  81082. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81083. /** Texture is not repeating outside of 0..1 UVs */
  81084. static readonly CLAMP_ADDRESSMODE: number;
  81085. /** Texture is repeating outside of 0..1 UVs */
  81086. static readonly WRAP_ADDRESSMODE: number;
  81087. /** Texture is repeating and mirrored */
  81088. static readonly MIRROR_ADDRESSMODE: number;
  81089. /**
  81090. * 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
  81091. */
  81092. static UseSerializedUrlIfAny: boolean;
  81093. /**
  81094. * Define the url of the texture.
  81095. */
  81096. url: Nullable<string>;
  81097. /**
  81098. * Define an offset on the texture to offset the u coordinates of the UVs
  81099. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81100. */
  81101. uOffset: number;
  81102. /**
  81103. * Define an offset on the texture to offset the v coordinates of the UVs
  81104. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81105. */
  81106. vOffset: number;
  81107. /**
  81108. * Define an offset on the texture to scale the u coordinates of the UVs
  81109. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81110. */
  81111. uScale: number;
  81112. /**
  81113. * Define an offset on the texture to scale the v coordinates of the UVs
  81114. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81115. */
  81116. vScale: number;
  81117. /**
  81118. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81119. * @see http://doc.babylonjs.com/how_to/more_materials
  81120. */
  81121. uAng: number;
  81122. /**
  81123. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81124. * @see http://doc.babylonjs.com/how_to/more_materials
  81125. */
  81126. vAng: number;
  81127. /**
  81128. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81129. * @see http://doc.babylonjs.com/how_to/more_materials
  81130. */
  81131. wAng: number;
  81132. /**
  81133. * Defines the center of rotation (U)
  81134. */
  81135. uRotationCenter: number;
  81136. /**
  81137. * Defines the center of rotation (V)
  81138. */
  81139. vRotationCenter: number;
  81140. /**
  81141. * Defines the center of rotation (W)
  81142. */
  81143. wRotationCenter: number;
  81144. /**
  81145. * Are mip maps generated for this texture or not.
  81146. */
  81147. readonly noMipmap: boolean;
  81148. /**
  81149. * List of inspectable custom properties (used by the Inspector)
  81150. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81151. */
  81152. inspectableCustomProperties: Nullable<IInspectable[]>;
  81153. private _noMipmap;
  81154. /** @hidden */
  81155. _invertY: boolean;
  81156. private _rowGenerationMatrix;
  81157. private _cachedTextureMatrix;
  81158. private _projectionModeMatrix;
  81159. private _t0;
  81160. private _t1;
  81161. private _t2;
  81162. private _cachedUOffset;
  81163. private _cachedVOffset;
  81164. private _cachedUScale;
  81165. private _cachedVScale;
  81166. private _cachedUAng;
  81167. private _cachedVAng;
  81168. private _cachedWAng;
  81169. private _cachedProjectionMatrixId;
  81170. private _cachedCoordinatesMode;
  81171. /** @hidden */
  81172. protected _initialSamplingMode: number;
  81173. /** @hidden */
  81174. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81175. private _deleteBuffer;
  81176. protected _format: Nullable<number>;
  81177. private _delayedOnLoad;
  81178. private _delayedOnError;
  81179. /**
  81180. * Observable triggered once the texture has been loaded.
  81181. */
  81182. onLoadObservable: Observable<Texture>;
  81183. protected _isBlocking: boolean;
  81184. /**
  81185. * Is the texture preventing material to render while loading.
  81186. * If false, a default texture will be used instead of the loading one during the preparation step.
  81187. */
  81188. isBlocking: boolean;
  81189. /**
  81190. * Get the current sampling mode associated with the texture.
  81191. */
  81192. readonly samplingMode: number;
  81193. /**
  81194. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81195. */
  81196. readonly invertY: boolean;
  81197. /**
  81198. * Instantiates a new texture.
  81199. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81200. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81201. * @param url define the url of the picture to load as a texture
  81202. * @param scene define the scene or engine the texture will belong to
  81203. * @param noMipmap define if the texture will require mip maps or not
  81204. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81205. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81206. * @param onLoad define a callback triggered when the texture has been loaded
  81207. * @param onError define a callback triggered when an error occurred during the loading session
  81208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81209. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81210. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81211. */
  81212. 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);
  81213. /**
  81214. * Update the url (and optional buffer) of this texture if url was null during construction.
  81215. * @param url the url of the texture
  81216. * @param buffer the buffer of the texture (defaults to null)
  81217. * @param onLoad callback called when the texture is loaded (defaults to null)
  81218. */
  81219. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81220. /**
  81221. * Finish the loading sequence of a texture flagged as delayed load.
  81222. * @hidden
  81223. */
  81224. delayLoad(): void;
  81225. private _prepareRowForTextureGeneration;
  81226. /**
  81227. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81228. * @returns the transform matrix of the texture.
  81229. */
  81230. getTextureMatrix(): Matrix;
  81231. /**
  81232. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81233. * @returns The reflection texture transform
  81234. */
  81235. getReflectionTextureMatrix(): Matrix;
  81236. /**
  81237. * Clones the texture.
  81238. * @returns the cloned texture
  81239. */
  81240. clone(): Texture;
  81241. /**
  81242. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81243. * @returns The JSON representation of the texture
  81244. */
  81245. serialize(): any;
  81246. /**
  81247. * Get the current class name of the texture useful for serialization or dynamic coding.
  81248. * @returns "Texture"
  81249. */
  81250. getClassName(): string;
  81251. /**
  81252. * Dispose the texture and release its associated resources.
  81253. */
  81254. dispose(): void;
  81255. /**
  81256. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81257. * @param parsedTexture Define the JSON representation of the texture
  81258. * @param scene Define the scene the parsed texture should be instantiated in
  81259. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81260. * @returns The parsed texture if successful
  81261. */
  81262. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81263. /**
  81264. * Creates a texture from its base 64 representation.
  81265. * @param data Define the base64 payload without the data: prefix
  81266. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81267. * @param scene Define the scene the texture should belong to
  81268. * @param noMipmap Forces the texture to not create mip map information if true
  81269. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81270. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81271. * @param onLoad define a callback triggered when the texture has been loaded
  81272. * @param onError define a callback triggered when an error occurred during the loading session
  81273. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81274. * @returns the created texture
  81275. */
  81276. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81277. /**
  81278. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81279. * @param data Define the base64 payload without the data: prefix
  81280. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81281. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81282. * @param scene Define the scene the texture should belong to
  81283. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81284. * @param noMipmap Forces the texture to not create mip map information if true
  81285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81287. * @param onLoad define a callback triggered when the texture has been loaded
  81288. * @param onError define a callback triggered when an error occurred during the loading session
  81289. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81290. * @returns the created texture
  81291. */
  81292. 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;
  81293. }
  81294. }
  81295. declare module BABYLON {
  81296. /**
  81297. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81298. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81299. */
  81300. export class PostProcessManager {
  81301. private _scene;
  81302. private _indexBuffer;
  81303. private _vertexBuffers;
  81304. /**
  81305. * Creates a new instance PostProcess
  81306. * @param scene The scene that the post process is associated with.
  81307. */
  81308. constructor(scene: Scene);
  81309. private _prepareBuffers;
  81310. private _buildIndexBuffer;
  81311. /**
  81312. * Rebuilds the vertex buffers of the manager.
  81313. * @hidden
  81314. */
  81315. _rebuild(): void;
  81316. /**
  81317. * Prepares a frame to be run through a post process.
  81318. * @param sourceTexture The input texture to the post procesess. (default: null)
  81319. * @param postProcesses An array of post processes to be run. (default: null)
  81320. * @returns True if the post processes were able to be run.
  81321. * @hidden
  81322. */
  81323. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81324. /**
  81325. * Manually render a set of post processes to a texture.
  81326. * @param postProcesses An array of post processes to be run.
  81327. * @param targetTexture The target texture to render to.
  81328. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81329. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81330. * @param lodLevel defines which lod of the texture to render to
  81331. */
  81332. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81333. /**
  81334. * Finalize the result of the output of the postprocesses.
  81335. * @param doNotPresent If true the result will not be displayed to the screen.
  81336. * @param targetTexture The target texture to render to.
  81337. * @param faceIndex The index of the face to bind the target texture to.
  81338. * @param postProcesses The array of post processes to render.
  81339. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81340. * @hidden
  81341. */
  81342. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81343. /**
  81344. * Disposes of the post process manager.
  81345. */
  81346. dispose(): void;
  81347. }
  81348. }
  81349. declare module BABYLON {
  81350. interface AbstractScene {
  81351. /**
  81352. * The list of procedural textures added to the scene
  81353. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81354. */
  81355. proceduralTextures: Array<ProceduralTexture>;
  81356. }
  81357. /**
  81358. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81359. * in a given scene.
  81360. */
  81361. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81362. /**
  81363. * The component name helpfull to identify the component in the list of scene components.
  81364. */
  81365. readonly name: string;
  81366. /**
  81367. * The scene the component belongs to.
  81368. */
  81369. scene: Scene;
  81370. /**
  81371. * Creates a new instance of the component for the given scene
  81372. * @param scene Defines the scene to register the component in
  81373. */
  81374. constructor(scene: Scene);
  81375. /**
  81376. * Registers the component in a given scene
  81377. */
  81378. register(): void;
  81379. /**
  81380. * Rebuilds the elements related to this component in case of
  81381. * context lost for instance.
  81382. */
  81383. rebuild(): void;
  81384. /**
  81385. * Disposes the component and the associated ressources.
  81386. */
  81387. dispose(): void;
  81388. private _beforeClear;
  81389. }
  81390. }
  81391. declare module BABYLON {
  81392. interface Engine {
  81393. /**
  81394. * Creates a new render target cube texture
  81395. * @param size defines the size of the texture
  81396. * @param options defines the options used to create the texture
  81397. * @returns a new render target cube texture stored in an InternalTexture
  81398. */
  81399. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81400. }
  81401. }
  81402. declare module BABYLON {
  81403. /** @hidden */
  81404. export var proceduralVertexShader: {
  81405. name: string;
  81406. shader: string;
  81407. };
  81408. }
  81409. declare module BABYLON {
  81410. /**
  81411. * 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.
  81412. * This is the base class of any Procedural texture and contains most of the shareable code.
  81413. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81414. */
  81415. export class ProceduralTexture extends Texture {
  81416. isCube: boolean;
  81417. /**
  81418. * Define if the texture is enabled or not (disabled texture will not render)
  81419. */
  81420. isEnabled: boolean;
  81421. /**
  81422. * Define if the texture must be cleared before rendering (default is true)
  81423. */
  81424. autoClear: boolean;
  81425. /**
  81426. * Callback called when the texture is generated
  81427. */
  81428. onGenerated: () => void;
  81429. /**
  81430. * Event raised when the texture is generated
  81431. */
  81432. onGeneratedObservable: Observable<ProceduralTexture>;
  81433. /** @hidden */
  81434. _generateMipMaps: boolean;
  81435. /** @hidden **/
  81436. _effect: Effect;
  81437. /** @hidden */
  81438. _textures: {
  81439. [key: string]: Texture;
  81440. };
  81441. private _size;
  81442. private _currentRefreshId;
  81443. private _refreshRate;
  81444. private _vertexBuffers;
  81445. private _indexBuffer;
  81446. private _uniforms;
  81447. private _samplers;
  81448. private _fragment;
  81449. private _floats;
  81450. private _ints;
  81451. private _floatsArrays;
  81452. private _colors3;
  81453. private _colors4;
  81454. private _vectors2;
  81455. private _vectors3;
  81456. private _matrices;
  81457. private _fallbackTexture;
  81458. private _fallbackTextureUsed;
  81459. private _engine;
  81460. private _cachedDefines;
  81461. private _contentUpdateId;
  81462. private _contentData;
  81463. /**
  81464. * Instantiates a new procedural texture.
  81465. * 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.
  81466. * This is the base class of any Procedural texture and contains most of the shareable code.
  81467. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81468. * @param name Define the name of the texture
  81469. * @param size Define the size of the texture to create
  81470. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81471. * @param scene Define the scene the texture belongs to
  81472. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81473. * @param generateMipMaps Define if the texture should creates mip maps or not
  81474. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81475. */
  81476. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81477. /**
  81478. * The effect that is created when initializing the post process.
  81479. * @returns The created effect corresponding the the postprocess.
  81480. */
  81481. getEffect(): Effect;
  81482. /**
  81483. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81484. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81485. */
  81486. getContent(): Nullable<ArrayBufferView>;
  81487. private _createIndexBuffer;
  81488. /** @hidden */
  81489. _rebuild(): void;
  81490. /**
  81491. * Resets the texture in order to recreate its associated resources.
  81492. * This can be called in case of context loss
  81493. */
  81494. reset(): void;
  81495. protected _getDefines(): string;
  81496. /**
  81497. * Is the texture ready to be used ? (rendered at least once)
  81498. * @returns true if ready, otherwise, false.
  81499. */
  81500. isReady(): boolean;
  81501. /**
  81502. * Resets the refresh counter of the texture and start bak from scratch.
  81503. * Could be useful to regenerate the texture if it is setup to render only once.
  81504. */
  81505. resetRefreshCounter(): void;
  81506. /**
  81507. * Set the fragment shader to use in order to render the texture.
  81508. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81509. */
  81510. setFragment(fragment: any): void;
  81511. /**
  81512. * Define the refresh rate of the texture or the rendering frequency.
  81513. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81514. */
  81515. refreshRate: number;
  81516. /** @hidden */
  81517. _shouldRender(): boolean;
  81518. /**
  81519. * Get the size the texture is rendering at.
  81520. * @returns the size (texture is always squared)
  81521. */
  81522. getRenderSize(): number;
  81523. /**
  81524. * Resize the texture to new value.
  81525. * @param size Define the new size the texture should have
  81526. * @param generateMipMaps Define whether the new texture should create mip maps
  81527. */
  81528. resize(size: number, generateMipMaps: boolean): void;
  81529. private _checkUniform;
  81530. /**
  81531. * Set a texture in the shader program used to render.
  81532. * @param name Define the name of the uniform samplers as defined in the shader
  81533. * @param texture Define the texture to bind to this sampler
  81534. * @return the texture itself allowing "fluent" like uniform updates
  81535. */
  81536. setTexture(name: string, texture: Texture): ProceduralTexture;
  81537. /**
  81538. * Set a float in the shader.
  81539. * @param name Define the name of the uniform as defined in the shader
  81540. * @param value Define the value to give to the uniform
  81541. * @return the texture itself allowing "fluent" like uniform updates
  81542. */
  81543. setFloat(name: string, value: number): ProceduralTexture;
  81544. /**
  81545. * Set a int in the shader.
  81546. * @param name Define the name of the uniform as defined in the shader
  81547. * @param value Define the value to give to the uniform
  81548. * @return the texture itself allowing "fluent" like uniform updates
  81549. */
  81550. setInt(name: string, value: number): ProceduralTexture;
  81551. /**
  81552. * Set an array of floats in the shader.
  81553. * @param name Define the name of the uniform as defined in the shader
  81554. * @param value Define the value to give to the uniform
  81555. * @return the texture itself allowing "fluent" like uniform updates
  81556. */
  81557. setFloats(name: string, value: number[]): ProceduralTexture;
  81558. /**
  81559. * Set a vec3 in the shader from a Color3.
  81560. * @param name Define the name of the uniform as defined in the shader
  81561. * @param value Define the value to give to the uniform
  81562. * @return the texture itself allowing "fluent" like uniform updates
  81563. */
  81564. setColor3(name: string, value: Color3): ProceduralTexture;
  81565. /**
  81566. * Set a vec4 in the shader from a Color4.
  81567. * @param name Define the name of the uniform as defined in the shader
  81568. * @param value Define the value to give to the uniform
  81569. * @return the texture itself allowing "fluent" like uniform updates
  81570. */
  81571. setColor4(name: string, value: Color4): ProceduralTexture;
  81572. /**
  81573. * Set a vec2 in the shader from a Vector2.
  81574. * @param name Define the name of the uniform as defined in the shader
  81575. * @param value Define the value to give to the uniform
  81576. * @return the texture itself allowing "fluent" like uniform updates
  81577. */
  81578. setVector2(name: string, value: Vector2): ProceduralTexture;
  81579. /**
  81580. * Set a vec3 in the shader from a Vector3.
  81581. * @param name Define the name of the uniform as defined in the shader
  81582. * @param value Define the value to give to the uniform
  81583. * @return the texture itself allowing "fluent" like uniform updates
  81584. */
  81585. setVector3(name: string, value: Vector3): ProceduralTexture;
  81586. /**
  81587. * Set a mat4 in the shader from a MAtrix.
  81588. * @param name Define the name of the uniform as defined in the shader
  81589. * @param value Define the value to give to the uniform
  81590. * @return the texture itself allowing "fluent" like uniform updates
  81591. */
  81592. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81593. /**
  81594. * Render the texture to its associated render target.
  81595. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81596. */
  81597. render(useCameraPostProcess?: boolean): void;
  81598. /**
  81599. * Clone the texture.
  81600. * @returns the cloned texture
  81601. */
  81602. clone(): ProceduralTexture;
  81603. /**
  81604. * Dispose the texture and release its asoociated resources.
  81605. */
  81606. dispose(): void;
  81607. }
  81608. }
  81609. declare module BABYLON {
  81610. /**
  81611. * This represents the base class for particle system in Babylon.
  81612. * 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.
  81613. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81614. * @example https://doc.babylonjs.com/babylon101/particles
  81615. */
  81616. export class BaseParticleSystem {
  81617. /**
  81618. * Source color is added to the destination color without alpha affecting the result
  81619. */
  81620. static BLENDMODE_ONEONE: number;
  81621. /**
  81622. * Blend current color and particle color using particle’s alpha
  81623. */
  81624. static BLENDMODE_STANDARD: number;
  81625. /**
  81626. * Add current color and particle color multiplied by particle’s alpha
  81627. */
  81628. static BLENDMODE_ADD: number;
  81629. /**
  81630. * Multiply current color with particle color
  81631. */
  81632. static BLENDMODE_MULTIPLY: number;
  81633. /**
  81634. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81635. */
  81636. static BLENDMODE_MULTIPLYADD: number;
  81637. /**
  81638. * List of animations used by the particle system.
  81639. */
  81640. animations: Animation[];
  81641. /**
  81642. * The id of the Particle system.
  81643. */
  81644. id: string;
  81645. /**
  81646. * The friendly name of the Particle system.
  81647. */
  81648. name: string;
  81649. /**
  81650. * The rendering group used by the Particle system to chose when to render.
  81651. */
  81652. renderingGroupId: number;
  81653. /**
  81654. * The emitter represents the Mesh or position we are attaching the particle system to.
  81655. */
  81656. emitter: Nullable<AbstractMesh | Vector3>;
  81657. /**
  81658. * The maximum number of particles to emit per frame
  81659. */
  81660. emitRate: number;
  81661. /**
  81662. * If you want to launch only a few particles at once, that can be done, as well.
  81663. */
  81664. manualEmitCount: number;
  81665. /**
  81666. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81667. */
  81668. updateSpeed: number;
  81669. /**
  81670. * The amount of time the particle system is running (depends of the overall update speed).
  81671. */
  81672. targetStopDuration: number;
  81673. /**
  81674. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81675. */
  81676. disposeOnStop: boolean;
  81677. /**
  81678. * Minimum power of emitting particles.
  81679. */
  81680. minEmitPower: number;
  81681. /**
  81682. * Maximum power of emitting particles.
  81683. */
  81684. maxEmitPower: number;
  81685. /**
  81686. * Minimum life time of emitting particles.
  81687. */
  81688. minLifeTime: number;
  81689. /**
  81690. * Maximum life time of emitting particles.
  81691. */
  81692. maxLifeTime: number;
  81693. /**
  81694. * Minimum Size of emitting particles.
  81695. */
  81696. minSize: number;
  81697. /**
  81698. * Maximum Size of emitting particles.
  81699. */
  81700. maxSize: number;
  81701. /**
  81702. * Minimum scale of emitting particles on X axis.
  81703. */
  81704. minScaleX: number;
  81705. /**
  81706. * Maximum scale of emitting particles on X axis.
  81707. */
  81708. maxScaleX: number;
  81709. /**
  81710. * Minimum scale of emitting particles on Y axis.
  81711. */
  81712. minScaleY: number;
  81713. /**
  81714. * Maximum scale of emitting particles on Y axis.
  81715. */
  81716. maxScaleY: number;
  81717. /**
  81718. * Gets or sets the minimal initial rotation in radians.
  81719. */
  81720. minInitialRotation: number;
  81721. /**
  81722. * Gets or sets the maximal initial rotation in radians.
  81723. */
  81724. maxInitialRotation: number;
  81725. /**
  81726. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81727. */
  81728. minAngularSpeed: number;
  81729. /**
  81730. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81731. */
  81732. maxAngularSpeed: number;
  81733. /**
  81734. * The texture used to render each particle. (this can be a spritesheet)
  81735. */
  81736. particleTexture: Nullable<Texture>;
  81737. /**
  81738. * The layer mask we are rendering the particles through.
  81739. */
  81740. layerMask: number;
  81741. /**
  81742. * This can help using your own shader to render the particle system.
  81743. * The according effect will be created
  81744. */
  81745. customShader: any;
  81746. /**
  81747. * By default particle system starts as soon as they are created. This prevents the
  81748. * automatic start to happen and let you decide when to start emitting particles.
  81749. */
  81750. preventAutoStart: boolean;
  81751. private _noiseTexture;
  81752. /**
  81753. * Gets or sets a texture used to add random noise to particle positions
  81754. */
  81755. noiseTexture: Nullable<ProceduralTexture>;
  81756. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81757. noiseStrength: Vector3;
  81758. /**
  81759. * Callback triggered when the particle animation is ending.
  81760. */
  81761. onAnimationEnd: Nullable<() => void>;
  81762. /**
  81763. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81764. */
  81765. blendMode: number;
  81766. /**
  81767. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81768. * to override the particles.
  81769. */
  81770. forceDepthWrite: boolean;
  81771. /** 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 */
  81772. preWarmCycles: number;
  81773. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81774. preWarmStepOffset: number;
  81775. /**
  81776. * 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)
  81777. */
  81778. spriteCellChangeSpeed: number;
  81779. /**
  81780. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81781. */
  81782. startSpriteCellID: number;
  81783. /**
  81784. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81785. */
  81786. endSpriteCellID: number;
  81787. /**
  81788. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81789. */
  81790. spriteCellWidth: number;
  81791. /**
  81792. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81793. */
  81794. spriteCellHeight: number;
  81795. /**
  81796. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81797. */
  81798. spriteRandomStartCell: boolean;
  81799. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81800. translationPivot: Vector2;
  81801. /** @hidden */
  81802. protected _isAnimationSheetEnabled: boolean;
  81803. /**
  81804. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81805. */
  81806. beginAnimationOnStart: boolean;
  81807. /**
  81808. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81809. */
  81810. beginAnimationFrom: number;
  81811. /**
  81812. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81813. */
  81814. beginAnimationTo: number;
  81815. /**
  81816. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81817. */
  81818. beginAnimationLoop: boolean;
  81819. /**
  81820. * Gets or sets a world offset applied to all particles
  81821. */
  81822. worldOffset: Vector3;
  81823. /**
  81824. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81825. */
  81826. isAnimationSheetEnabled: boolean;
  81827. /**
  81828. * Get hosting scene
  81829. * @returns the scene
  81830. */
  81831. getScene(): Scene;
  81832. /**
  81833. * You can use gravity if you want to give an orientation to your particles.
  81834. */
  81835. gravity: Vector3;
  81836. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81837. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81838. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81839. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81840. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81841. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81842. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81843. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81844. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81845. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81846. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81847. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81848. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81849. /**
  81850. * Defines the delay in milliseconds before starting the system (0 by default)
  81851. */
  81852. startDelay: number;
  81853. /**
  81854. * Gets the current list of drag gradients.
  81855. * You must use addDragGradient and removeDragGradient to udpate this list
  81856. * @returns the list of drag gradients
  81857. */
  81858. getDragGradients(): Nullable<Array<FactorGradient>>;
  81859. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81860. limitVelocityDamping: number;
  81861. /**
  81862. * Gets the current list of limit velocity gradients.
  81863. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81864. * @returns the list of limit velocity gradients
  81865. */
  81866. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81867. /**
  81868. * Gets the current list of color gradients.
  81869. * You must use addColorGradient and removeColorGradient to udpate this list
  81870. * @returns the list of color gradients
  81871. */
  81872. getColorGradients(): Nullable<Array<ColorGradient>>;
  81873. /**
  81874. * Gets the current list of size gradients.
  81875. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81876. * @returns the list of size gradients
  81877. */
  81878. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81879. /**
  81880. * Gets the current list of color remap gradients.
  81881. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81882. * @returns the list of color remap gradients
  81883. */
  81884. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81885. /**
  81886. * Gets the current list of alpha remap gradients.
  81887. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81888. * @returns the list of alpha remap gradients
  81889. */
  81890. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81891. /**
  81892. * Gets the current list of life time gradients.
  81893. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81894. * @returns the list of life time gradients
  81895. */
  81896. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81897. /**
  81898. * Gets the current list of angular speed gradients.
  81899. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81900. * @returns the list of angular speed gradients
  81901. */
  81902. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81903. /**
  81904. * Gets the current list of velocity gradients.
  81905. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81906. * @returns the list of velocity gradients
  81907. */
  81908. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81909. /**
  81910. * Gets the current list of start size gradients.
  81911. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81912. * @returns the list of start size gradients
  81913. */
  81914. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81915. /**
  81916. * Gets the current list of emit rate gradients.
  81917. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81918. * @returns the list of emit rate gradients
  81919. */
  81920. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81921. /**
  81922. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81923. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81924. */
  81925. direction1: Vector3;
  81926. /**
  81927. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81928. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81929. */
  81930. direction2: Vector3;
  81931. /**
  81932. * 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.
  81933. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81934. */
  81935. minEmitBox: Vector3;
  81936. /**
  81937. * 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.
  81938. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81939. */
  81940. maxEmitBox: Vector3;
  81941. /**
  81942. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81943. */
  81944. color1: Color4;
  81945. /**
  81946. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81947. */
  81948. color2: Color4;
  81949. /**
  81950. * Color the particle will have at the end of its lifetime
  81951. */
  81952. colorDead: Color4;
  81953. /**
  81954. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81955. */
  81956. textureMask: Color4;
  81957. /**
  81958. * The particle emitter type defines the emitter used by the particle system.
  81959. * It can be for example box, sphere, or cone...
  81960. */
  81961. particleEmitterType: IParticleEmitterType;
  81962. /** @hidden */
  81963. _isSubEmitter: boolean;
  81964. /**
  81965. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81966. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81967. */
  81968. billboardMode: number;
  81969. protected _isBillboardBased: boolean;
  81970. /**
  81971. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81972. */
  81973. isBillboardBased: boolean;
  81974. /**
  81975. * The scene the particle system belongs to.
  81976. */
  81977. protected _scene: Scene;
  81978. /**
  81979. * Local cache of defines for image processing.
  81980. */
  81981. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81982. /**
  81983. * Default configuration related to image processing available in the standard Material.
  81984. */
  81985. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81986. /**
  81987. * Gets the image processing configuration used either in this material.
  81988. */
  81989. /**
  81990. * Sets the Default image processing configuration used either in the this material.
  81991. *
  81992. * If sets to null, the scene one is in use.
  81993. */
  81994. imageProcessingConfiguration: ImageProcessingConfiguration;
  81995. /**
  81996. * Attaches a new image processing configuration to the Standard Material.
  81997. * @param configuration
  81998. */
  81999. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82000. /** @hidden */
  82001. protected _reset(): void;
  82002. /** @hidden */
  82003. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82004. /**
  82005. * Instantiates a particle system.
  82006. * 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.
  82007. * @param name The name of the particle system
  82008. */
  82009. constructor(name: string);
  82010. /**
  82011. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82014. * @returns the emitter
  82015. */
  82016. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82017. /**
  82018. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82019. * @param radius The radius of the hemisphere to emit from
  82020. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82021. * @returns the emitter
  82022. */
  82023. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82024. /**
  82025. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82026. * @param radius The radius of the sphere to emit from
  82027. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82028. * @returns the emitter
  82029. */
  82030. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82031. /**
  82032. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82033. * @param radius The radius of the sphere to emit from
  82034. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82035. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82036. * @returns the emitter
  82037. */
  82038. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82039. /**
  82040. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82041. * @param radius The radius of the emission cylinder
  82042. * @param height The height of the emission cylinder
  82043. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82044. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82045. * @returns the emitter
  82046. */
  82047. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82048. /**
  82049. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82050. * @param radius The radius of the cylinder to emit from
  82051. * @param height The height of the emission cylinder
  82052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82053. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82054. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82055. * @returns the emitter
  82056. */
  82057. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82058. /**
  82059. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82060. * @param radius The radius of the cone to emit from
  82061. * @param angle The base angle of the cone
  82062. * @returns the emitter
  82063. */
  82064. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82065. /**
  82066. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82067. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82068. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82069. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82070. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82071. * @returns the emitter
  82072. */
  82073. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82074. }
  82075. }
  82076. declare module BABYLON {
  82077. /**
  82078. * Type of sub emitter
  82079. */
  82080. export enum SubEmitterType {
  82081. /**
  82082. * Attached to the particle over it's lifetime
  82083. */
  82084. ATTACHED = 0,
  82085. /**
  82086. * Created when the particle dies
  82087. */
  82088. END = 1
  82089. }
  82090. /**
  82091. * Sub emitter class used to emit particles from an existing particle
  82092. */
  82093. export class SubEmitter {
  82094. /**
  82095. * the particle system to be used by the sub emitter
  82096. */
  82097. particleSystem: ParticleSystem;
  82098. /**
  82099. * Type of the submitter (Default: END)
  82100. */
  82101. type: SubEmitterType;
  82102. /**
  82103. * 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)
  82104. * Note: This only is supported when using an emitter of type Mesh
  82105. */
  82106. inheritDirection: boolean;
  82107. /**
  82108. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82109. */
  82110. inheritedVelocityAmount: number;
  82111. /**
  82112. * Creates a sub emitter
  82113. * @param particleSystem the particle system to be used by the sub emitter
  82114. */
  82115. constructor(
  82116. /**
  82117. * the particle system to be used by the sub emitter
  82118. */
  82119. particleSystem: ParticleSystem);
  82120. /**
  82121. * Clones the sub emitter
  82122. * @returns the cloned sub emitter
  82123. */
  82124. clone(): SubEmitter;
  82125. /**
  82126. * Serialize current object to a JSON object
  82127. * @returns the serialized object
  82128. */
  82129. serialize(): any;
  82130. /** @hidden */
  82131. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82132. /**
  82133. * Creates a new SubEmitter from a serialized JSON version
  82134. * @param serializationObject defines the JSON object to read from
  82135. * @param scene defines the hosting scene
  82136. * @param rootUrl defines the rootUrl for data loading
  82137. * @returns a new SubEmitter
  82138. */
  82139. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82140. /** Release associated resources */
  82141. dispose(): void;
  82142. }
  82143. }
  82144. declare module BABYLON {
  82145. /** @hidden */
  82146. export var imageProcessingDeclaration: {
  82147. name: string;
  82148. shader: string;
  82149. };
  82150. }
  82151. declare module BABYLON {
  82152. /** @hidden */
  82153. export var imageProcessingFunctions: {
  82154. name: string;
  82155. shader: string;
  82156. };
  82157. }
  82158. declare module BABYLON {
  82159. /** @hidden */
  82160. export var particlesPixelShader: {
  82161. name: string;
  82162. shader: string;
  82163. };
  82164. }
  82165. declare module BABYLON {
  82166. /** @hidden */
  82167. export var particlesVertexShader: {
  82168. name: string;
  82169. shader: string;
  82170. };
  82171. }
  82172. declare module BABYLON {
  82173. /**
  82174. * This represents a particle system in Babylon.
  82175. * 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.
  82176. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82177. * @example https://doc.babylonjs.com/babylon101/particles
  82178. */
  82179. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82180. /**
  82181. * Billboard mode will only apply to Y axis
  82182. */
  82183. static readonly BILLBOARDMODE_Y: number;
  82184. /**
  82185. * Billboard mode will apply to all axes
  82186. */
  82187. static readonly BILLBOARDMODE_ALL: number;
  82188. /**
  82189. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82190. */
  82191. static readonly BILLBOARDMODE_STRETCHED: number;
  82192. /**
  82193. * This function can be defined to provide custom update for active particles.
  82194. * This function will be called instead of regular update (age, position, color, etc.).
  82195. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82196. */
  82197. updateFunction: (particles: Particle[]) => void;
  82198. private _emitterWorldMatrix;
  82199. /**
  82200. * This function can be defined to specify initial direction for every new particle.
  82201. * It by default use the emitterType defined function
  82202. */
  82203. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82204. /**
  82205. * This function can be defined to specify initial position for every new particle.
  82206. * It by default use the emitterType defined function
  82207. */
  82208. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82209. /**
  82210. * @hidden
  82211. */
  82212. _inheritedVelocityOffset: Vector3;
  82213. /**
  82214. * An event triggered when the system is disposed
  82215. */
  82216. onDisposeObservable: Observable<ParticleSystem>;
  82217. private _onDisposeObserver;
  82218. /**
  82219. * Sets a callback that will be triggered when the system is disposed
  82220. */
  82221. onDispose: () => void;
  82222. private _particles;
  82223. private _epsilon;
  82224. private _capacity;
  82225. private _stockParticles;
  82226. private _newPartsExcess;
  82227. private _vertexData;
  82228. private _vertexBuffer;
  82229. private _vertexBuffers;
  82230. private _spriteBuffer;
  82231. private _indexBuffer;
  82232. private _effect;
  82233. private _customEffect;
  82234. private _cachedDefines;
  82235. private _scaledColorStep;
  82236. private _colorDiff;
  82237. private _scaledDirection;
  82238. private _scaledGravity;
  82239. private _currentRenderId;
  82240. private _alive;
  82241. private _useInstancing;
  82242. private _started;
  82243. private _stopped;
  82244. private _actualFrame;
  82245. private _scaledUpdateSpeed;
  82246. private _vertexBufferSize;
  82247. /** @hidden */
  82248. _currentEmitRateGradient: Nullable<FactorGradient>;
  82249. /** @hidden */
  82250. _currentEmitRate1: number;
  82251. /** @hidden */
  82252. _currentEmitRate2: number;
  82253. /** @hidden */
  82254. _currentStartSizeGradient: Nullable<FactorGradient>;
  82255. /** @hidden */
  82256. _currentStartSize1: number;
  82257. /** @hidden */
  82258. _currentStartSize2: number;
  82259. private readonly _rawTextureWidth;
  82260. private _rampGradientsTexture;
  82261. private _useRampGradients;
  82262. /** Gets or sets a boolean indicating that ramp gradients must be used
  82263. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82264. */
  82265. useRampGradients: boolean;
  82266. /**
  82267. * 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.
  82268. * 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: [])
  82269. */
  82270. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82271. private _subEmitters;
  82272. /**
  82273. * @hidden
  82274. * If the particle systems emitter should be disposed when the particle system is disposed
  82275. */
  82276. _disposeEmitterOnDispose: boolean;
  82277. /**
  82278. * The current active Sub-systems, this property is used by the root particle system only.
  82279. */
  82280. activeSubSystems: Array<ParticleSystem>;
  82281. private _rootParticleSystem;
  82282. /**
  82283. * Gets the current list of active particles
  82284. */
  82285. readonly particles: Particle[];
  82286. /**
  82287. * Returns the string "ParticleSystem"
  82288. * @returns a string containing the class name
  82289. */
  82290. getClassName(): string;
  82291. /**
  82292. * Instantiates a particle system.
  82293. * 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.
  82294. * @param name The name of the particle system
  82295. * @param capacity The max number of particles alive at the same time
  82296. * @param scene The scene the particle system belongs to
  82297. * @param customEffect a custom effect used to change the way particles are rendered by default
  82298. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82299. * @param epsilon Offset used to render the particles
  82300. */
  82301. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82302. private _addFactorGradient;
  82303. private _removeFactorGradient;
  82304. /**
  82305. * Adds a new life time gradient
  82306. * @param gradient defines the gradient to use (between 0 and 1)
  82307. * @param factor defines the life time factor to affect to the specified gradient
  82308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82309. * @returns the current particle system
  82310. */
  82311. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82312. /**
  82313. * Remove a specific life time gradient
  82314. * @param gradient defines the gradient to remove
  82315. * @returns the current particle system
  82316. */
  82317. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82318. /**
  82319. * Adds a new size gradient
  82320. * @param gradient defines the gradient to use (between 0 and 1)
  82321. * @param factor defines the size factor to affect to the specified gradient
  82322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82323. * @returns the current particle system
  82324. */
  82325. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82326. /**
  82327. * Remove a specific size gradient
  82328. * @param gradient defines the gradient to remove
  82329. * @returns the current particle system
  82330. */
  82331. removeSizeGradient(gradient: number): IParticleSystem;
  82332. /**
  82333. * Adds a new color remap gradient
  82334. * @param gradient defines the gradient to use (between 0 and 1)
  82335. * @param min defines the color remap minimal range
  82336. * @param max defines the color remap maximal range
  82337. * @returns the current particle system
  82338. */
  82339. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82340. /**
  82341. * Remove a specific color remap gradient
  82342. * @param gradient defines the gradient to remove
  82343. * @returns the current particle system
  82344. */
  82345. removeColorRemapGradient(gradient: number): IParticleSystem;
  82346. /**
  82347. * Adds a new alpha remap gradient
  82348. * @param gradient defines the gradient to use (between 0 and 1)
  82349. * @param min defines the alpha remap minimal range
  82350. * @param max defines the alpha remap maximal range
  82351. * @returns the current particle system
  82352. */
  82353. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82354. /**
  82355. * Remove a specific alpha remap gradient
  82356. * @param gradient defines the gradient to remove
  82357. * @returns the current particle system
  82358. */
  82359. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82360. /**
  82361. * Adds a new angular speed gradient
  82362. * @param gradient defines the gradient to use (between 0 and 1)
  82363. * @param factor defines the angular speed to affect to the specified gradient
  82364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82365. * @returns the current particle system
  82366. */
  82367. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82368. /**
  82369. * Remove a specific angular speed gradient
  82370. * @param gradient defines the gradient to remove
  82371. * @returns the current particle system
  82372. */
  82373. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82374. /**
  82375. * Adds a new velocity gradient
  82376. * @param gradient defines the gradient to use (between 0 and 1)
  82377. * @param factor defines the velocity to affect to the specified gradient
  82378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82379. * @returns the current particle system
  82380. */
  82381. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82382. /**
  82383. * Remove a specific velocity gradient
  82384. * @param gradient defines the gradient to remove
  82385. * @returns the current particle system
  82386. */
  82387. removeVelocityGradient(gradient: number): IParticleSystem;
  82388. /**
  82389. * Adds a new limit velocity gradient
  82390. * @param gradient defines the gradient to use (between 0 and 1)
  82391. * @param factor defines the limit velocity value to affect to the specified gradient
  82392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82393. * @returns the current particle system
  82394. */
  82395. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82396. /**
  82397. * Remove a specific limit velocity gradient
  82398. * @param gradient defines the gradient to remove
  82399. * @returns the current particle system
  82400. */
  82401. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82402. /**
  82403. * Adds a new drag gradient
  82404. * @param gradient defines the gradient to use (between 0 and 1)
  82405. * @param factor defines the drag value to affect to the specified gradient
  82406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82407. * @returns the current particle system
  82408. */
  82409. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82410. /**
  82411. * Remove a specific drag gradient
  82412. * @param gradient defines the gradient to remove
  82413. * @returns the current particle system
  82414. */
  82415. removeDragGradient(gradient: number): IParticleSystem;
  82416. /**
  82417. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82418. * @param gradient defines the gradient to use (between 0 and 1)
  82419. * @param factor defines the emit rate value to affect to the specified gradient
  82420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82421. * @returns the current particle system
  82422. */
  82423. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82424. /**
  82425. * Remove a specific emit rate gradient
  82426. * @param gradient defines the gradient to remove
  82427. * @returns the current particle system
  82428. */
  82429. removeEmitRateGradient(gradient: number): IParticleSystem;
  82430. /**
  82431. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82432. * @param gradient defines the gradient to use (between 0 and 1)
  82433. * @param factor defines the start size value to affect to the specified gradient
  82434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82435. * @returns the current particle system
  82436. */
  82437. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82438. /**
  82439. * Remove a specific start size gradient
  82440. * @param gradient defines the gradient to remove
  82441. * @returns the current particle system
  82442. */
  82443. removeStartSizeGradient(gradient: number): IParticleSystem;
  82444. private _createRampGradientTexture;
  82445. /**
  82446. * Gets the current list of ramp gradients.
  82447. * You must use addRampGradient and removeRampGradient to udpate this list
  82448. * @returns the list of ramp gradients
  82449. */
  82450. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82451. /**
  82452. * Adds a new ramp gradient used to remap particle colors
  82453. * @param gradient defines the gradient to use (between 0 and 1)
  82454. * @param color defines the color to affect to the specified gradient
  82455. * @returns the current particle system
  82456. */
  82457. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82458. /**
  82459. * Remove a specific ramp gradient
  82460. * @param gradient defines the gradient to remove
  82461. * @returns the current particle system
  82462. */
  82463. removeRampGradient(gradient: number): ParticleSystem;
  82464. /**
  82465. * Adds a new color gradient
  82466. * @param gradient defines the gradient to use (between 0 and 1)
  82467. * @param color1 defines the color to affect to the specified gradient
  82468. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82469. * @returns this particle system
  82470. */
  82471. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82472. /**
  82473. * Remove a specific color gradient
  82474. * @param gradient defines the gradient to remove
  82475. * @returns this particle system
  82476. */
  82477. removeColorGradient(gradient: number): IParticleSystem;
  82478. private _fetchR;
  82479. protected _reset(): void;
  82480. private _resetEffect;
  82481. private _createVertexBuffers;
  82482. private _createIndexBuffer;
  82483. /**
  82484. * Gets the maximum number of particles active at the same time.
  82485. * @returns The max number of active particles.
  82486. */
  82487. getCapacity(): number;
  82488. /**
  82489. * Gets whether there are still active particles in the system.
  82490. * @returns True if it is alive, otherwise false.
  82491. */
  82492. isAlive(): boolean;
  82493. /**
  82494. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82495. * @returns True if it has been started, otherwise false.
  82496. */
  82497. isStarted(): boolean;
  82498. private _prepareSubEmitterInternalArray;
  82499. /**
  82500. * Starts the particle system and begins to emit
  82501. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82502. */
  82503. start(delay?: number): void;
  82504. /**
  82505. * Stops the particle system.
  82506. * @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.
  82507. */
  82508. stop(stopSubEmitters?: boolean): void;
  82509. /**
  82510. * Remove all active particles
  82511. */
  82512. reset(): void;
  82513. /**
  82514. * @hidden (for internal use only)
  82515. */
  82516. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82517. /**
  82518. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82519. * Its lifetime will start back at 0.
  82520. */
  82521. recycleParticle: (particle: Particle) => void;
  82522. private _stopSubEmitters;
  82523. private _createParticle;
  82524. private _removeFromRoot;
  82525. private _emitFromParticle;
  82526. private _update;
  82527. /** @hidden */
  82528. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82529. /** @hidden */
  82530. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82531. /** @hidden */
  82532. private _getEffect;
  82533. /**
  82534. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82535. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82536. */
  82537. animate(preWarmOnly?: boolean): void;
  82538. private _appendParticleVertices;
  82539. /**
  82540. * Rebuilds the particle system.
  82541. */
  82542. rebuild(): void;
  82543. /**
  82544. * Is this system ready to be used/rendered
  82545. * @return true if the system is ready
  82546. */
  82547. isReady(): boolean;
  82548. private _render;
  82549. /**
  82550. * Renders the particle system in its current state.
  82551. * @returns the current number of particles
  82552. */
  82553. render(): number;
  82554. /**
  82555. * Disposes the particle system and free the associated resources
  82556. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82557. */
  82558. dispose(disposeTexture?: boolean): void;
  82559. /**
  82560. * Clones the particle system.
  82561. * @param name The name of the cloned object
  82562. * @param newEmitter The new emitter to use
  82563. * @returns the cloned particle system
  82564. */
  82565. clone(name: string, newEmitter: any): ParticleSystem;
  82566. /**
  82567. * Serializes the particle system to a JSON object.
  82568. * @returns the JSON object
  82569. */
  82570. serialize(): any;
  82571. /** @hidden */
  82572. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82573. /** @hidden */
  82574. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82575. /**
  82576. * Parses a JSON object to create a particle system.
  82577. * @param parsedParticleSystem The JSON object to parse
  82578. * @param scene The scene to create the particle system in
  82579. * @param rootUrl The root url to use to load external dependencies like texture
  82580. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82581. * @returns the Parsed particle system
  82582. */
  82583. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82584. }
  82585. }
  82586. declare module BABYLON {
  82587. /**
  82588. * A particle represents one of the element emitted by a particle system.
  82589. * This is mainly define by its coordinates, direction, velocity and age.
  82590. */
  82591. export class Particle {
  82592. /**
  82593. * The particle system the particle belongs to.
  82594. */
  82595. particleSystem: ParticleSystem;
  82596. private static _Count;
  82597. /**
  82598. * Unique ID of the particle
  82599. */
  82600. id: number;
  82601. /**
  82602. * The world position of the particle in the scene.
  82603. */
  82604. position: Vector3;
  82605. /**
  82606. * The world direction of the particle in the scene.
  82607. */
  82608. direction: Vector3;
  82609. /**
  82610. * The color of the particle.
  82611. */
  82612. color: Color4;
  82613. /**
  82614. * The color change of the particle per step.
  82615. */
  82616. colorStep: Color4;
  82617. /**
  82618. * Defines how long will the life of the particle be.
  82619. */
  82620. lifeTime: number;
  82621. /**
  82622. * The current age of the particle.
  82623. */
  82624. age: number;
  82625. /**
  82626. * The current size of the particle.
  82627. */
  82628. size: number;
  82629. /**
  82630. * The current scale of the particle.
  82631. */
  82632. scale: Vector2;
  82633. /**
  82634. * The current angle of the particle.
  82635. */
  82636. angle: number;
  82637. /**
  82638. * Defines how fast is the angle changing.
  82639. */
  82640. angularSpeed: number;
  82641. /**
  82642. * Defines the cell index used by the particle to be rendered from a sprite.
  82643. */
  82644. cellIndex: number;
  82645. /**
  82646. * The information required to support color remapping
  82647. */
  82648. remapData: Vector4;
  82649. /** @hidden */
  82650. _randomCellOffset?: number;
  82651. /** @hidden */
  82652. _initialDirection: Nullable<Vector3>;
  82653. /** @hidden */
  82654. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82655. /** @hidden */
  82656. _initialStartSpriteCellID: number;
  82657. /** @hidden */
  82658. _initialEndSpriteCellID: number;
  82659. /** @hidden */
  82660. _currentColorGradient: Nullable<ColorGradient>;
  82661. /** @hidden */
  82662. _currentColor1: Color4;
  82663. /** @hidden */
  82664. _currentColor2: Color4;
  82665. /** @hidden */
  82666. _currentSizeGradient: Nullable<FactorGradient>;
  82667. /** @hidden */
  82668. _currentSize1: number;
  82669. /** @hidden */
  82670. _currentSize2: number;
  82671. /** @hidden */
  82672. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82673. /** @hidden */
  82674. _currentAngularSpeed1: number;
  82675. /** @hidden */
  82676. _currentAngularSpeed2: number;
  82677. /** @hidden */
  82678. _currentVelocityGradient: Nullable<FactorGradient>;
  82679. /** @hidden */
  82680. _currentVelocity1: number;
  82681. /** @hidden */
  82682. _currentVelocity2: number;
  82683. /** @hidden */
  82684. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82685. /** @hidden */
  82686. _currentLimitVelocity1: number;
  82687. /** @hidden */
  82688. _currentLimitVelocity2: number;
  82689. /** @hidden */
  82690. _currentDragGradient: Nullable<FactorGradient>;
  82691. /** @hidden */
  82692. _currentDrag1: number;
  82693. /** @hidden */
  82694. _currentDrag2: number;
  82695. /** @hidden */
  82696. _randomNoiseCoordinates1: Vector3;
  82697. /** @hidden */
  82698. _randomNoiseCoordinates2: Vector3;
  82699. /**
  82700. * Creates a new instance Particle
  82701. * @param particleSystem the particle system the particle belongs to
  82702. */
  82703. constructor(
  82704. /**
  82705. * The particle system the particle belongs to.
  82706. */
  82707. particleSystem: ParticleSystem);
  82708. private updateCellInfoFromSystem;
  82709. /**
  82710. * Defines how the sprite cell index is updated for the particle
  82711. */
  82712. updateCellIndex(): void;
  82713. /** @hidden */
  82714. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82715. /** @hidden */
  82716. _inheritParticleInfoToSubEmitters(): void;
  82717. /** @hidden */
  82718. _reset(): void;
  82719. /**
  82720. * Copy the properties of particle to another one.
  82721. * @param other the particle to copy the information to.
  82722. */
  82723. copyTo(other: Particle): void;
  82724. }
  82725. }
  82726. declare module BABYLON {
  82727. /**
  82728. * Particle emitter represents a volume emitting particles.
  82729. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82730. */
  82731. export interface IParticleEmitterType {
  82732. /**
  82733. * Called by the particle System when the direction is computed for the created particle.
  82734. * @param worldMatrix is the world matrix of the particle system
  82735. * @param directionToUpdate is the direction vector to update with the result
  82736. * @param particle is the particle we are computed the direction for
  82737. */
  82738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82739. /**
  82740. * Called by the particle System when the position is computed for the created particle.
  82741. * @param worldMatrix is the world matrix of the particle system
  82742. * @param positionToUpdate is the position vector to update with the result
  82743. * @param particle is the particle we are computed the position for
  82744. */
  82745. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82746. /**
  82747. * Clones the current emitter and returns a copy of it
  82748. * @returns the new emitter
  82749. */
  82750. clone(): IParticleEmitterType;
  82751. /**
  82752. * Called by the GPUParticleSystem to setup the update shader
  82753. * @param effect defines the update shader
  82754. */
  82755. applyToShader(effect: Effect): void;
  82756. /**
  82757. * Returns a string to use to update the GPU particles update shader
  82758. * @returns the effect defines string
  82759. */
  82760. getEffectDefines(): string;
  82761. /**
  82762. * Returns a string representing the class name
  82763. * @returns a string containing the class name
  82764. */
  82765. getClassName(): string;
  82766. /**
  82767. * Serializes the particle system to a JSON object.
  82768. * @returns the JSON object
  82769. */
  82770. serialize(): any;
  82771. /**
  82772. * Parse properties from a JSON object
  82773. * @param serializationObject defines the JSON object
  82774. */
  82775. parse(serializationObject: any): void;
  82776. }
  82777. }
  82778. declare module BABYLON {
  82779. /**
  82780. * Particle emitter emitting particles from the inside of a box.
  82781. * It emits the particles randomly between 2 given directions.
  82782. */
  82783. export class BoxParticleEmitter implements IParticleEmitterType {
  82784. /**
  82785. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82786. */
  82787. direction1: Vector3;
  82788. /**
  82789. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82790. */
  82791. direction2: Vector3;
  82792. /**
  82793. * 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.
  82794. */
  82795. minEmitBox: Vector3;
  82796. /**
  82797. * 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.
  82798. */
  82799. maxEmitBox: Vector3;
  82800. /**
  82801. * Creates a new instance BoxParticleEmitter
  82802. */
  82803. constructor();
  82804. /**
  82805. * Called by the particle System when the direction is computed for the created particle.
  82806. * @param worldMatrix is the world matrix of the particle system
  82807. * @param directionToUpdate is the direction vector to update with the result
  82808. * @param particle is the particle we are computed the direction for
  82809. */
  82810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82811. /**
  82812. * Called by the particle System when the position is computed for the created particle.
  82813. * @param worldMatrix is the world matrix of the particle system
  82814. * @param positionToUpdate is the position vector to update with the result
  82815. * @param particle is the particle we are computed the position for
  82816. */
  82817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82818. /**
  82819. * Clones the current emitter and returns a copy of it
  82820. * @returns the new emitter
  82821. */
  82822. clone(): BoxParticleEmitter;
  82823. /**
  82824. * Called by the GPUParticleSystem to setup the update shader
  82825. * @param effect defines the update shader
  82826. */
  82827. applyToShader(effect: Effect): void;
  82828. /**
  82829. * Returns a string to use to update the GPU particles update shader
  82830. * @returns a string containng the defines string
  82831. */
  82832. getEffectDefines(): string;
  82833. /**
  82834. * Returns the string "BoxParticleEmitter"
  82835. * @returns a string containing the class name
  82836. */
  82837. getClassName(): string;
  82838. /**
  82839. * Serializes the particle system to a JSON object.
  82840. * @returns the JSON object
  82841. */
  82842. serialize(): any;
  82843. /**
  82844. * Parse properties from a JSON object
  82845. * @param serializationObject defines the JSON object
  82846. */
  82847. parse(serializationObject: any): void;
  82848. }
  82849. }
  82850. declare module BABYLON {
  82851. /**
  82852. * Particle emitter emitting particles from the inside of a cone.
  82853. * It emits the particles alongside the cone volume from the base to the particle.
  82854. * The emission direction might be randomized.
  82855. */
  82856. export class ConeParticleEmitter implements IParticleEmitterType {
  82857. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82858. directionRandomizer: number;
  82859. private _radius;
  82860. private _angle;
  82861. private _height;
  82862. /**
  82863. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82864. */
  82865. radiusRange: number;
  82866. /**
  82867. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82868. */
  82869. heightRange: number;
  82870. /**
  82871. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82872. */
  82873. emitFromSpawnPointOnly: boolean;
  82874. /**
  82875. * Gets or sets the radius of the emission cone
  82876. */
  82877. radius: number;
  82878. /**
  82879. * Gets or sets the angle of the emission cone
  82880. */
  82881. angle: number;
  82882. private _buildHeight;
  82883. /**
  82884. * Creates a new instance ConeParticleEmitter
  82885. * @param radius the radius of the emission cone (1 by default)
  82886. * @param angle the cone base angle (PI by default)
  82887. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82888. */
  82889. constructor(radius?: number, angle?: number,
  82890. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82891. directionRandomizer?: number);
  82892. /**
  82893. * Called by the particle System when the direction is computed for the created particle.
  82894. * @param worldMatrix is the world matrix of the particle system
  82895. * @param directionToUpdate is the direction vector to update with the result
  82896. * @param particle is the particle we are computed the direction for
  82897. */
  82898. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82899. /**
  82900. * Called by the particle System when the position is computed for the created particle.
  82901. * @param worldMatrix is the world matrix of the particle system
  82902. * @param positionToUpdate is the position vector to update with the result
  82903. * @param particle is the particle we are computed the position for
  82904. */
  82905. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82906. /**
  82907. * Clones the current emitter and returns a copy of it
  82908. * @returns the new emitter
  82909. */
  82910. clone(): ConeParticleEmitter;
  82911. /**
  82912. * Called by the GPUParticleSystem to setup the update shader
  82913. * @param effect defines the update shader
  82914. */
  82915. applyToShader(effect: Effect): void;
  82916. /**
  82917. * Returns a string to use to update the GPU particles update shader
  82918. * @returns a string containng the defines string
  82919. */
  82920. getEffectDefines(): string;
  82921. /**
  82922. * Returns the string "ConeParticleEmitter"
  82923. * @returns a string containing the class name
  82924. */
  82925. getClassName(): string;
  82926. /**
  82927. * Serializes the particle system to a JSON object.
  82928. * @returns the JSON object
  82929. */
  82930. serialize(): any;
  82931. /**
  82932. * Parse properties from a JSON object
  82933. * @param serializationObject defines the JSON object
  82934. */
  82935. parse(serializationObject: any): void;
  82936. }
  82937. }
  82938. declare module BABYLON {
  82939. /**
  82940. * Particle emitter emitting particles from the inside of a cylinder.
  82941. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82942. */
  82943. export class CylinderParticleEmitter implements IParticleEmitterType {
  82944. /**
  82945. * The radius of the emission cylinder.
  82946. */
  82947. radius: number;
  82948. /**
  82949. * The height of the emission cylinder.
  82950. */
  82951. height: number;
  82952. /**
  82953. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82954. */
  82955. radiusRange: number;
  82956. /**
  82957. * How much to randomize the particle direction [0-1].
  82958. */
  82959. directionRandomizer: number;
  82960. /**
  82961. * Creates a new instance CylinderParticleEmitter
  82962. * @param radius the radius of the emission cylinder (1 by default)
  82963. * @param height the height of the emission cylinder (1 by default)
  82964. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82965. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82966. */
  82967. constructor(
  82968. /**
  82969. * The radius of the emission cylinder.
  82970. */
  82971. radius?: number,
  82972. /**
  82973. * The height of the emission cylinder.
  82974. */
  82975. height?: number,
  82976. /**
  82977. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82978. */
  82979. radiusRange?: number,
  82980. /**
  82981. * How much to randomize the particle direction [0-1].
  82982. */
  82983. directionRandomizer?: number);
  82984. /**
  82985. * Called by the particle System when the direction is computed for the created particle.
  82986. * @param worldMatrix is the world matrix of the particle system
  82987. * @param directionToUpdate is the direction vector to update with the result
  82988. * @param particle is the particle we are computed the direction for
  82989. */
  82990. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82991. /**
  82992. * Called by the particle System when the position is computed for the created particle.
  82993. * @param worldMatrix is the world matrix of the particle system
  82994. * @param positionToUpdate is the position vector to update with the result
  82995. * @param particle is the particle we are computed the position for
  82996. */
  82997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82998. /**
  82999. * Clones the current emitter and returns a copy of it
  83000. * @returns the new emitter
  83001. */
  83002. clone(): CylinderParticleEmitter;
  83003. /**
  83004. * Called by the GPUParticleSystem to setup the update shader
  83005. * @param effect defines the update shader
  83006. */
  83007. applyToShader(effect: Effect): void;
  83008. /**
  83009. * Returns a string to use to update the GPU particles update shader
  83010. * @returns a string containng the defines string
  83011. */
  83012. getEffectDefines(): string;
  83013. /**
  83014. * Returns the string "CylinderParticleEmitter"
  83015. * @returns a string containing the class name
  83016. */
  83017. getClassName(): string;
  83018. /**
  83019. * Serializes the particle system to a JSON object.
  83020. * @returns the JSON object
  83021. */
  83022. serialize(): any;
  83023. /**
  83024. * Parse properties from a JSON object
  83025. * @param serializationObject defines the JSON object
  83026. */
  83027. parse(serializationObject: any): void;
  83028. }
  83029. /**
  83030. * Particle emitter emitting particles from the inside of a cylinder.
  83031. * It emits the particles randomly between two vectors.
  83032. */
  83033. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83034. /**
  83035. * The min limit of the emission direction.
  83036. */
  83037. direction1: Vector3;
  83038. /**
  83039. * The max limit of the emission direction.
  83040. */
  83041. direction2: Vector3;
  83042. /**
  83043. * Creates a new instance CylinderDirectedParticleEmitter
  83044. * @param radius the radius of the emission cylinder (1 by default)
  83045. * @param height the height of the emission cylinder (1 by default)
  83046. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83047. * @param direction1 the min limit of the emission direction (up vector by default)
  83048. * @param direction2 the max limit of the emission direction (up vector by default)
  83049. */
  83050. constructor(radius?: number, height?: number, radiusRange?: number,
  83051. /**
  83052. * The min limit of the emission direction.
  83053. */
  83054. direction1?: Vector3,
  83055. /**
  83056. * The max limit of the emission direction.
  83057. */
  83058. direction2?: Vector3);
  83059. /**
  83060. * Called by the particle System when the direction is computed for the created particle.
  83061. * @param worldMatrix is the world matrix of the particle system
  83062. * @param directionToUpdate is the direction vector to update with the result
  83063. * @param particle is the particle we are computed the direction for
  83064. */
  83065. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83066. /**
  83067. * Clones the current emitter and returns a copy of it
  83068. * @returns the new emitter
  83069. */
  83070. clone(): CylinderDirectedParticleEmitter;
  83071. /**
  83072. * Called by the GPUParticleSystem to setup the update shader
  83073. * @param effect defines the update shader
  83074. */
  83075. applyToShader(effect: Effect): void;
  83076. /**
  83077. * Returns a string to use to update the GPU particles update shader
  83078. * @returns a string containng the defines string
  83079. */
  83080. getEffectDefines(): string;
  83081. /**
  83082. * Returns the string "CylinderDirectedParticleEmitter"
  83083. * @returns a string containing the class name
  83084. */
  83085. getClassName(): string;
  83086. /**
  83087. * Serializes the particle system to a JSON object.
  83088. * @returns the JSON object
  83089. */
  83090. serialize(): any;
  83091. /**
  83092. * Parse properties from a JSON object
  83093. * @param serializationObject defines the JSON object
  83094. */
  83095. parse(serializationObject: any): void;
  83096. }
  83097. }
  83098. declare module BABYLON {
  83099. /**
  83100. * Particle emitter emitting particles from the inside of a hemisphere.
  83101. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83102. */
  83103. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83104. /**
  83105. * The radius of the emission hemisphere.
  83106. */
  83107. radius: number;
  83108. /**
  83109. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83110. */
  83111. radiusRange: number;
  83112. /**
  83113. * How much to randomize the particle direction [0-1].
  83114. */
  83115. directionRandomizer: number;
  83116. /**
  83117. * Creates a new instance HemisphericParticleEmitter
  83118. * @param radius the radius of the emission hemisphere (1 by default)
  83119. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83120. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83121. */
  83122. constructor(
  83123. /**
  83124. * The radius of the emission hemisphere.
  83125. */
  83126. radius?: number,
  83127. /**
  83128. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83129. */
  83130. radiusRange?: number,
  83131. /**
  83132. * How much to randomize the particle direction [0-1].
  83133. */
  83134. directionRandomizer?: number);
  83135. /**
  83136. * Called by the particle System when the direction is computed for the created particle.
  83137. * @param worldMatrix is the world matrix of the particle system
  83138. * @param directionToUpdate is the direction vector to update with the result
  83139. * @param particle is the particle we are computed the direction for
  83140. */
  83141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83142. /**
  83143. * Called by the particle System when the position is computed for the created particle.
  83144. * @param worldMatrix is the world matrix of the particle system
  83145. * @param positionToUpdate is the position vector to update with the result
  83146. * @param particle is the particle we are computed the position for
  83147. */
  83148. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83149. /**
  83150. * Clones the current emitter and returns a copy of it
  83151. * @returns the new emitter
  83152. */
  83153. clone(): HemisphericParticleEmitter;
  83154. /**
  83155. * Called by the GPUParticleSystem to setup the update shader
  83156. * @param effect defines the update shader
  83157. */
  83158. applyToShader(effect: Effect): void;
  83159. /**
  83160. * Returns a string to use to update the GPU particles update shader
  83161. * @returns a string containng the defines string
  83162. */
  83163. getEffectDefines(): string;
  83164. /**
  83165. * Returns the string "HemisphericParticleEmitter"
  83166. * @returns a string containing the class name
  83167. */
  83168. getClassName(): string;
  83169. /**
  83170. * Serializes the particle system to a JSON object.
  83171. * @returns the JSON object
  83172. */
  83173. serialize(): any;
  83174. /**
  83175. * Parse properties from a JSON object
  83176. * @param serializationObject defines the JSON object
  83177. */
  83178. parse(serializationObject: any): void;
  83179. }
  83180. }
  83181. declare module BABYLON {
  83182. /**
  83183. * Particle emitter emitting particles from a point.
  83184. * It emits the particles randomly between 2 given directions.
  83185. */
  83186. export class PointParticleEmitter implements IParticleEmitterType {
  83187. /**
  83188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83189. */
  83190. direction1: Vector3;
  83191. /**
  83192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83193. */
  83194. direction2: Vector3;
  83195. /**
  83196. * Creates a new instance PointParticleEmitter
  83197. */
  83198. constructor();
  83199. /**
  83200. * Called by the particle System when the direction is computed for the created particle.
  83201. * @param worldMatrix is the world matrix of the particle system
  83202. * @param directionToUpdate is the direction vector to update with the result
  83203. * @param particle is the particle we are computed the direction for
  83204. */
  83205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83206. /**
  83207. * Called by the particle System when the position is computed for the created particle.
  83208. * @param worldMatrix is the world matrix of the particle system
  83209. * @param positionToUpdate is the position vector to update with the result
  83210. * @param particle is the particle we are computed the position for
  83211. */
  83212. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83213. /**
  83214. * Clones the current emitter and returns a copy of it
  83215. * @returns the new emitter
  83216. */
  83217. clone(): PointParticleEmitter;
  83218. /**
  83219. * Called by the GPUParticleSystem to setup the update shader
  83220. * @param effect defines the update shader
  83221. */
  83222. applyToShader(effect: Effect): void;
  83223. /**
  83224. * Returns a string to use to update the GPU particles update shader
  83225. * @returns a string containng the defines string
  83226. */
  83227. getEffectDefines(): string;
  83228. /**
  83229. * Returns the string "PointParticleEmitter"
  83230. * @returns a string containing the class name
  83231. */
  83232. getClassName(): string;
  83233. /**
  83234. * Serializes the particle system to a JSON object.
  83235. * @returns the JSON object
  83236. */
  83237. serialize(): any;
  83238. /**
  83239. * Parse properties from a JSON object
  83240. * @param serializationObject defines the JSON object
  83241. */
  83242. parse(serializationObject: any): void;
  83243. }
  83244. }
  83245. declare module BABYLON {
  83246. /**
  83247. * Particle emitter emitting particles from the inside of a sphere.
  83248. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83249. */
  83250. export class SphereParticleEmitter implements IParticleEmitterType {
  83251. /**
  83252. * The radius of the emission sphere.
  83253. */
  83254. radius: number;
  83255. /**
  83256. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83257. */
  83258. radiusRange: number;
  83259. /**
  83260. * How much to randomize the particle direction [0-1].
  83261. */
  83262. directionRandomizer: number;
  83263. /**
  83264. * Creates a new instance SphereParticleEmitter
  83265. * @param radius the radius of the emission sphere (1 by default)
  83266. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83267. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83268. */
  83269. constructor(
  83270. /**
  83271. * The radius of the emission sphere.
  83272. */
  83273. radius?: number,
  83274. /**
  83275. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83276. */
  83277. radiusRange?: number,
  83278. /**
  83279. * How much to randomize the particle direction [0-1].
  83280. */
  83281. directionRandomizer?: number);
  83282. /**
  83283. * Called by the particle System when the direction is computed for the created particle.
  83284. * @param worldMatrix is the world matrix of the particle system
  83285. * @param directionToUpdate is the direction vector to update with the result
  83286. * @param particle is the particle we are computed the direction for
  83287. */
  83288. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83289. /**
  83290. * Called by the particle System when the position is computed for the created particle.
  83291. * @param worldMatrix is the world matrix of the particle system
  83292. * @param positionToUpdate is the position vector to update with the result
  83293. * @param particle is the particle we are computed the position for
  83294. */
  83295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83296. /**
  83297. * Clones the current emitter and returns a copy of it
  83298. * @returns the new emitter
  83299. */
  83300. clone(): SphereParticleEmitter;
  83301. /**
  83302. * Called by the GPUParticleSystem to setup the update shader
  83303. * @param effect defines the update shader
  83304. */
  83305. applyToShader(effect: Effect): void;
  83306. /**
  83307. * Returns a string to use to update the GPU particles update shader
  83308. * @returns a string containng the defines string
  83309. */
  83310. getEffectDefines(): string;
  83311. /**
  83312. * Returns the string "SphereParticleEmitter"
  83313. * @returns a string containing the class name
  83314. */
  83315. getClassName(): string;
  83316. /**
  83317. * Serializes the particle system to a JSON object.
  83318. * @returns the JSON object
  83319. */
  83320. serialize(): any;
  83321. /**
  83322. * Parse properties from a JSON object
  83323. * @param serializationObject defines the JSON object
  83324. */
  83325. parse(serializationObject: any): void;
  83326. }
  83327. /**
  83328. * Particle emitter emitting particles from the inside of a sphere.
  83329. * It emits the particles randomly between two vectors.
  83330. */
  83331. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83332. /**
  83333. * The min limit of the emission direction.
  83334. */
  83335. direction1: Vector3;
  83336. /**
  83337. * The max limit of the emission direction.
  83338. */
  83339. direction2: Vector3;
  83340. /**
  83341. * Creates a new instance SphereDirectedParticleEmitter
  83342. * @param radius the radius of the emission sphere (1 by default)
  83343. * @param direction1 the min limit of the emission direction (up vector by default)
  83344. * @param direction2 the max limit of the emission direction (up vector by default)
  83345. */
  83346. constructor(radius?: number,
  83347. /**
  83348. * The min limit of the emission direction.
  83349. */
  83350. direction1?: Vector3,
  83351. /**
  83352. * The max limit of the emission direction.
  83353. */
  83354. direction2?: Vector3);
  83355. /**
  83356. * Called by the particle System when the direction is computed for the created particle.
  83357. * @param worldMatrix is the world matrix of the particle system
  83358. * @param directionToUpdate is the direction vector to update with the result
  83359. * @param particle is the particle we are computed the direction for
  83360. */
  83361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83362. /**
  83363. * Clones the current emitter and returns a copy of it
  83364. * @returns the new emitter
  83365. */
  83366. clone(): SphereDirectedParticleEmitter;
  83367. /**
  83368. * Called by the GPUParticleSystem to setup the update shader
  83369. * @param effect defines the update shader
  83370. */
  83371. applyToShader(effect: Effect): void;
  83372. /**
  83373. * Returns a string to use to update the GPU particles update shader
  83374. * @returns a string containng the defines string
  83375. */
  83376. getEffectDefines(): string;
  83377. /**
  83378. * Returns the string "SphereDirectedParticleEmitter"
  83379. * @returns a string containing the class name
  83380. */
  83381. getClassName(): string;
  83382. /**
  83383. * Serializes the particle system to a JSON object.
  83384. * @returns the JSON object
  83385. */
  83386. serialize(): any;
  83387. /**
  83388. * Parse properties from a JSON object
  83389. * @param serializationObject defines the JSON object
  83390. */
  83391. parse(serializationObject: any): void;
  83392. }
  83393. }
  83394. declare module BABYLON {
  83395. /**
  83396. * Interface representing a particle system in Babylon.js.
  83397. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83398. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83399. */
  83400. export interface IParticleSystem {
  83401. /**
  83402. * List of animations used by the particle system.
  83403. */
  83404. animations: Animation[];
  83405. /**
  83406. * The id of the Particle system.
  83407. */
  83408. id: string;
  83409. /**
  83410. * The name of the Particle system.
  83411. */
  83412. name: string;
  83413. /**
  83414. * The emitter represents the Mesh or position we are attaching the particle system to.
  83415. */
  83416. emitter: Nullable<AbstractMesh | Vector3>;
  83417. /**
  83418. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83419. */
  83420. isBillboardBased: boolean;
  83421. /**
  83422. * The rendering group used by the Particle system to chose when to render.
  83423. */
  83424. renderingGroupId: number;
  83425. /**
  83426. * The layer mask we are rendering the particles through.
  83427. */
  83428. layerMask: number;
  83429. /**
  83430. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83431. */
  83432. updateSpeed: number;
  83433. /**
  83434. * The amount of time the particle system is running (depends of the overall update speed).
  83435. */
  83436. targetStopDuration: number;
  83437. /**
  83438. * The texture used to render each particle. (this can be a spritesheet)
  83439. */
  83440. particleTexture: Nullable<Texture>;
  83441. /**
  83442. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83443. */
  83444. blendMode: number;
  83445. /**
  83446. * Minimum life time of emitting particles.
  83447. */
  83448. minLifeTime: number;
  83449. /**
  83450. * Maximum life time of emitting particles.
  83451. */
  83452. maxLifeTime: number;
  83453. /**
  83454. * Minimum Size of emitting particles.
  83455. */
  83456. minSize: number;
  83457. /**
  83458. * Maximum Size of emitting particles.
  83459. */
  83460. maxSize: number;
  83461. /**
  83462. * Minimum scale of emitting particles on X axis.
  83463. */
  83464. minScaleX: number;
  83465. /**
  83466. * Maximum scale of emitting particles on X axis.
  83467. */
  83468. maxScaleX: number;
  83469. /**
  83470. * Minimum scale of emitting particles on Y axis.
  83471. */
  83472. minScaleY: number;
  83473. /**
  83474. * Maximum scale of emitting particles on Y axis.
  83475. */
  83476. maxScaleY: number;
  83477. /**
  83478. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83479. */
  83480. color1: Color4;
  83481. /**
  83482. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83483. */
  83484. color2: Color4;
  83485. /**
  83486. * Color the particle will have at the end of its lifetime.
  83487. */
  83488. colorDead: Color4;
  83489. /**
  83490. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83491. */
  83492. emitRate: number;
  83493. /**
  83494. * You can use gravity if you want to give an orientation to your particles.
  83495. */
  83496. gravity: Vector3;
  83497. /**
  83498. * Minimum power of emitting particles.
  83499. */
  83500. minEmitPower: number;
  83501. /**
  83502. * Maximum power of emitting particles.
  83503. */
  83504. maxEmitPower: number;
  83505. /**
  83506. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83507. */
  83508. minAngularSpeed: number;
  83509. /**
  83510. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83511. */
  83512. maxAngularSpeed: number;
  83513. /**
  83514. * Gets or sets the minimal initial rotation in radians.
  83515. */
  83516. minInitialRotation: number;
  83517. /**
  83518. * Gets or sets the maximal initial rotation in radians.
  83519. */
  83520. maxInitialRotation: number;
  83521. /**
  83522. * The particle emitter type defines the emitter used by the particle system.
  83523. * It can be for example box, sphere, or cone...
  83524. */
  83525. particleEmitterType: Nullable<IParticleEmitterType>;
  83526. /**
  83527. * Defines the delay in milliseconds before starting the system (0 by default)
  83528. */
  83529. startDelay: number;
  83530. /**
  83531. * 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
  83532. */
  83533. preWarmCycles: number;
  83534. /**
  83535. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83536. */
  83537. preWarmStepOffset: number;
  83538. /**
  83539. * 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)
  83540. */
  83541. spriteCellChangeSpeed: number;
  83542. /**
  83543. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83544. */
  83545. startSpriteCellID: number;
  83546. /**
  83547. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83548. */
  83549. endSpriteCellID: number;
  83550. /**
  83551. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83552. */
  83553. spriteCellWidth: number;
  83554. /**
  83555. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83556. */
  83557. spriteCellHeight: number;
  83558. /**
  83559. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83560. */
  83561. spriteRandomStartCell: boolean;
  83562. /**
  83563. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83564. */
  83565. isAnimationSheetEnabled: boolean;
  83566. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83567. translationPivot: Vector2;
  83568. /**
  83569. * Gets or sets a texture used to add random noise to particle positions
  83570. */
  83571. noiseTexture: Nullable<BaseTexture>;
  83572. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83573. noiseStrength: Vector3;
  83574. /**
  83575. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83576. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83577. */
  83578. billboardMode: number;
  83579. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83580. limitVelocityDamping: number;
  83581. /**
  83582. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83583. */
  83584. beginAnimationOnStart: boolean;
  83585. /**
  83586. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83587. */
  83588. beginAnimationFrom: number;
  83589. /**
  83590. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83591. */
  83592. beginAnimationTo: number;
  83593. /**
  83594. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83595. */
  83596. beginAnimationLoop: boolean;
  83597. /**
  83598. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83599. */
  83600. disposeOnStop: boolean;
  83601. /**
  83602. * Gets the maximum number of particles active at the same time.
  83603. * @returns The max number of active particles.
  83604. */
  83605. getCapacity(): number;
  83606. /**
  83607. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83608. * @returns True if it has been started, otherwise false.
  83609. */
  83610. isStarted(): boolean;
  83611. /**
  83612. * Animates the particle system for this frame.
  83613. */
  83614. animate(): void;
  83615. /**
  83616. * Renders the particle system in its current state.
  83617. * @returns the current number of particles
  83618. */
  83619. render(): number;
  83620. /**
  83621. * Dispose the particle system and frees its associated resources.
  83622. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83623. */
  83624. dispose(disposeTexture?: boolean): void;
  83625. /**
  83626. * Clones the particle system.
  83627. * @param name The name of the cloned object
  83628. * @param newEmitter The new emitter to use
  83629. * @returns the cloned particle system
  83630. */
  83631. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83632. /**
  83633. * Serializes the particle system to a JSON object.
  83634. * @returns the JSON object
  83635. */
  83636. serialize(): any;
  83637. /**
  83638. * Rebuild the particle system
  83639. */
  83640. rebuild(): void;
  83641. /**
  83642. * Starts the particle system and begins to emit
  83643. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83644. */
  83645. start(delay?: number): void;
  83646. /**
  83647. * Stops the particle system.
  83648. */
  83649. stop(): void;
  83650. /**
  83651. * Remove all active particles
  83652. */
  83653. reset(): void;
  83654. /**
  83655. * Is this system ready to be used/rendered
  83656. * @return true if the system is ready
  83657. */
  83658. isReady(): boolean;
  83659. /**
  83660. * Adds a new color gradient
  83661. * @param gradient defines the gradient to use (between 0 and 1)
  83662. * @param color1 defines the color to affect to the specified gradient
  83663. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83664. * @returns the current particle system
  83665. */
  83666. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83667. /**
  83668. * Remove a specific color gradient
  83669. * @param gradient defines the gradient to remove
  83670. * @returns the current particle system
  83671. */
  83672. removeColorGradient(gradient: number): IParticleSystem;
  83673. /**
  83674. * Adds a new size gradient
  83675. * @param gradient defines the gradient to use (between 0 and 1)
  83676. * @param factor defines the size factor to affect to the specified gradient
  83677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83678. * @returns the current particle system
  83679. */
  83680. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83681. /**
  83682. * Remove a specific size gradient
  83683. * @param gradient defines the gradient to remove
  83684. * @returns the current particle system
  83685. */
  83686. removeSizeGradient(gradient: number): IParticleSystem;
  83687. /**
  83688. * Gets the current list of color gradients.
  83689. * You must use addColorGradient and removeColorGradient to udpate this list
  83690. * @returns the list of color gradients
  83691. */
  83692. getColorGradients(): Nullable<Array<ColorGradient>>;
  83693. /**
  83694. * Gets the current list of size gradients.
  83695. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83696. * @returns the list of size gradients
  83697. */
  83698. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83699. /**
  83700. * Gets the current list of angular speed gradients.
  83701. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83702. * @returns the list of angular speed gradients
  83703. */
  83704. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83705. /**
  83706. * Adds a new angular speed gradient
  83707. * @param gradient defines the gradient to use (between 0 and 1)
  83708. * @param factor defines the angular speed to affect to the specified gradient
  83709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83710. * @returns the current particle system
  83711. */
  83712. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83713. /**
  83714. * Remove a specific angular speed gradient
  83715. * @param gradient defines the gradient to remove
  83716. * @returns the current particle system
  83717. */
  83718. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83719. /**
  83720. * Gets the current list of velocity gradients.
  83721. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83722. * @returns the list of velocity gradients
  83723. */
  83724. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83725. /**
  83726. * Adds a new velocity gradient
  83727. * @param gradient defines the gradient to use (between 0 and 1)
  83728. * @param factor defines the velocity to affect to the specified gradient
  83729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83730. * @returns the current particle system
  83731. */
  83732. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83733. /**
  83734. * Remove a specific velocity gradient
  83735. * @param gradient defines the gradient to remove
  83736. * @returns the current particle system
  83737. */
  83738. removeVelocityGradient(gradient: number): IParticleSystem;
  83739. /**
  83740. * Gets the current list of limit velocity gradients.
  83741. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83742. * @returns the list of limit velocity gradients
  83743. */
  83744. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83745. /**
  83746. * Adds a new limit velocity gradient
  83747. * @param gradient defines the gradient to use (between 0 and 1)
  83748. * @param factor defines the limit velocity to affect to the specified gradient
  83749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83750. * @returns the current particle system
  83751. */
  83752. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83753. /**
  83754. * Remove a specific limit velocity gradient
  83755. * @param gradient defines the gradient to remove
  83756. * @returns the current particle system
  83757. */
  83758. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83759. /**
  83760. * Adds a new drag gradient
  83761. * @param gradient defines the gradient to use (between 0 and 1)
  83762. * @param factor defines the drag to affect to the specified gradient
  83763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83764. * @returns the current particle system
  83765. */
  83766. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83767. /**
  83768. * Remove a specific drag gradient
  83769. * @param gradient defines the gradient to remove
  83770. * @returns the current particle system
  83771. */
  83772. removeDragGradient(gradient: number): IParticleSystem;
  83773. /**
  83774. * Gets the current list of drag gradients.
  83775. * You must use addDragGradient and removeDragGradient to udpate this list
  83776. * @returns the list of drag gradients
  83777. */
  83778. getDragGradients(): Nullable<Array<FactorGradient>>;
  83779. /**
  83780. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83781. * @param gradient defines the gradient to use (between 0 and 1)
  83782. * @param factor defines the emit rate to affect to the specified gradient
  83783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83784. * @returns the current particle system
  83785. */
  83786. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83787. /**
  83788. * Remove a specific emit rate gradient
  83789. * @param gradient defines the gradient to remove
  83790. * @returns the current particle system
  83791. */
  83792. removeEmitRateGradient(gradient: number): IParticleSystem;
  83793. /**
  83794. * Gets the current list of emit rate gradients.
  83795. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83796. * @returns the list of emit rate gradients
  83797. */
  83798. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83799. /**
  83800. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83801. * @param gradient defines the gradient to use (between 0 and 1)
  83802. * @param factor defines the start size to affect to the specified gradient
  83803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83804. * @returns the current particle system
  83805. */
  83806. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83807. /**
  83808. * Remove a specific start size gradient
  83809. * @param gradient defines the gradient to remove
  83810. * @returns the current particle system
  83811. */
  83812. removeStartSizeGradient(gradient: number): IParticleSystem;
  83813. /**
  83814. * Gets the current list of start size gradients.
  83815. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83816. * @returns the list of start size gradients
  83817. */
  83818. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83819. /**
  83820. * Adds a new life time gradient
  83821. * @param gradient defines the gradient to use (between 0 and 1)
  83822. * @param factor defines the life time factor to affect to the specified gradient
  83823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83824. * @returns the current particle system
  83825. */
  83826. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83827. /**
  83828. * Remove a specific life time gradient
  83829. * @param gradient defines the gradient to remove
  83830. * @returns the current particle system
  83831. */
  83832. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83833. /**
  83834. * Gets the current list of life time gradients.
  83835. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83836. * @returns the list of life time gradients
  83837. */
  83838. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83839. /**
  83840. * Gets the current list of color gradients.
  83841. * You must use addColorGradient and removeColorGradient to udpate this list
  83842. * @returns the list of color gradients
  83843. */
  83844. getColorGradients(): Nullable<Array<ColorGradient>>;
  83845. /**
  83846. * Adds a new ramp gradient used to remap particle colors
  83847. * @param gradient defines the gradient to use (between 0 and 1)
  83848. * @param color defines the color to affect to the specified gradient
  83849. * @returns the current particle system
  83850. */
  83851. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83852. /**
  83853. * Gets the current list of ramp gradients.
  83854. * You must use addRampGradient and removeRampGradient to udpate this list
  83855. * @returns the list of ramp gradients
  83856. */
  83857. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83858. /** Gets or sets a boolean indicating that ramp gradients must be used
  83859. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83860. */
  83861. useRampGradients: boolean;
  83862. /**
  83863. * Adds a new color remap gradient
  83864. * @param gradient defines the gradient to use (between 0 and 1)
  83865. * @param min defines the color remap minimal range
  83866. * @param max defines the color remap maximal range
  83867. * @returns the current particle system
  83868. */
  83869. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83870. /**
  83871. * Gets the current list of color remap gradients.
  83872. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83873. * @returns the list of color remap gradients
  83874. */
  83875. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83876. /**
  83877. * Adds a new alpha remap gradient
  83878. * @param gradient defines the gradient to use (between 0 and 1)
  83879. * @param min defines the alpha remap minimal range
  83880. * @param max defines the alpha remap maximal range
  83881. * @returns the current particle system
  83882. */
  83883. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83884. /**
  83885. * Gets the current list of alpha remap gradients.
  83886. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83887. * @returns the list of alpha remap gradients
  83888. */
  83889. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83890. /**
  83891. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83892. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83893. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83894. * @returns the emitter
  83895. */
  83896. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83897. /**
  83898. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83899. * @param radius The radius of the hemisphere to emit from
  83900. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83901. * @returns the emitter
  83902. */
  83903. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83904. /**
  83905. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83906. * @param radius The radius of the sphere to emit from
  83907. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83908. * @returns the emitter
  83909. */
  83910. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83911. /**
  83912. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83913. * @param radius The radius of the sphere to emit from
  83914. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83915. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83916. * @returns the emitter
  83917. */
  83918. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83919. /**
  83920. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83921. * @param radius The radius of the emission cylinder
  83922. * @param height The height of the emission cylinder
  83923. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83924. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83925. * @returns the emitter
  83926. */
  83927. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83928. /**
  83929. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83930. * @param radius The radius of the cylinder to emit from
  83931. * @param height The height of the emission cylinder
  83932. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83933. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83934. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83935. * @returns the emitter
  83936. */
  83937. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83938. /**
  83939. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83940. * @param radius The radius of the cone to emit from
  83941. * @param angle The base angle of the cone
  83942. * @returns the emitter
  83943. */
  83944. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83945. /**
  83946. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83947. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83948. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83949. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83950. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83951. * @returns the emitter
  83952. */
  83953. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83954. /**
  83955. * Get hosting scene
  83956. * @returns the scene
  83957. */
  83958. getScene(): Scene;
  83959. }
  83960. }
  83961. declare module BABYLON {
  83962. /** @hidden */
  83963. export var linePixelShader: {
  83964. name: string;
  83965. shader: string;
  83966. };
  83967. }
  83968. declare module BABYLON {
  83969. /** @hidden */
  83970. export var lineVertexShader: {
  83971. name: string;
  83972. shader: string;
  83973. };
  83974. }
  83975. declare module BABYLON {
  83976. interface AbstractMesh {
  83977. /**
  83978. * Gets the edgesRenderer associated with the mesh
  83979. */
  83980. edgesRenderer: Nullable<EdgesRenderer>;
  83981. }
  83982. interface LinesMesh {
  83983. /**
  83984. * Enables the edge rendering mode on the mesh.
  83985. * This mode makes the mesh edges visible
  83986. * @param epsilon defines the maximal distance between two angles to detect a face
  83987. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83988. * @returns the currentAbstractMesh
  83989. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83990. */
  83991. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83992. }
  83993. interface InstancedLinesMesh {
  83994. /**
  83995. * Enables the edge rendering mode on the mesh.
  83996. * This mode makes the mesh edges visible
  83997. * @param epsilon defines the maximal distance between two angles to detect a face
  83998. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83999. * @returns the current InstancedLinesMesh
  84000. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84001. */
  84002. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84003. }
  84004. /**
  84005. * Defines the minimum contract an Edges renderer should follow.
  84006. */
  84007. export interface IEdgesRenderer extends IDisposable {
  84008. /**
  84009. * Gets or sets a boolean indicating if the edgesRenderer is active
  84010. */
  84011. isEnabled: boolean;
  84012. /**
  84013. * Renders the edges of the attached mesh,
  84014. */
  84015. render(): void;
  84016. /**
  84017. * Checks wether or not the edges renderer is ready to render.
  84018. * @return true if ready, otherwise false.
  84019. */
  84020. isReady(): boolean;
  84021. }
  84022. /**
  84023. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84024. */
  84025. export class EdgesRenderer implements IEdgesRenderer {
  84026. /**
  84027. * Define the size of the edges with an orthographic camera
  84028. */
  84029. edgesWidthScalerForOrthographic: number;
  84030. /**
  84031. * Define the size of the edges with a perspective camera
  84032. */
  84033. edgesWidthScalerForPerspective: number;
  84034. protected _source: AbstractMesh;
  84035. protected _linesPositions: number[];
  84036. protected _linesNormals: number[];
  84037. protected _linesIndices: number[];
  84038. protected _epsilon: number;
  84039. protected _indicesCount: number;
  84040. protected _lineShader: ShaderMaterial;
  84041. protected _ib: DataBuffer;
  84042. protected _buffers: {
  84043. [key: string]: Nullable<VertexBuffer>;
  84044. };
  84045. protected _checkVerticesInsteadOfIndices: boolean;
  84046. private _meshRebuildObserver;
  84047. private _meshDisposeObserver;
  84048. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84049. isEnabled: boolean;
  84050. /**
  84051. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84052. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84053. * @param source Mesh used to create edges
  84054. * @param epsilon sum of angles in adjacency to check for edge
  84055. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84056. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84057. */
  84058. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84059. protected _prepareRessources(): void;
  84060. /** @hidden */
  84061. _rebuild(): void;
  84062. /**
  84063. * Releases the required resources for the edges renderer
  84064. */
  84065. dispose(): void;
  84066. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84067. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84068. /**
  84069. * Checks if the pair of p0 and p1 is en edge
  84070. * @param faceIndex
  84071. * @param edge
  84072. * @param faceNormals
  84073. * @param p0
  84074. * @param p1
  84075. * @private
  84076. */
  84077. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84078. /**
  84079. * push line into the position, normal and index buffer
  84080. * @protected
  84081. */
  84082. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84083. /**
  84084. * Generates lines edges from adjacencjes
  84085. * @private
  84086. */
  84087. _generateEdgesLines(): void;
  84088. /**
  84089. * Checks wether or not the edges renderer is ready to render.
  84090. * @return true if ready, otherwise false.
  84091. */
  84092. isReady(): boolean;
  84093. /**
  84094. * Renders the edges of the attached mesh,
  84095. */
  84096. render(): void;
  84097. }
  84098. /**
  84099. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84100. */
  84101. export class LineEdgesRenderer extends EdgesRenderer {
  84102. /**
  84103. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84104. * @param source LineMesh used to generate edges
  84105. * @param epsilon not important (specified angle for edge detection)
  84106. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84107. */
  84108. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84109. /**
  84110. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84111. */
  84112. _generateEdgesLines(): void;
  84113. }
  84114. }
  84115. declare module BABYLON {
  84116. /**
  84117. * This represents the object necessary to create a rendering group.
  84118. * This is exclusively used and created by the rendering manager.
  84119. * To modify the behavior, you use the available helpers in your scene or meshes.
  84120. * @hidden
  84121. */
  84122. export class RenderingGroup {
  84123. index: number;
  84124. private static _zeroVector;
  84125. private _scene;
  84126. private _opaqueSubMeshes;
  84127. private _transparentSubMeshes;
  84128. private _alphaTestSubMeshes;
  84129. private _depthOnlySubMeshes;
  84130. private _particleSystems;
  84131. private _spriteManagers;
  84132. private _opaqueSortCompareFn;
  84133. private _alphaTestSortCompareFn;
  84134. private _transparentSortCompareFn;
  84135. private _renderOpaque;
  84136. private _renderAlphaTest;
  84137. private _renderTransparent;
  84138. /** @hidden */
  84139. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84140. onBeforeTransparentRendering: () => void;
  84141. /**
  84142. * Set the opaque sort comparison function.
  84143. * If null the sub meshes will be render in the order they were created
  84144. */
  84145. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84146. /**
  84147. * Set the alpha test sort comparison function.
  84148. * If null the sub meshes will be render in the order they were created
  84149. */
  84150. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84151. /**
  84152. * Set the transparent sort comparison function.
  84153. * If null the sub meshes will be render in the order they were created
  84154. */
  84155. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84156. /**
  84157. * Creates a new rendering group.
  84158. * @param index The rendering group index
  84159. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84160. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84161. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84162. */
  84163. 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>);
  84164. /**
  84165. * Render all the sub meshes contained in the group.
  84166. * @param customRenderFunction Used to override the default render behaviour of the group.
  84167. * @returns true if rendered some submeshes.
  84168. */
  84169. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84170. /**
  84171. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84172. * @param subMeshes The submeshes to render
  84173. */
  84174. private renderOpaqueSorted;
  84175. /**
  84176. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84177. * @param subMeshes The submeshes to render
  84178. */
  84179. private renderAlphaTestSorted;
  84180. /**
  84181. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84182. * @param subMeshes The submeshes to render
  84183. */
  84184. private renderTransparentSorted;
  84185. /**
  84186. * Renders the submeshes in a specified order.
  84187. * @param subMeshes The submeshes to sort before render
  84188. * @param sortCompareFn The comparison function use to sort
  84189. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84190. * @param transparent Specifies to activate blending if true
  84191. */
  84192. private static renderSorted;
  84193. /**
  84194. * Renders the submeshes in the order they were dispatched (no sort applied).
  84195. * @param subMeshes The submeshes to render
  84196. */
  84197. private static renderUnsorted;
  84198. /**
  84199. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84200. * are rendered back to front if in the same alpha index.
  84201. *
  84202. * @param a The first submesh
  84203. * @param b The second submesh
  84204. * @returns The result of the comparison
  84205. */
  84206. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84207. /**
  84208. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84209. * are rendered back to front.
  84210. *
  84211. * @param a The first submesh
  84212. * @param b The second submesh
  84213. * @returns The result of the comparison
  84214. */
  84215. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84216. /**
  84217. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84218. * are rendered front to back (prevent overdraw).
  84219. *
  84220. * @param a The first submesh
  84221. * @param b The second submesh
  84222. * @returns The result of the comparison
  84223. */
  84224. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84225. /**
  84226. * Resets the different lists of submeshes to prepare a new frame.
  84227. */
  84228. prepare(): void;
  84229. dispose(): void;
  84230. /**
  84231. * Inserts the submesh in its correct queue depending on its material.
  84232. * @param subMesh The submesh to dispatch
  84233. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84234. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84235. */
  84236. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84237. dispatchSprites(spriteManager: ISpriteManager): void;
  84238. dispatchParticles(particleSystem: IParticleSystem): void;
  84239. private _renderParticles;
  84240. private _renderSprites;
  84241. }
  84242. }
  84243. declare module BABYLON {
  84244. /**
  84245. * Interface describing the different options available in the rendering manager
  84246. * regarding Auto Clear between groups.
  84247. */
  84248. export interface IRenderingManagerAutoClearSetup {
  84249. /**
  84250. * Defines whether or not autoclear is enable.
  84251. */
  84252. autoClear: boolean;
  84253. /**
  84254. * Defines whether or not to autoclear the depth buffer.
  84255. */
  84256. depth: boolean;
  84257. /**
  84258. * Defines whether or not to autoclear the stencil buffer.
  84259. */
  84260. stencil: boolean;
  84261. }
  84262. /**
  84263. * This class is used by the onRenderingGroupObservable
  84264. */
  84265. export class RenderingGroupInfo {
  84266. /**
  84267. * The Scene that being rendered
  84268. */
  84269. scene: Scene;
  84270. /**
  84271. * The camera currently used for the rendering pass
  84272. */
  84273. camera: Nullable<Camera>;
  84274. /**
  84275. * The ID of the renderingGroup being processed
  84276. */
  84277. renderingGroupId: number;
  84278. }
  84279. /**
  84280. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84281. * It is enable to manage the different groups as well as the different necessary sort functions.
  84282. * This should not be used directly aside of the few static configurations
  84283. */
  84284. export class RenderingManager {
  84285. /**
  84286. * The max id used for rendering groups (not included)
  84287. */
  84288. static MAX_RENDERINGGROUPS: number;
  84289. /**
  84290. * The min id used for rendering groups (included)
  84291. */
  84292. static MIN_RENDERINGGROUPS: number;
  84293. /**
  84294. * Used to globally prevent autoclearing scenes.
  84295. */
  84296. static AUTOCLEAR: boolean;
  84297. /**
  84298. * @hidden
  84299. */
  84300. _useSceneAutoClearSetup: boolean;
  84301. private _scene;
  84302. private _renderingGroups;
  84303. private _depthStencilBufferAlreadyCleaned;
  84304. private _autoClearDepthStencil;
  84305. private _customOpaqueSortCompareFn;
  84306. private _customAlphaTestSortCompareFn;
  84307. private _customTransparentSortCompareFn;
  84308. private _renderingGroupInfo;
  84309. /**
  84310. * Instantiates a new rendering group for a particular scene
  84311. * @param scene Defines the scene the groups belongs to
  84312. */
  84313. constructor(scene: Scene);
  84314. private _clearDepthStencilBuffer;
  84315. /**
  84316. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84317. * @hidden
  84318. */
  84319. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84320. /**
  84321. * Resets the different information of the group to prepare a new frame
  84322. * @hidden
  84323. */
  84324. reset(): void;
  84325. /**
  84326. * Dispose and release the group and its associated resources.
  84327. * @hidden
  84328. */
  84329. dispose(): void;
  84330. /**
  84331. * Clear the info related to rendering groups preventing retention points during dispose.
  84332. */
  84333. freeRenderingGroups(): void;
  84334. private _prepareRenderingGroup;
  84335. /**
  84336. * Add a sprite manager to the rendering manager in order to render it this frame.
  84337. * @param spriteManager Define the sprite manager to render
  84338. */
  84339. dispatchSprites(spriteManager: ISpriteManager): void;
  84340. /**
  84341. * Add a particle system to the rendering manager in order to render it this frame.
  84342. * @param particleSystem Define the particle system to render
  84343. */
  84344. dispatchParticles(particleSystem: IParticleSystem): void;
  84345. /**
  84346. * Add a submesh to the manager in order to render it this frame
  84347. * @param subMesh The submesh to dispatch
  84348. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84349. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84350. */
  84351. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84352. /**
  84353. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84354. * This allowed control for front to back rendering or reversly depending of the special needs.
  84355. *
  84356. * @param renderingGroupId The rendering group id corresponding to its index
  84357. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84358. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84359. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84360. */
  84361. 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;
  84362. /**
  84363. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84364. *
  84365. * @param renderingGroupId The rendering group id corresponding to its index
  84366. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84367. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84368. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84369. */
  84370. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84371. /**
  84372. * Gets the current auto clear configuration for one rendering group of the rendering
  84373. * manager.
  84374. * @param index the rendering group index to get the information for
  84375. * @returns The auto clear setup for the requested rendering group
  84376. */
  84377. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84378. }
  84379. }
  84380. declare module BABYLON {
  84381. /**
  84382. * This Helps creating a texture that will be created from a camera in your scene.
  84383. * It is basically a dynamic texture that could be used to create special effects for instance.
  84384. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84385. */
  84386. export class RenderTargetTexture extends Texture {
  84387. isCube: boolean;
  84388. /**
  84389. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84390. */
  84391. static readonly REFRESHRATE_RENDER_ONCE: number;
  84392. /**
  84393. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84394. */
  84395. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84396. /**
  84397. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84398. * the central point of your effect and can save a lot of performances.
  84399. */
  84400. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84401. /**
  84402. * Use this predicate to dynamically define the list of mesh you want to render.
  84403. * If set, the renderList property will be overwritten.
  84404. */
  84405. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84406. private _renderList;
  84407. /**
  84408. * Use this list to define the list of mesh you want to render.
  84409. */
  84410. renderList: Nullable<Array<AbstractMesh>>;
  84411. private _hookArray;
  84412. /**
  84413. * Define if particles should be rendered in your texture.
  84414. */
  84415. renderParticles: boolean;
  84416. /**
  84417. * Define if sprites should be rendered in your texture.
  84418. */
  84419. renderSprites: boolean;
  84420. /**
  84421. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84422. */
  84423. coordinatesMode: number;
  84424. /**
  84425. * Define the camera used to render the texture.
  84426. */
  84427. activeCamera: Nullable<Camera>;
  84428. /**
  84429. * Override the render function of the texture with your own one.
  84430. */
  84431. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84432. /**
  84433. * Define if camera post processes should be use while rendering the texture.
  84434. */
  84435. useCameraPostProcesses: boolean;
  84436. /**
  84437. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84438. */
  84439. ignoreCameraViewport: boolean;
  84440. private _postProcessManager;
  84441. private _postProcesses;
  84442. private _resizeObserver;
  84443. /**
  84444. * An event triggered when the texture is unbind.
  84445. */
  84446. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84447. /**
  84448. * An event triggered when the texture is unbind.
  84449. */
  84450. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84451. private _onAfterUnbindObserver;
  84452. /**
  84453. * Set a after unbind callback in the texture.
  84454. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84455. */
  84456. onAfterUnbind: () => void;
  84457. /**
  84458. * An event triggered before rendering the texture
  84459. */
  84460. onBeforeRenderObservable: Observable<number>;
  84461. private _onBeforeRenderObserver;
  84462. /**
  84463. * Set a before render callback in the texture.
  84464. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84465. */
  84466. onBeforeRender: (faceIndex: number) => void;
  84467. /**
  84468. * An event triggered after rendering the texture
  84469. */
  84470. onAfterRenderObservable: Observable<number>;
  84471. private _onAfterRenderObserver;
  84472. /**
  84473. * Set a after render callback in the texture.
  84474. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84475. */
  84476. onAfterRender: (faceIndex: number) => void;
  84477. /**
  84478. * An event triggered after the texture clear
  84479. */
  84480. onClearObservable: Observable<Engine>;
  84481. private _onClearObserver;
  84482. /**
  84483. * Set a clear callback in the texture.
  84484. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84485. */
  84486. onClear: (Engine: Engine) => void;
  84487. /**
  84488. * Define the clear color of the Render Target if it should be different from the scene.
  84489. */
  84490. clearColor: Color4;
  84491. protected _size: number | {
  84492. width: number;
  84493. height: number;
  84494. };
  84495. protected _initialSizeParameter: number | {
  84496. width: number;
  84497. height: number;
  84498. } | {
  84499. ratio: number;
  84500. };
  84501. protected _sizeRatio: Nullable<number>;
  84502. /** @hidden */
  84503. _generateMipMaps: boolean;
  84504. protected _renderingManager: RenderingManager;
  84505. /** @hidden */
  84506. _waitingRenderList: string[];
  84507. protected _doNotChangeAspectRatio: boolean;
  84508. protected _currentRefreshId: number;
  84509. protected _refreshRate: number;
  84510. protected _textureMatrix: Matrix;
  84511. protected _samples: number;
  84512. protected _renderTargetOptions: RenderTargetCreationOptions;
  84513. /**
  84514. * Gets render target creation options that were used.
  84515. */
  84516. readonly renderTargetOptions: RenderTargetCreationOptions;
  84517. protected _engine: Engine;
  84518. protected _onRatioRescale(): void;
  84519. /**
  84520. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84521. * It must define where the camera used to render the texture is set
  84522. */
  84523. boundingBoxPosition: Vector3;
  84524. private _boundingBoxSize;
  84525. /**
  84526. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84527. * When defined, the cubemap will switch to local mode
  84528. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84529. * @example https://www.babylonjs-playground.com/#RNASML
  84530. */
  84531. boundingBoxSize: Vector3;
  84532. /**
  84533. * In case the RTT has been created with a depth texture, get the associated
  84534. * depth texture.
  84535. * Otherwise, return null.
  84536. */
  84537. depthStencilTexture: Nullable<InternalTexture>;
  84538. /**
  84539. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84540. * or used a shadow, depth texture...
  84541. * @param name The friendly name of the texture
  84542. * @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)
  84543. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84544. * @param generateMipMaps True if mip maps need to be generated after render.
  84545. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84546. * @param type The type of the buffer in the RTT (int, half float, float...)
  84547. * @param isCube True if a cube texture needs to be created
  84548. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84549. * @param generateDepthBuffer True to generate a depth buffer
  84550. * @param generateStencilBuffer True to generate a stencil buffer
  84551. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84552. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84553. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84554. */
  84555. constructor(name: string, size: number | {
  84556. width: number;
  84557. height: number;
  84558. } | {
  84559. ratio: number;
  84560. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84561. /**
  84562. * Creates a depth stencil texture.
  84563. * This is only available in WebGL 2 or with the depth texture extension available.
  84564. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84565. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84566. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84567. */
  84568. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84569. private _processSizeParameter;
  84570. /**
  84571. * Define the number of samples to use in case of MSAA.
  84572. * It defaults to one meaning no MSAA has been enabled.
  84573. */
  84574. samples: number;
  84575. /**
  84576. * Resets the refresh counter of the texture and start bak from scratch.
  84577. * Could be useful to regenerate the texture if it is setup to render only once.
  84578. */
  84579. resetRefreshCounter(): void;
  84580. /**
  84581. * Define the refresh rate of the texture or the rendering frequency.
  84582. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84583. */
  84584. refreshRate: number;
  84585. /**
  84586. * Adds a post process to the render target rendering passes.
  84587. * @param postProcess define the post process to add
  84588. */
  84589. addPostProcess(postProcess: PostProcess): void;
  84590. /**
  84591. * Clear all the post processes attached to the render target
  84592. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84593. */
  84594. clearPostProcesses(dispose?: boolean): void;
  84595. /**
  84596. * Remove one of the post process from the list of attached post processes to the texture
  84597. * @param postProcess define the post process to remove from the list
  84598. */
  84599. removePostProcess(postProcess: PostProcess): void;
  84600. /** @hidden */
  84601. _shouldRender(): boolean;
  84602. /**
  84603. * Gets the actual render size of the texture.
  84604. * @returns the width of the render size
  84605. */
  84606. getRenderSize(): number;
  84607. /**
  84608. * Gets the actual render width of the texture.
  84609. * @returns the width of the render size
  84610. */
  84611. getRenderWidth(): number;
  84612. /**
  84613. * Gets the actual render height of the texture.
  84614. * @returns the height of the render size
  84615. */
  84616. getRenderHeight(): number;
  84617. /**
  84618. * Get if the texture can be rescaled or not.
  84619. */
  84620. readonly canRescale: boolean;
  84621. /**
  84622. * Resize the texture using a ratio.
  84623. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84624. */
  84625. scale(ratio: number): void;
  84626. /**
  84627. * Get the texture reflection matrix used to rotate/transform the reflection.
  84628. * @returns the reflection matrix
  84629. */
  84630. getReflectionTextureMatrix(): Matrix;
  84631. /**
  84632. * Resize the texture to a new desired size.
  84633. * Be carrefull as it will recreate all the data in the new texture.
  84634. * @param size Define the new size. It can be:
  84635. * - a number for squared texture,
  84636. * - an object containing { width: number, height: number }
  84637. * - or an object containing a ratio { ratio: number }
  84638. */
  84639. resize(size: number | {
  84640. width: number;
  84641. height: number;
  84642. } | {
  84643. ratio: number;
  84644. }): void;
  84645. /**
  84646. * Renders all the objects from the render list into the texture.
  84647. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84648. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84649. */
  84650. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84651. private _bestReflectionRenderTargetDimension;
  84652. /**
  84653. * @hidden
  84654. * @param faceIndex face index to bind to if this is a cubetexture
  84655. */
  84656. _bindFrameBuffer(faceIndex?: number): void;
  84657. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84658. private renderToTarget;
  84659. /**
  84660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84661. * This allowed control for front to back rendering or reversly depending of the special needs.
  84662. *
  84663. * @param renderingGroupId The rendering group id corresponding to its index
  84664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84667. */
  84668. 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;
  84669. /**
  84670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84671. *
  84672. * @param renderingGroupId The rendering group id corresponding to its index
  84673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84674. */
  84675. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84676. /**
  84677. * Clones the texture.
  84678. * @returns the cloned texture
  84679. */
  84680. clone(): RenderTargetTexture;
  84681. /**
  84682. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84683. * @returns The JSON representation of the texture
  84684. */
  84685. serialize(): any;
  84686. /**
  84687. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84688. */
  84689. disposeFramebufferObjects(): void;
  84690. /**
  84691. * Dispose the texture and release its associated resources.
  84692. */
  84693. dispose(): void;
  84694. /** @hidden */
  84695. _rebuild(): void;
  84696. /**
  84697. * Clear the info related to rendering groups preventing retention point in material dispose.
  84698. */
  84699. freeRenderingGroups(): void;
  84700. /**
  84701. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84702. * @returns the view count
  84703. */
  84704. getViewCount(): number;
  84705. }
  84706. }
  84707. declare module BABYLON {
  84708. /**
  84709. * Base class for the main features of a material in Babylon.js
  84710. */
  84711. export class Material implements IAnimatable {
  84712. /**
  84713. * Returns the triangle fill mode
  84714. */
  84715. static readonly TriangleFillMode: number;
  84716. /**
  84717. * Returns the wireframe mode
  84718. */
  84719. static readonly WireFrameFillMode: number;
  84720. /**
  84721. * Returns the point fill mode
  84722. */
  84723. static readonly PointFillMode: number;
  84724. /**
  84725. * Returns the point list draw mode
  84726. */
  84727. static readonly PointListDrawMode: number;
  84728. /**
  84729. * Returns the line list draw mode
  84730. */
  84731. static readonly LineListDrawMode: number;
  84732. /**
  84733. * Returns the line loop draw mode
  84734. */
  84735. static readonly LineLoopDrawMode: number;
  84736. /**
  84737. * Returns the line strip draw mode
  84738. */
  84739. static readonly LineStripDrawMode: number;
  84740. /**
  84741. * Returns the triangle strip draw mode
  84742. */
  84743. static readonly TriangleStripDrawMode: number;
  84744. /**
  84745. * Returns the triangle fan draw mode
  84746. */
  84747. static readonly TriangleFanDrawMode: number;
  84748. /**
  84749. * Stores the clock-wise side orientation
  84750. */
  84751. static readonly ClockWiseSideOrientation: number;
  84752. /**
  84753. * Stores the counter clock-wise side orientation
  84754. */
  84755. static readonly CounterClockWiseSideOrientation: number;
  84756. /**
  84757. * The dirty texture flag value
  84758. */
  84759. static readonly TextureDirtyFlag: number;
  84760. /**
  84761. * The dirty light flag value
  84762. */
  84763. static readonly LightDirtyFlag: number;
  84764. /**
  84765. * The dirty fresnel flag value
  84766. */
  84767. static readonly FresnelDirtyFlag: number;
  84768. /**
  84769. * The dirty attribute flag value
  84770. */
  84771. static readonly AttributesDirtyFlag: number;
  84772. /**
  84773. * The dirty misc flag value
  84774. */
  84775. static readonly MiscDirtyFlag: number;
  84776. /**
  84777. * The all dirty flag value
  84778. */
  84779. static readonly AllDirtyFlag: number;
  84780. /**
  84781. * The ID of the material
  84782. */
  84783. id: string;
  84784. /**
  84785. * Gets or sets the unique id of the material
  84786. */
  84787. uniqueId: number;
  84788. /**
  84789. * The name of the material
  84790. */
  84791. name: string;
  84792. /**
  84793. * Gets or sets user defined metadata
  84794. */
  84795. metadata: any;
  84796. /**
  84797. * For internal use only. Please do not use.
  84798. */
  84799. reservedDataStore: any;
  84800. /**
  84801. * Specifies if the ready state should be checked on each call
  84802. */
  84803. checkReadyOnEveryCall: boolean;
  84804. /**
  84805. * Specifies if the ready state should be checked once
  84806. */
  84807. checkReadyOnlyOnce: boolean;
  84808. /**
  84809. * The state of the material
  84810. */
  84811. state: string;
  84812. /**
  84813. * The alpha value of the material
  84814. */
  84815. protected _alpha: number;
  84816. /**
  84817. * List of inspectable custom properties (used by the Inspector)
  84818. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84819. */
  84820. inspectableCustomProperties: IInspectable[];
  84821. /**
  84822. * Sets the alpha value of the material
  84823. */
  84824. /**
  84825. * Gets the alpha value of the material
  84826. */
  84827. alpha: number;
  84828. /**
  84829. * Specifies if back face culling is enabled
  84830. */
  84831. protected _backFaceCulling: boolean;
  84832. /**
  84833. * Sets the back-face culling state
  84834. */
  84835. /**
  84836. * Gets the back-face culling state
  84837. */
  84838. backFaceCulling: boolean;
  84839. /**
  84840. * Stores the value for side orientation
  84841. */
  84842. sideOrientation: number;
  84843. /**
  84844. * Callback triggered when the material is compiled
  84845. */
  84846. onCompiled: Nullable<(effect: Effect) => void>;
  84847. /**
  84848. * Callback triggered when an error occurs
  84849. */
  84850. onError: Nullable<(effect: Effect, errors: string) => void>;
  84851. /**
  84852. * Callback triggered to get the render target textures
  84853. */
  84854. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84855. /**
  84856. * Gets a boolean indicating that current material needs to register RTT
  84857. */
  84858. readonly hasRenderTargetTextures: boolean;
  84859. /**
  84860. * Specifies if the material should be serialized
  84861. */
  84862. doNotSerialize: boolean;
  84863. /**
  84864. * @hidden
  84865. */
  84866. _storeEffectOnSubMeshes: boolean;
  84867. /**
  84868. * Stores the animations for the material
  84869. */
  84870. animations: Nullable<Array<Animation>>;
  84871. /**
  84872. * An event triggered when the material is disposed
  84873. */
  84874. onDisposeObservable: Observable<Material>;
  84875. /**
  84876. * An observer which watches for dispose events
  84877. */
  84878. private _onDisposeObserver;
  84879. private _onUnBindObservable;
  84880. /**
  84881. * Called during a dispose event
  84882. */
  84883. onDispose: () => void;
  84884. private _onBindObservable;
  84885. /**
  84886. * An event triggered when the material is bound
  84887. */
  84888. readonly onBindObservable: Observable<AbstractMesh>;
  84889. /**
  84890. * An observer which watches for bind events
  84891. */
  84892. private _onBindObserver;
  84893. /**
  84894. * Called during a bind event
  84895. */
  84896. onBind: (Mesh: AbstractMesh) => void;
  84897. /**
  84898. * An event triggered when the material is unbound
  84899. */
  84900. readonly onUnBindObservable: Observable<Material>;
  84901. /**
  84902. * Stores the value of the alpha mode
  84903. */
  84904. private _alphaMode;
  84905. /**
  84906. * Sets the value of the alpha mode.
  84907. *
  84908. * | Value | Type | Description |
  84909. * | --- | --- | --- |
  84910. * | 0 | ALPHA_DISABLE | |
  84911. * | 1 | ALPHA_ADD | |
  84912. * | 2 | ALPHA_COMBINE | |
  84913. * | 3 | ALPHA_SUBTRACT | |
  84914. * | 4 | ALPHA_MULTIPLY | |
  84915. * | 5 | ALPHA_MAXIMIZED | |
  84916. * | 6 | ALPHA_ONEONE | |
  84917. * | 7 | ALPHA_PREMULTIPLIED | |
  84918. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84919. * | 9 | ALPHA_INTERPOLATE | |
  84920. * | 10 | ALPHA_SCREENMODE | |
  84921. *
  84922. */
  84923. /**
  84924. * Gets the value of the alpha mode
  84925. */
  84926. alphaMode: number;
  84927. /**
  84928. * Stores the state of the need depth pre-pass value
  84929. */
  84930. private _needDepthPrePass;
  84931. /**
  84932. * Sets the need depth pre-pass value
  84933. */
  84934. /**
  84935. * Gets the depth pre-pass value
  84936. */
  84937. needDepthPrePass: boolean;
  84938. /**
  84939. * Specifies if depth writing should be disabled
  84940. */
  84941. disableDepthWrite: boolean;
  84942. /**
  84943. * Specifies if depth writing should be forced
  84944. */
  84945. forceDepthWrite: boolean;
  84946. /**
  84947. * Specifies if there should be a separate pass for culling
  84948. */
  84949. separateCullingPass: boolean;
  84950. /**
  84951. * Stores the state specifing if fog should be enabled
  84952. */
  84953. private _fogEnabled;
  84954. /**
  84955. * Sets the state for enabling fog
  84956. */
  84957. /**
  84958. * Gets the value of the fog enabled state
  84959. */
  84960. fogEnabled: boolean;
  84961. /**
  84962. * Stores the size of points
  84963. */
  84964. pointSize: number;
  84965. /**
  84966. * Stores the z offset value
  84967. */
  84968. zOffset: number;
  84969. /**
  84970. * Gets a value specifying if wireframe mode is enabled
  84971. */
  84972. /**
  84973. * Sets the state of wireframe mode
  84974. */
  84975. wireframe: boolean;
  84976. /**
  84977. * Gets the value specifying if point clouds are enabled
  84978. */
  84979. /**
  84980. * Sets the state of point cloud mode
  84981. */
  84982. pointsCloud: boolean;
  84983. /**
  84984. * Gets the material fill mode
  84985. */
  84986. /**
  84987. * Sets the material fill mode
  84988. */
  84989. fillMode: number;
  84990. /**
  84991. * @hidden
  84992. * Stores the effects for the material
  84993. */
  84994. _effect: Nullable<Effect>;
  84995. /**
  84996. * @hidden
  84997. * Specifies if the material was previously ready
  84998. */
  84999. _wasPreviouslyReady: boolean;
  85000. /**
  85001. * Specifies if uniform buffers should be used
  85002. */
  85003. private _useUBO;
  85004. /**
  85005. * Stores a reference to the scene
  85006. */
  85007. private _scene;
  85008. /**
  85009. * Stores the fill mode state
  85010. */
  85011. private _fillMode;
  85012. /**
  85013. * Specifies if the depth write state should be cached
  85014. */
  85015. private _cachedDepthWriteState;
  85016. /**
  85017. * Stores the uniform buffer
  85018. */
  85019. protected _uniformBuffer: UniformBuffer;
  85020. /** @hidden */
  85021. _indexInSceneMaterialArray: number;
  85022. /** @hidden */
  85023. meshMap: Nullable<{
  85024. [id: string]: AbstractMesh | undefined;
  85025. }>;
  85026. /**
  85027. * Creates a material instance
  85028. * @param name defines the name of the material
  85029. * @param scene defines the scene to reference
  85030. * @param doNotAdd specifies if the material should be added to the scene
  85031. */
  85032. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85033. /**
  85034. * Returns a string representation of the current material
  85035. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85036. * @returns a string with material information
  85037. */
  85038. toString(fullDetails?: boolean): string;
  85039. /**
  85040. * Gets the class name of the material
  85041. * @returns a string with the class name of the material
  85042. */
  85043. getClassName(): string;
  85044. /**
  85045. * Specifies if updates for the material been locked
  85046. */
  85047. readonly isFrozen: boolean;
  85048. /**
  85049. * Locks updates for the material
  85050. */
  85051. freeze(): void;
  85052. /**
  85053. * Unlocks updates for the material
  85054. */
  85055. unfreeze(): void;
  85056. /**
  85057. * Specifies if the material is ready to be used
  85058. * @param mesh defines the mesh to check
  85059. * @param useInstances specifies if instances should be used
  85060. * @returns a boolean indicating if the material is ready to be used
  85061. */
  85062. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85063. /**
  85064. * Specifies that the submesh is ready to be used
  85065. * @param mesh defines the mesh to check
  85066. * @param subMesh defines which submesh to check
  85067. * @param useInstances specifies that instances should be used
  85068. * @returns a boolean indicating that the submesh is ready or not
  85069. */
  85070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85071. /**
  85072. * Returns the material effect
  85073. * @returns the effect associated with the material
  85074. */
  85075. getEffect(): Nullable<Effect>;
  85076. /**
  85077. * Returns the current scene
  85078. * @returns a Scene
  85079. */
  85080. getScene(): Scene;
  85081. /**
  85082. * Specifies if the material will require alpha blending
  85083. * @returns a boolean specifying if alpha blending is needed
  85084. */
  85085. needAlphaBlending(): boolean;
  85086. /**
  85087. * Specifies if the mesh will require alpha blending
  85088. * @param mesh defines the mesh to check
  85089. * @returns a boolean specifying if alpha blending is needed for the mesh
  85090. */
  85091. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85092. /**
  85093. * Specifies if this material should be rendered in alpha test mode
  85094. * @returns a boolean specifying if an alpha test is needed.
  85095. */
  85096. needAlphaTesting(): boolean;
  85097. /**
  85098. * Gets the texture used for the alpha test
  85099. * @returns the texture to use for alpha testing
  85100. */
  85101. getAlphaTestTexture(): Nullable<BaseTexture>;
  85102. /**
  85103. * Marks the material to indicate that it needs to be re-calculated
  85104. */
  85105. markDirty(): void;
  85106. /** @hidden */
  85107. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85108. /**
  85109. * Binds the material to the mesh
  85110. * @param world defines the world transformation matrix
  85111. * @param mesh defines the mesh to bind the material to
  85112. */
  85113. bind(world: Matrix, mesh?: Mesh): void;
  85114. /**
  85115. * Binds the submesh to the material
  85116. * @param world defines the world transformation matrix
  85117. * @param mesh defines the mesh containing the submesh
  85118. * @param subMesh defines the submesh to bind the material to
  85119. */
  85120. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85121. /**
  85122. * Binds the world matrix to the material
  85123. * @param world defines the world transformation matrix
  85124. */
  85125. bindOnlyWorldMatrix(world: Matrix): void;
  85126. /**
  85127. * Binds the scene's uniform buffer to the effect.
  85128. * @param effect defines the effect to bind to the scene uniform buffer
  85129. * @param sceneUbo defines the uniform buffer storing scene data
  85130. */
  85131. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85132. /**
  85133. * Binds the view matrix to the effect
  85134. * @param effect defines the effect to bind the view matrix to
  85135. */
  85136. bindView(effect: Effect): void;
  85137. /**
  85138. * Binds the view projection matrix to the effect
  85139. * @param effect defines the effect to bind the view projection matrix to
  85140. */
  85141. bindViewProjection(effect: Effect): void;
  85142. /**
  85143. * Specifies if material alpha testing should be turned on for the mesh
  85144. * @param mesh defines the mesh to check
  85145. */
  85146. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85147. /**
  85148. * Processes to execute after binding the material to a mesh
  85149. * @param mesh defines the rendered mesh
  85150. */
  85151. protected _afterBind(mesh?: Mesh): void;
  85152. /**
  85153. * Unbinds the material from the mesh
  85154. */
  85155. unbind(): void;
  85156. /**
  85157. * Gets the active textures from the material
  85158. * @returns an array of textures
  85159. */
  85160. getActiveTextures(): BaseTexture[];
  85161. /**
  85162. * Specifies if the material uses a texture
  85163. * @param texture defines the texture to check against the material
  85164. * @returns a boolean specifying if the material uses the texture
  85165. */
  85166. hasTexture(texture: BaseTexture): boolean;
  85167. /**
  85168. * Makes a duplicate of the material, and gives it a new name
  85169. * @param name defines the new name for the duplicated material
  85170. * @returns the cloned material
  85171. */
  85172. clone(name: string): Nullable<Material>;
  85173. /**
  85174. * Gets the meshes bound to the material
  85175. * @returns an array of meshes bound to the material
  85176. */
  85177. getBindedMeshes(): AbstractMesh[];
  85178. /**
  85179. * Force shader compilation
  85180. * @param mesh defines the mesh associated with this material
  85181. * @param onCompiled defines a function to execute once the material is compiled
  85182. * @param options defines the options to configure the compilation
  85183. */
  85184. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85185. clipPlane: boolean;
  85186. }>): void;
  85187. /**
  85188. * Force shader compilation
  85189. * @param mesh defines the mesh that will use this material
  85190. * @param options defines additional options for compiling the shaders
  85191. * @returns a promise that resolves when the compilation completes
  85192. */
  85193. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85194. clipPlane: boolean;
  85195. }>): Promise<void>;
  85196. private static readonly _AllDirtyCallBack;
  85197. private static readonly _ImageProcessingDirtyCallBack;
  85198. private static readonly _TextureDirtyCallBack;
  85199. private static readonly _FresnelDirtyCallBack;
  85200. private static readonly _MiscDirtyCallBack;
  85201. private static readonly _LightsDirtyCallBack;
  85202. private static readonly _AttributeDirtyCallBack;
  85203. private static _FresnelAndMiscDirtyCallBack;
  85204. private static _TextureAndMiscDirtyCallBack;
  85205. private static readonly _DirtyCallbackArray;
  85206. private static readonly _RunDirtyCallBacks;
  85207. /**
  85208. * Marks a define in the material to indicate that it needs to be re-computed
  85209. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85210. */
  85211. markAsDirty(flag: number): void;
  85212. /**
  85213. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85214. * @param func defines a function which checks material defines against the submeshes
  85215. */
  85216. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85217. /**
  85218. * Indicates that we need to re-calculated for all submeshes
  85219. */
  85220. protected _markAllSubMeshesAsAllDirty(): void;
  85221. /**
  85222. * Indicates that image processing needs to be re-calculated for all submeshes
  85223. */
  85224. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85225. /**
  85226. * Indicates that textures need to be re-calculated for all submeshes
  85227. */
  85228. protected _markAllSubMeshesAsTexturesDirty(): void;
  85229. /**
  85230. * Indicates that fresnel needs to be re-calculated for all submeshes
  85231. */
  85232. protected _markAllSubMeshesAsFresnelDirty(): void;
  85233. /**
  85234. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85235. */
  85236. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85237. /**
  85238. * Indicates that lights need to be re-calculated for all submeshes
  85239. */
  85240. protected _markAllSubMeshesAsLightsDirty(): void;
  85241. /**
  85242. * Indicates that attributes need to be re-calculated for all submeshes
  85243. */
  85244. protected _markAllSubMeshesAsAttributesDirty(): void;
  85245. /**
  85246. * Indicates that misc needs to be re-calculated for all submeshes
  85247. */
  85248. protected _markAllSubMeshesAsMiscDirty(): void;
  85249. /**
  85250. * Indicates that textures and misc need to be re-calculated for all submeshes
  85251. */
  85252. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85253. /**
  85254. * Disposes the material
  85255. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85256. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85257. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85258. */
  85259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85260. /** @hidden */
  85261. private releaseVertexArrayObject;
  85262. /**
  85263. * Serializes this material
  85264. * @returns the serialized material object
  85265. */
  85266. serialize(): any;
  85267. /**
  85268. * Creates a material from parsed material data
  85269. * @param parsedMaterial defines parsed material data
  85270. * @param scene defines the hosting scene
  85271. * @param rootUrl defines the root URL to use to load textures
  85272. * @returns a new material
  85273. */
  85274. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85275. }
  85276. }
  85277. declare module BABYLON {
  85278. /**
  85279. * Base class for submeshes
  85280. */
  85281. export class BaseSubMesh {
  85282. /** @hidden */
  85283. _materialDefines: Nullable<MaterialDefines>;
  85284. /** @hidden */
  85285. _materialEffect: Nullable<Effect>;
  85286. /**
  85287. * Gets associated effect
  85288. */
  85289. readonly effect: Nullable<Effect>;
  85290. /**
  85291. * Sets associated effect (effect used to render this submesh)
  85292. * @param effect defines the effect to associate with
  85293. * @param defines defines the set of defines used to compile this effect
  85294. */
  85295. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85296. }
  85297. /**
  85298. * Defines a subdivision inside a mesh
  85299. */
  85300. export class SubMesh extends BaseSubMesh implements ICullable {
  85301. /** the material index to use */
  85302. materialIndex: number;
  85303. /** vertex index start */
  85304. verticesStart: number;
  85305. /** vertices count */
  85306. verticesCount: number;
  85307. /** index start */
  85308. indexStart: number;
  85309. /** indices count */
  85310. indexCount: number;
  85311. /** @hidden */
  85312. _linesIndexCount: number;
  85313. private _mesh;
  85314. private _renderingMesh;
  85315. private _boundingInfo;
  85316. private _linesIndexBuffer;
  85317. /** @hidden */
  85318. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85319. /** @hidden */
  85320. _trianglePlanes: Plane[];
  85321. /** @hidden */
  85322. _lastColliderTransformMatrix: Nullable<Matrix>;
  85323. /** @hidden */
  85324. _renderId: number;
  85325. /** @hidden */
  85326. _alphaIndex: number;
  85327. /** @hidden */
  85328. _distanceToCamera: number;
  85329. /** @hidden */
  85330. _id: number;
  85331. private _currentMaterial;
  85332. /**
  85333. * Add a new submesh to a mesh
  85334. * @param materialIndex defines the material index to use
  85335. * @param verticesStart defines vertex index start
  85336. * @param verticesCount defines vertices count
  85337. * @param indexStart defines index start
  85338. * @param indexCount defines indices count
  85339. * @param mesh defines the parent mesh
  85340. * @param renderingMesh defines an optional rendering mesh
  85341. * @param createBoundingBox defines if bounding box should be created for this submesh
  85342. * @returns the new submesh
  85343. */
  85344. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85345. /**
  85346. * Creates a new submesh
  85347. * @param materialIndex defines the material index to use
  85348. * @param verticesStart defines vertex index start
  85349. * @param verticesCount defines vertices count
  85350. * @param indexStart defines index start
  85351. * @param indexCount defines indices count
  85352. * @param mesh defines the parent mesh
  85353. * @param renderingMesh defines an optional rendering mesh
  85354. * @param createBoundingBox defines if bounding box should be created for this submesh
  85355. */
  85356. constructor(
  85357. /** the material index to use */
  85358. materialIndex: number,
  85359. /** vertex index start */
  85360. verticesStart: number,
  85361. /** vertices count */
  85362. verticesCount: number,
  85363. /** index start */
  85364. indexStart: number,
  85365. /** indices count */
  85366. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85367. /**
  85368. * Returns true if this submesh covers the entire parent mesh
  85369. * @ignorenaming
  85370. */
  85371. readonly IsGlobal: boolean;
  85372. /**
  85373. * Returns the submesh BoudingInfo object
  85374. * @returns current bounding info (or mesh's one if the submesh is global)
  85375. */
  85376. getBoundingInfo(): BoundingInfo;
  85377. /**
  85378. * Sets the submesh BoundingInfo
  85379. * @param boundingInfo defines the new bounding info to use
  85380. * @returns the SubMesh
  85381. */
  85382. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85383. /**
  85384. * Returns the mesh of the current submesh
  85385. * @return the parent mesh
  85386. */
  85387. getMesh(): AbstractMesh;
  85388. /**
  85389. * Returns the rendering mesh of the submesh
  85390. * @returns the rendering mesh (could be different from parent mesh)
  85391. */
  85392. getRenderingMesh(): Mesh;
  85393. /**
  85394. * Returns the submesh material
  85395. * @returns null or the current material
  85396. */
  85397. getMaterial(): Nullable<Material>;
  85398. /**
  85399. * Sets a new updated BoundingInfo object to the submesh
  85400. * @param data defines an optional position array to use to determine the bounding info
  85401. * @returns the SubMesh
  85402. */
  85403. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85404. /** @hidden */
  85405. _checkCollision(collider: Collider): boolean;
  85406. /**
  85407. * Updates the submesh BoundingInfo
  85408. * @param world defines the world matrix to use to update the bounding info
  85409. * @returns the submesh
  85410. */
  85411. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85412. /**
  85413. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85414. * @param frustumPlanes defines the frustum planes
  85415. * @returns true if the submesh is intersecting with the frustum
  85416. */
  85417. isInFrustum(frustumPlanes: Plane[]): boolean;
  85418. /**
  85419. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85420. * @param frustumPlanes defines the frustum planes
  85421. * @returns true if the submesh is inside the frustum
  85422. */
  85423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85424. /**
  85425. * Renders the submesh
  85426. * @param enableAlphaMode defines if alpha needs to be used
  85427. * @returns the submesh
  85428. */
  85429. render(enableAlphaMode: boolean): SubMesh;
  85430. /**
  85431. * @hidden
  85432. */
  85433. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85434. /**
  85435. * Checks if the submesh intersects with a ray
  85436. * @param ray defines the ray to test
  85437. * @returns true is the passed ray intersects the submesh bounding box
  85438. */
  85439. canIntersects(ray: Ray): boolean;
  85440. /**
  85441. * Intersects current submesh with a ray
  85442. * @param ray defines the ray to test
  85443. * @param positions defines mesh's positions array
  85444. * @param indices defines mesh's indices array
  85445. * @param fastCheck defines if only bounding info should be used
  85446. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85447. * @returns intersection info or null if no intersection
  85448. */
  85449. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85450. /** @hidden */
  85451. private _intersectLines;
  85452. /** @hidden */
  85453. private _intersectUnIndexedLines;
  85454. /** @hidden */
  85455. private _intersectTriangles;
  85456. /** @hidden */
  85457. private _intersectUnIndexedTriangles;
  85458. /** @hidden */
  85459. _rebuild(): void;
  85460. /**
  85461. * Creates a new submesh from the passed mesh
  85462. * @param newMesh defines the new hosting mesh
  85463. * @param newRenderingMesh defines an optional rendering mesh
  85464. * @returns the new submesh
  85465. */
  85466. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85467. /**
  85468. * Release associated resources
  85469. */
  85470. dispose(): void;
  85471. /**
  85472. * Gets the class name
  85473. * @returns the string "SubMesh".
  85474. */
  85475. getClassName(): string;
  85476. /**
  85477. * Creates a new submesh from indices data
  85478. * @param materialIndex the index of the main mesh material
  85479. * @param startIndex the index where to start the copy in the mesh indices array
  85480. * @param indexCount the number of indices to copy then from the startIndex
  85481. * @param mesh the main mesh to create the submesh from
  85482. * @param renderingMesh the optional rendering mesh
  85483. * @returns a new submesh
  85484. */
  85485. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85486. }
  85487. }
  85488. declare module BABYLON {
  85489. /**
  85490. * Class used to store geometry data (vertex buffers + index buffer)
  85491. */
  85492. export class Geometry implements IGetSetVerticesData {
  85493. /**
  85494. * Gets or sets the ID of the geometry
  85495. */
  85496. id: string;
  85497. /**
  85498. * Gets or sets the unique ID of the geometry
  85499. */
  85500. uniqueId: number;
  85501. /**
  85502. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85503. */
  85504. delayLoadState: number;
  85505. /**
  85506. * Gets the file containing the data to load when running in delay load state
  85507. */
  85508. delayLoadingFile: Nullable<string>;
  85509. /**
  85510. * Callback called when the geometry is updated
  85511. */
  85512. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85513. private _scene;
  85514. private _engine;
  85515. private _meshes;
  85516. private _totalVertices;
  85517. /** @hidden */
  85518. _indices: IndicesArray;
  85519. /** @hidden */
  85520. _vertexBuffers: {
  85521. [key: string]: VertexBuffer;
  85522. };
  85523. private _isDisposed;
  85524. private _extend;
  85525. private _boundingBias;
  85526. /** @hidden */
  85527. _delayInfo: Array<string>;
  85528. private _indexBuffer;
  85529. private _indexBufferIsUpdatable;
  85530. /** @hidden */
  85531. _boundingInfo: Nullable<BoundingInfo>;
  85532. /** @hidden */
  85533. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85534. /** @hidden */
  85535. _softwareSkinningFrameId: number;
  85536. private _vertexArrayObjects;
  85537. private _updatable;
  85538. /** @hidden */
  85539. _positions: Nullable<Vector3[]>;
  85540. /**
  85541. * 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
  85542. */
  85543. /**
  85544. * 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
  85545. */
  85546. boundingBias: Vector2;
  85547. /**
  85548. * Static function used to attach a new empty geometry to a mesh
  85549. * @param mesh defines the mesh to attach the geometry to
  85550. * @returns the new Geometry
  85551. */
  85552. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85553. /**
  85554. * Creates a new geometry
  85555. * @param id defines the unique ID
  85556. * @param scene defines the hosting scene
  85557. * @param vertexData defines the VertexData used to get geometry data
  85558. * @param updatable defines if geometry must be updatable (false by default)
  85559. * @param mesh defines the mesh that will be associated with the geometry
  85560. */
  85561. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85562. /**
  85563. * Gets the current extend of the geometry
  85564. */
  85565. readonly extend: {
  85566. minimum: Vector3;
  85567. maximum: Vector3;
  85568. };
  85569. /**
  85570. * Gets the hosting scene
  85571. * @returns the hosting Scene
  85572. */
  85573. getScene(): Scene;
  85574. /**
  85575. * Gets the hosting engine
  85576. * @returns the hosting Engine
  85577. */
  85578. getEngine(): Engine;
  85579. /**
  85580. * Defines if the geometry is ready to use
  85581. * @returns true if the geometry is ready to be used
  85582. */
  85583. isReady(): boolean;
  85584. /**
  85585. * Gets a value indicating that the geometry should not be serialized
  85586. */
  85587. readonly doNotSerialize: boolean;
  85588. /** @hidden */
  85589. _rebuild(): void;
  85590. /**
  85591. * Affects all geometry data in one call
  85592. * @param vertexData defines the geometry data
  85593. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85594. */
  85595. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85596. /**
  85597. * Set specific vertex data
  85598. * @param kind defines the data kind (Position, normal, etc...)
  85599. * @param data defines the vertex data to use
  85600. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85601. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85602. */
  85603. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85604. /**
  85605. * Removes a specific vertex data
  85606. * @param kind defines the data kind (Position, normal, etc...)
  85607. */
  85608. removeVerticesData(kind: string): void;
  85609. /**
  85610. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85611. * @param buffer defines the vertex buffer to use
  85612. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85613. */
  85614. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85615. /**
  85616. * Update a specific vertex buffer
  85617. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85618. * It will do nothing if the buffer is not updatable
  85619. * @param kind defines the data kind (Position, normal, etc...)
  85620. * @param data defines the data to use
  85621. * @param offset defines the offset in the target buffer where to store the data
  85622. * @param useBytes set to true if the offset is in bytes
  85623. */
  85624. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85625. /**
  85626. * Update a specific vertex buffer
  85627. * This function will create a new buffer if the current one is not updatable
  85628. * @param kind defines the data kind (Position, normal, etc...)
  85629. * @param data defines the data to use
  85630. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85631. */
  85632. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85633. private _updateBoundingInfo;
  85634. /** @hidden */
  85635. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85636. /**
  85637. * Gets total number of vertices
  85638. * @returns the total number of vertices
  85639. */
  85640. getTotalVertices(): number;
  85641. /**
  85642. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85643. * @param kind defines the data kind (Position, normal, etc...)
  85644. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85645. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85646. * @returns a float array containing vertex data
  85647. */
  85648. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85649. /**
  85650. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85651. * @param kind defines the data kind (Position, normal, etc...)
  85652. * @returns true if the vertex buffer with the specified kind is updatable
  85653. */
  85654. isVertexBufferUpdatable(kind: string): boolean;
  85655. /**
  85656. * Gets a specific vertex buffer
  85657. * @param kind defines the data kind (Position, normal, etc...)
  85658. * @returns a VertexBuffer
  85659. */
  85660. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85661. /**
  85662. * Returns all vertex buffers
  85663. * @return an object holding all vertex buffers indexed by kind
  85664. */
  85665. getVertexBuffers(): Nullable<{
  85666. [key: string]: VertexBuffer;
  85667. }>;
  85668. /**
  85669. * Gets a boolean indicating if specific vertex buffer is present
  85670. * @param kind defines the data kind (Position, normal, etc...)
  85671. * @returns true if data is present
  85672. */
  85673. isVerticesDataPresent(kind: string): boolean;
  85674. /**
  85675. * Gets a list of all attached data kinds (Position, normal, etc...)
  85676. * @returns a list of string containing all kinds
  85677. */
  85678. getVerticesDataKinds(): string[];
  85679. /**
  85680. * Update index buffer
  85681. * @param indices defines the indices to store in the index buffer
  85682. * @param offset defines the offset in the target buffer where to store the data
  85683. * @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)
  85684. */
  85685. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85686. /**
  85687. * Creates a new index buffer
  85688. * @param indices defines the indices to store in the index buffer
  85689. * @param totalVertices defines the total number of vertices (could be null)
  85690. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85691. */
  85692. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85693. /**
  85694. * Return the total number of indices
  85695. * @returns the total number of indices
  85696. */
  85697. getTotalIndices(): number;
  85698. /**
  85699. * Gets the index buffer array
  85700. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85701. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85702. * @returns the index buffer array
  85703. */
  85704. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85705. /**
  85706. * Gets the index buffer
  85707. * @return the index buffer
  85708. */
  85709. getIndexBuffer(): Nullable<DataBuffer>;
  85710. /** @hidden */
  85711. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85712. /**
  85713. * Release the associated resources for a specific mesh
  85714. * @param mesh defines the source mesh
  85715. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85716. */
  85717. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85718. /**
  85719. * Apply current geometry to a given mesh
  85720. * @param mesh defines the mesh to apply geometry to
  85721. */
  85722. applyToMesh(mesh: Mesh): void;
  85723. private _updateExtend;
  85724. private _applyToMesh;
  85725. private notifyUpdate;
  85726. /**
  85727. * Load the geometry if it was flagged as delay loaded
  85728. * @param scene defines the hosting scene
  85729. * @param onLoaded defines a callback called when the geometry is loaded
  85730. */
  85731. load(scene: Scene, onLoaded?: () => void): void;
  85732. private _queueLoad;
  85733. /**
  85734. * Invert the geometry to move from a right handed system to a left handed one.
  85735. */
  85736. toLeftHanded(): void;
  85737. /** @hidden */
  85738. _resetPointsArrayCache(): void;
  85739. /** @hidden */
  85740. _generatePointsArray(): boolean;
  85741. /**
  85742. * Gets a value indicating if the geometry is disposed
  85743. * @returns true if the geometry was disposed
  85744. */
  85745. isDisposed(): boolean;
  85746. private _disposeVertexArrayObjects;
  85747. /**
  85748. * Free all associated resources
  85749. */
  85750. dispose(): void;
  85751. /**
  85752. * Clone the current geometry into a new geometry
  85753. * @param id defines the unique ID of the new geometry
  85754. * @returns a new geometry object
  85755. */
  85756. copy(id: string): Geometry;
  85757. /**
  85758. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85759. * @return a JSON representation of the current geometry data (without the vertices data)
  85760. */
  85761. serialize(): any;
  85762. private toNumberArray;
  85763. /**
  85764. * Serialize all vertices data into a JSON oject
  85765. * @returns a JSON representation of the current geometry data
  85766. */
  85767. serializeVerticeData(): any;
  85768. /**
  85769. * Extracts a clone of a mesh geometry
  85770. * @param mesh defines the source mesh
  85771. * @param id defines the unique ID of the new geometry object
  85772. * @returns the new geometry object
  85773. */
  85774. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85775. /**
  85776. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85777. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85778. * Be aware Math.random() could cause collisions, but:
  85779. * "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"
  85780. * @returns a string containing a new GUID
  85781. */
  85782. static RandomId(): string;
  85783. /** @hidden */
  85784. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85785. private static _CleanMatricesWeights;
  85786. /**
  85787. * Create a new geometry from persisted data (Using .babylon file format)
  85788. * @param parsedVertexData defines the persisted data
  85789. * @param scene defines the hosting scene
  85790. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85791. * @returns the new geometry object
  85792. */
  85793. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. /**
  85798. * Define an interface for all classes that will get and set the data on vertices
  85799. */
  85800. export interface IGetSetVerticesData {
  85801. /**
  85802. * Gets a boolean indicating if specific vertex data is present
  85803. * @param kind defines the vertex data kind to use
  85804. * @returns true is data kind is present
  85805. */
  85806. isVerticesDataPresent(kind: string): boolean;
  85807. /**
  85808. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85809. * @param kind defines the data kind (Position, normal, etc...)
  85810. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85811. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85812. * @returns a float array containing vertex data
  85813. */
  85814. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85815. /**
  85816. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85817. * @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.
  85818. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85819. * @returns the indices array or an empty array if the mesh has no geometry
  85820. */
  85821. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85822. /**
  85823. * Set specific vertex data
  85824. * @param kind defines the data kind (Position, normal, etc...)
  85825. * @param data defines the vertex data to use
  85826. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85827. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85828. */
  85829. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85830. /**
  85831. * Update a specific associated vertex buffer
  85832. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85833. * - VertexBuffer.PositionKind
  85834. * - VertexBuffer.UVKind
  85835. * - VertexBuffer.UV2Kind
  85836. * - VertexBuffer.UV3Kind
  85837. * - VertexBuffer.UV4Kind
  85838. * - VertexBuffer.UV5Kind
  85839. * - VertexBuffer.UV6Kind
  85840. * - VertexBuffer.ColorKind
  85841. * - VertexBuffer.MatricesIndicesKind
  85842. * - VertexBuffer.MatricesIndicesExtraKind
  85843. * - VertexBuffer.MatricesWeightsKind
  85844. * - VertexBuffer.MatricesWeightsExtraKind
  85845. * @param data defines the data source
  85846. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85847. * @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)
  85848. */
  85849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85850. /**
  85851. * Creates a new index buffer
  85852. * @param indices defines the indices to store in the index buffer
  85853. * @param totalVertices defines the total number of vertices (could be null)
  85854. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85855. */
  85856. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85857. }
  85858. /**
  85859. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85860. */
  85861. export class VertexData {
  85862. /**
  85863. * Mesh side orientation : usually the external or front surface
  85864. */
  85865. static readonly FRONTSIDE: number;
  85866. /**
  85867. * Mesh side orientation : usually the internal or back surface
  85868. */
  85869. static readonly BACKSIDE: number;
  85870. /**
  85871. * Mesh side orientation : both internal and external or front and back surfaces
  85872. */
  85873. static readonly DOUBLESIDE: number;
  85874. /**
  85875. * Mesh side orientation : by default, `FRONTSIDE`
  85876. */
  85877. static readonly DEFAULTSIDE: number;
  85878. /**
  85879. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85880. */
  85881. positions: Nullable<FloatArray>;
  85882. /**
  85883. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85884. */
  85885. normals: Nullable<FloatArray>;
  85886. /**
  85887. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85888. */
  85889. tangents: Nullable<FloatArray>;
  85890. /**
  85891. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85892. */
  85893. uvs: Nullable<FloatArray>;
  85894. /**
  85895. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85896. */
  85897. uvs2: Nullable<FloatArray>;
  85898. /**
  85899. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85900. */
  85901. uvs3: Nullable<FloatArray>;
  85902. /**
  85903. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85904. */
  85905. uvs4: Nullable<FloatArray>;
  85906. /**
  85907. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85908. */
  85909. uvs5: Nullable<FloatArray>;
  85910. /**
  85911. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85912. */
  85913. uvs6: Nullable<FloatArray>;
  85914. /**
  85915. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85916. */
  85917. colors: Nullable<FloatArray>;
  85918. /**
  85919. * 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).
  85920. */
  85921. matricesIndices: Nullable<FloatArray>;
  85922. /**
  85923. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85924. */
  85925. matricesWeights: Nullable<FloatArray>;
  85926. /**
  85927. * An array extending the number of possible indices
  85928. */
  85929. matricesIndicesExtra: Nullable<FloatArray>;
  85930. /**
  85931. * An array extending the number of possible weights when the number of indices is extended
  85932. */
  85933. matricesWeightsExtra: Nullable<FloatArray>;
  85934. /**
  85935. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85936. */
  85937. indices: Nullable<IndicesArray>;
  85938. /**
  85939. * Uses the passed data array to set the set the values for the specified kind of data
  85940. * @param data a linear array of floating numbers
  85941. * @param kind the type of data that is being set, eg positions, colors etc
  85942. */
  85943. set(data: FloatArray, kind: string): void;
  85944. /**
  85945. * Associates the vertexData to the passed Mesh.
  85946. * Sets it as updatable or not (default `false`)
  85947. * @param mesh the mesh the vertexData is applied to
  85948. * @param updatable when used and having the value true allows new data to update the vertexData
  85949. * @returns the VertexData
  85950. */
  85951. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85952. /**
  85953. * Associates the vertexData to the passed Geometry.
  85954. * Sets it as updatable or not (default `false`)
  85955. * @param geometry the geometry the vertexData is applied to
  85956. * @param updatable when used and having the value true allows new data to update the vertexData
  85957. * @returns VertexData
  85958. */
  85959. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85960. /**
  85961. * Updates the associated mesh
  85962. * @param mesh the mesh to be updated
  85963. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85964. * @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
  85965. * @returns VertexData
  85966. */
  85967. updateMesh(mesh: Mesh): VertexData;
  85968. /**
  85969. * Updates the associated geometry
  85970. * @param geometry the geometry to be updated
  85971. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85972. * @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
  85973. * @returns VertexData.
  85974. */
  85975. updateGeometry(geometry: Geometry): VertexData;
  85976. private _applyTo;
  85977. private _update;
  85978. /**
  85979. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85980. * @param matrix the transforming matrix
  85981. * @returns the VertexData
  85982. */
  85983. transform(matrix: Matrix): VertexData;
  85984. /**
  85985. * Merges the passed VertexData into the current one
  85986. * @param other the VertexData to be merged into the current one
  85987. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85988. * @returns the modified VertexData
  85989. */
  85990. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85991. private _mergeElement;
  85992. private _validate;
  85993. /**
  85994. * Serializes the VertexData
  85995. * @returns a serialized object
  85996. */
  85997. serialize(): any;
  85998. /**
  85999. * Extracts the vertexData from a mesh
  86000. * @param mesh the mesh from which to extract the VertexData
  86001. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86002. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86003. * @returns the object VertexData associated to the passed mesh
  86004. */
  86005. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86006. /**
  86007. * Extracts the vertexData from the geometry
  86008. * @param geometry the geometry from which to extract the VertexData
  86009. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86010. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86011. * @returns the object VertexData associated to the passed mesh
  86012. */
  86013. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86014. private static _ExtractFrom;
  86015. /**
  86016. * Creates the VertexData for a Ribbon
  86017. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86018. * * pathArray array of paths, each of which an array of successive Vector3
  86019. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86020. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86021. * * 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
  86022. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86023. * * 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)
  86024. * * 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)
  86025. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86026. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86027. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86028. * @returns the VertexData of the ribbon
  86029. */
  86030. static CreateRibbon(options: {
  86031. pathArray: Vector3[][];
  86032. closeArray?: boolean;
  86033. closePath?: boolean;
  86034. offset?: number;
  86035. sideOrientation?: number;
  86036. frontUVs?: Vector4;
  86037. backUVs?: Vector4;
  86038. invertUV?: boolean;
  86039. uvs?: Vector2[];
  86040. colors?: Color4[];
  86041. }): VertexData;
  86042. /**
  86043. * Creates the VertexData for a box
  86044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86045. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86046. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86047. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86048. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86049. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86050. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86052. * * 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)
  86053. * * 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)
  86054. * @returns the VertexData of the box
  86055. */
  86056. static CreateBox(options: {
  86057. size?: number;
  86058. width?: number;
  86059. height?: number;
  86060. depth?: number;
  86061. faceUV?: Vector4[];
  86062. faceColors?: Color4[];
  86063. sideOrientation?: number;
  86064. frontUVs?: Vector4;
  86065. backUVs?: Vector4;
  86066. }): VertexData;
  86067. /**
  86068. * Creates the VertexData for a tiled box
  86069. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86070. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86071. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86072. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86074. * @returns the VertexData of the box
  86075. */
  86076. static CreateTiledBox(options: {
  86077. pattern?: number;
  86078. width?: number;
  86079. height?: number;
  86080. depth?: number;
  86081. tileSize?: number;
  86082. tileWidth?: number;
  86083. tileHeight?: number;
  86084. alignHorizontal?: number;
  86085. alignVertical?: number;
  86086. faceUV?: Vector4[];
  86087. faceColors?: Color4[];
  86088. sideOrientation?: number;
  86089. }): VertexData;
  86090. /**
  86091. * Creates the VertexData for a tiled plane
  86092. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86093. * * pattern a limited pattern arrangement depending on the number
  86094. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86095. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86096. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86098. * * 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)
  86099. * * 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)
  86100. * @returns the VertexData of the tiled plane
  86101. */
  86102. static CreateTiledPlane(options: {
  86103. pattern?: number;
  86104. tileSize?: number;
  86105. tileWidth?: number;
  86106. tileHeight?: number;
  86107. size?: number;
  86108. width?: number;
  86109. height?: number;
  86110. alignHorizontal?: number;
  86111. alignVertical?: number;
  86112. sideOrientation?: number;
  86113. frontUVs?: Vector4;
  86114. backUVs?: Vector4;
  86115. }): VertexData;
  86116. /**
  86117. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86119. * * segments sets the number of horizontal strips optional, default 32
  86120. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86121. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86122. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86123. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86124. * * 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
  86125. * * 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
  86126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86127. * * 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)
  86128. * * 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)
  86129. * @returns the VertexData of the ellipsoid
  86130. */
  86131. static CreateSphere(options: {
  86132. segments?: number;
  86133. diameter?: number;
  86134. diameterX?: number;
  86135. diameterY?: number;
  86136. diameterZ?: number;
  86137. arc?: number;
  86138. slice?: number;
  86139. sideOrientation?: number;
  86140. frontUVs?: Vector4;
  86141. backUVs?: Vector4;
  86142. }): VertexData;
  86143. /**
  86144. * Creates the VertexData for a cylinder, cone or prism
  86145. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86146. * * height sets the height (y direction) of the cylinder, optional, default 2
  86147. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86148. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86149. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86150. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86151. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86152. * * 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
  86153. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86154. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86155. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86156. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86158. * * 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)
  86159. * * 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)
  86160. * @returns the VertexData of the cylinder, cone or prism
  86161. */
  86162. static CreateCylinder(options: {
  86163. height?: number;
  86164. diameterTop?: number;
  86165. diameterBottom?: number;
  86166. diameter?: number;
  86167. tessellation?: number;
  86168. subdivisions?: number;
  86169. arc?: number;
  86170. faceColors?: Color4[];
  86171. faceUV?: Vector4[];
  86172. hasRings?: boolean;
  86173. enclose?: boolean;
  86174. sideOrientation?: number;
  86175. frontUVs?: Vector4;
  86176. backUVs?: Vector4;
  86177. }): VertexData;
  86178. /**
  86179. * Creates the VertexData for a torus
  86180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86181. * * diameter the diameter of the torus, optional default 1
  86182. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86183. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86185. * * 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)
  86186. * * 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)
  86187. * @returns the VertexData of the torus
  86188. */
  86189. static CreateTorus(options: {
  86190. diameter?: number;
  86191. thickness?: number;
  86192. tessellation?: number;
  86193. sideOrientation?: number;
  86194. frontUVs?: Vector4;
  86195. backUVs?: Vector4;
  86196. }): VertexData;
  86197. /**
  86198. * Creates the VertexData of the LineSystem
  86199. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86200. * - lines an array of lines, each line being an array of successive Vector3
  86201. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86202. * @returns the VertexData of the LineSystem
  86203. */
  86204. static CreateLineSystem(options: {
  86205. lines: Vector3[][];
  86206. colors?: Nullable<Color4[][]>;
  86207. }): VertexData;
  86208. /**
  86209. * Create the VertexData for a DashedLines
  86210. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86211. * - points an array successive Vector3
  86212. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86213. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86214. * - dashNb the intended total number of dashes, optional, default 200
  86215. * @returns the VertexData for the DashedLines
  86216. */
  86217. static CreateDashedLines(options: {
  86218. points: Vector3[];
  86219. dashSize?: number;
  86220. gapSize?: number;
  86221. dashNb?: number;
  86222. }): VertexData;
  86223. /**
  86224. * Creates the VertexData for a Ground
  86225. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86226. * - width the width (x direction) of the ground, optional, default 1
  86227. * - height the height (z direction) of the ground, optional, default 1
  86228. * - subdivisions the number of subdivisions per side, optional, default 1
  86229. * @returns the VertexData of the Ground
  86230. */
  86231. static CreateGround(options: {
  86232. width?: number;
  86233. height?: number;
  86234. subdivisions?: number;
  86235. subdivisionsX?: number;
  86236. subdivisionsY?: number;
  86237. }): VertexData;
  86238. /**
  86239. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86240. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86241. * * xmin the ground minimum X coordinate, optional, default -1
  86242. * * zmin the ground minimum Z coordinate, optional, default -1
  86243. * * xmax the ground maximum X coordinate, optional, default 1
  86244. * * zmax the ground maximum Z coordinate, optional, default 1
  86245. * * 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}
  86246. * * 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}
  86247. * @returns the VertexData of the TiledGround
  86248. */
  86249. static CreateTiledGround(options: {
  86250. xmin: number;
  86251. zmin: number;
  86252. xmax: number;
  86253. zmax: number;
  86254. subdivisions?: {
  86255. w: number;
  86256. h: number;
  86257. };
  86258. precision?: {
  86259. w: number;
  86260. h: number;
  86261. };
  86262. }): VertexData;
  86263. /**
  86264. * Creates the VertexData of the Ground designed from a heightmap
  86265. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86266. * * width the width (x direction) of the ground
  86267. * * height the height (z direction) of the ground
  86268. * * subdivisions the number of subdivisions per side
  86269. * * minHeight the minimum altitude on the ground, optional, default 0
  86270. * * maxHeight the maximum altitude on the ground, optional default 1
  86271. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86272. * * buffer the array holding the image color data
  86273. * * bufferWidth the width of image
  86274. * * bufferHeight the height of image
  86275. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86276. * @returns the VertexData of the Ground designed from a heightmap
  86277. */
  86278. static CreateGroundFromHeightMap(options: {
  86279. width: number;
  86280. height: number;
  86281. subdivisions: number;
  86282. minHeight: number;
  86283. maxHeight: number;
  86284. colorFilter: Color3;
  86285. buffer: Uint8Array;
  86286. bufferWidth: number;
  86287. bufferHeight: number;
  86288. alphaFilter: number;
  86289. }): VertexData;
  86290. /**
  86291. * Creates the VertexData for a Plane
  86292. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86293. * * size sets the width and height of the plane to the value of size, optional default 1
  86294. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86295. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86297. * * 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)
  86298. * * 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)
  86299. * @returns the VertexData of the box
  86300. */
  86301. static CreatePlane(options: {
  86302. size?: number;
  86303. width?: number;
  86304. height?: number;
  86305. sideOrientation?: number;
  86306. frontUVs?: Vector4;
  86307. backUVs?: Vector4;
  86308. }): VertexData;
  86309. /**
  86310. * Creates the VertexData of the Disc or regular Polygon
  86311. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86312. * * radius the radius of the disc, optional default 0.5
  86313. * * tessellation the number of polygon sides, optional, default 64
  86314. * * 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
  86315. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86316. * * 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)
  86317. * * 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)
  86318. * @returns the VertexData of the box
  86319. */
  86320. static CreateDisc(options: {
  86321. radius?: number;
  86322. tessellation?: number;
  86323. arc?: number;
  86324. sideOrientation?: number;
  86325. frontUVs?: Vector4;
  86326. backUVs?: Vector4;
  86327. }): VertexData;
  86328. /**
  86329. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86330. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86331. * @param polygon a mesh built from polygonTriangulation.build()
  86332. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86333. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86334. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86335. * @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)
  86336. * @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)
  86337. * @returns the VertexData of the Polygon
  86338. */
  86339. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86340. /**
  86341. * Creates the VertexData of the IcoSphere
  86342. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86343. * * radius the radius of the IcoSphere, optional default 1
  86344. * * radiusX allows stretching in the x direction, optional, default radius
  86345. * * radiusY allows stretching in the y direction, optional, default radius
  86346. * * radiusZ allows stretching in the z direction, optional, default radius
  86347. * * flat when true creates a flat shaded mesh, optional, default true
  86348. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86350. * * 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)
  86351. * * 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)
  86352. * @returns the VertexData of the IcoSphere
  86353. */
  86354. static CreateIcoSphere(options: {
  86355. radius?: number;
  86356. radiusX?: number;
  86357. radiusY?: number;
  86358. radiusZ?: number;
  86359. flat?: boolean;
  86360. subdivisions?: number;
  86361. sideOrientation?: number;
  86362. frontUVs?: Vector4;
  86363. backUVs?: Vector4;
  86364. }): VertexData;
  86365. /**
  86366. * Creates the VertexData for a Polyhedron
  86367. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86368. * * type provided types are:
  86369. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86370. * * 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)
  86371. * * size the size of the IcoSphere, optional default 1
  86372. * * sizeX allows stretching in the x direction, optional, default size
  86373. * * sizeY allows stretching in the y direction, optional, default size
  86374. * * sizeZ allows stretching in the z direction, optional, default size
  86375. * * 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
  86376. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86377. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86378. * * flat when true creates a flat shaded mesh, optional, default true
  86379. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86381. * * 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)
  86382. * * 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)
  86383. * @returns the VertexData of the Polyhedron
  86384. */
  86385. static CreatePolyhedron(options: {
  86386. type?: number;
  86387. size?: number;
  86388. sizeX?: number;
  86389. sizeY?: number;
  86390. sizeZ?: number;
  86391. custom?: any;
  86392. faceUV?: Vector4[];
  86393. faceColors?: Color4[];
  86394. flat?: boolean;
  86395. sideOrientation?: number;
  86396. frontUVs?: Vector4;
  86397. backUVs?: Vector4;
  86398. }): VertexData;
  86399. /**
  86400. * Creates the VertexData for a TorusKnot
  86401. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86402. * * radius the radius of the torus knot, optional, default 2
  86403. * * tube the thickness of the tube, optional, default 0.5
  86404. * * radialSegments the number of sides on each tube segments, optional, default 32
  86405. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86406. * * p the number of windings around the z axis, optional, default 2
  86407. * * q the number of windings around the x axis, optional, default 3
  86408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86409. * * 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)
  86410. * * 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)
  86411. * @returns the VertexData of the Torus Knot
  86412. */
  86413. static CreateTorusKnot(options: {
  86414. radius?: number;
  86415. tube?: number;
  86416. radialSegments?: number;
  86417. tubularSegments?: number;
  86418. p?: number;
  86419. q?: number;
  86420. sideOrientation?: number;
  86421. frontUVs?: Vector4;
  86422. backUVs?: Vector4;
  86423. }): VertexData;
  86424. /**
  86425. * Compute normals for given positions and indices
  86426. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86427. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86428. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86429. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86430. * * facetNormals : optional array of facet normals (vector3)
  86431. * * facetPositions : optional array of facet positions (vector3)
  86432. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86433. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86434. * * bInfo : optional bounding info, required for facetPartitioning computation
  86435. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86436. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86437. * * useRightHandedSystem: optional boolean to for right handed system computation
  86438. * * depthSort : optional boolean to enable the facet depth sort computation
  86439. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86440. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86441. */
  86442. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86443. facetNormals?: any;
  86444. facetPositions?: any;
  86445. facetPartitioning?: any;
  86446. ratio?: number;
  86447. bInfo?: any;
  86448. bbSize?: Vector3;
  86449. subDiv?: any;
  86450. useRightHandedSystem?: boolean;
  86451. depthSort?: boolean;
  86452. distanceTo?: Vector3;
  86453. depthSortedFacets?: any;
  86454. }): void;
  86455. /** @hidden */
  86456. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86457. /**
  86458. * Applies VertexData created from the imported parameters to the geometry
  86459. * @param parsedVertexData the parsed data from an imported file
  86460. * @param geometry the geometry to apply the VertexData to
  86461. */
  86462. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86463. }
  86464. }
  86465. declare module BABYLON {
  86466. /**
  86467. * Class containing static functions to help procedurally build meshes
  86468. */
  86469. export class DiscBuilder {
  86470. /**
  86471. * Creates a plane polygonal mesh. By default, this is a disc
  86472. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86473. * * 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
  86474. * * 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
  86475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86476. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86478. * @param name defines the name of the mesh
  86479. * @param options defines the options used to create the mesh
  86480. * @param scene defines the hosting scene
  86481. * @returns the plane polygonal mesh
  86482. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86483. */
  86484. static CreateDisc(name: string, options: {
  86485. radius?: number;
  86486. tessellation?: number;
  86487. arc?: number;
  86488. updatable?: boolean;
  86489. sideOrientation?: number;
  86490. frontUVs?: Vector4;
  86491. backUVs?: Vector4;
  86492. }, scene?: Nullable<Scene>): Mesh;
  86493. }
  86494. }
  86495. declare module BABYLON {
  86496. /**
  86497. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86498. *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.
  86499. * The SPS is also a particle system. It provides some methods to manage the particles.
  86500. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86501. *
  86502. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86503. */
  86504. export class SolidParticleSystem implements IDisposable {
  86505. /**
  86506. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86507. * Example : var p = SPS.particles[i];
  86508. */
  86509. particles: SolidParticle[];
  86510. /**
  86511. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86512. */
  86513. nbParticles: number;
  86514. /**
  86515. * If the particles must ever face the camera (default false). Useful for planar particles.
  86516. */
  86517. billboard: boolean;
  86518. /**
  86519. * Recompute normals when adding a shape
  86520. */
  86521. recomputeNormals: boolean;
  86522. /**
  86523. * This a counter ofr your own usage. It's not set by any SPS functions.
  86524. */
  86525. counter: number;
  86526. /**
  86527. * The SPS name. This name is also given to the underlying mesh.
  86528. */
  86529. name: string;
  86530. /**
  86531. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86532. */
  86533. mesh: Mesh;
  86534. /**
  86535. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86536. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86537. */
  86538. vars: any;
  86539. /**
  86540. * This array is populated when the SPS is set as 'pickable'.
  86541. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86542. * Each element of this array is an object `{idx: int, faceId: int}`.
  86543. * `idx` is the picked particle index in the `SPS.particles` array
  86544. * `faceId` is the picked face index counted within this particle.
  86545. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86546. */
  86547. pickedParticles: {
  86548. idx: number;
  86549. faceId: number;
  86550. }[];
  86551. /**
  86552. * This array is populated when `enableDepthSort` is set to true.
  86553. * Each element of this array is an instance of the class DepthSortedParticle.
  86554. */
  86555. depthSortedParticles: DepthSortedParticle[];
  86556. /**
  86557. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86558. * @hidden
  86559. */
  86560. _bSphereOnly: boolean;
  86561. /**
  86562. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86563. * @hidden
  86564. */
  86565. _bSphereRadiusFactor: number;
  86566. private _scene;
  86567. private _positions;
  86568. private _indices;
  86569. private _normals;
  86570. private _colors;
  86571. private _uvs;
  86572. private _indices32;
  86573. private _positions32;
  86574. private _normals32;
  86575. private _fixedNormal32;
  86576. private _colors32;
  86577. private _uvs32;
  86578. private _index;
  86579. private _updatable;
  86580. private _pickable;
  86581. private _isVisibilityBoxLocked;
  86582. private _alwaysVisible;
  86583. private _depthSort;
  86584. private _shapeCounter;
  86585. private _copy;
  86586. private _color;
  86587. private _computeParticleColor;
  86588. private _computeParticleTexture;
  86589. private _computeParticleRotation;
  86590. private _computeParticleVertex;
  86591. private _computeBoundingBox;
  86592. private _depthSortParticles;
  86593. private _camera;
  86594. private _mustUnrotateFixedNormals;
  86595. private _particlesIntersect;
  86596. private _needs32Bits;
  86597. /**
  86598. * Creates a SPS (Solid Particle System) object.
  86599. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86600. * @param scene (Scene) is the scene in which the SPS is added.
  86601. * @param options defines the options of the sps e.g.
  86602. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86603. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86604. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86605. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86606. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86607. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86608. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86609. */
  86610. constructor(name: string, scene: Scene, options?: {
  86611. updatable?: boolean;
  86612. isPickable?: boolean;
  86613. enableDepthSort?: boolean;
  86614. particleIntersection?: boolean;
  86615. boundingSphereOnly?: boolean;
  86616. bSphereRadiusFactor?: number;
  86617. });
  86618. /**
  86619. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86620. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86621. * @returns the created mesh
  86622. */
  86623. buildMesh(): Mesh;
  86624. /**
  86625. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86626. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86627. * Thus the particles generated from `digest()` have their property `position` set yet.
  86628. * @param mesh ( Mesh ) is the mesh to be digested
  86629. * @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
  86630. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86631. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86632. * @returns the current SPS
  86633. */
  86634. digest(mesh: Mesh, options?: {
  86635. facetNb?: number;
  86636. number?: number;
  86637. delta?: number;
  86638. }): SolidParticleSystem;
  86639. private _unrotateFixedNormals;
  86640. private _resetCopy;
  86641. private _meshBuilder;
  86642. private _posToShape;
  86643. private _uvsToShapeUV;
  86644. private _addParticle;
  86645. /**
  86646. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86647. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86648. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86649. * @param nb (positive integer) the number of particles to be created from this model
  86650. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86651. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86652. * @returns the number of shapes in the system
  86653. */
  86654. addShape(mesh: Mesh, nb: number, options?: {
  86655. positionFunction?: any;
  86656. vertexFunction?: any;
  86657. }): number;
  86658. private _rebuildParticle;
  86659. /**
  86660. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86661. * @returns the SPS.
  86662. */
  86663. rebuildMesh(): SolidParticleSystem;
  86664. /**
  86665. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86666. * This method calls `updateParticle()` for each particle of the SPS.
  86667. * For an animated SPS, it is usually called within the render loop.
  86668. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86669. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86670. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86671. * @returns the SPS.
  86672. */
  86673. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86674. /**
  86675. * Disposes the SPS.
  86676. */
  86677. dispose(): void;
  86678. /**
  86679. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86681. * @returns the SPS.
  86682. */
  86683. refreshVisibleSize(): SolidParticleSystem;
  86684. /**
  86685. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86686. * @param size the size (float) of the visibility box
  86687. * note : this doesn't lock the SPS mesh bounding box.
  86688. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86689. */
  86690. setVisibilityBox(size: number): void;
  86691. /**
  86692. * Gets whether the SPS as always visible or not
  86693. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86694. */
  86695. /**
  86696. * Sets the SPS as always visible or not
  86697. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86698. */
  86699. isAlwaysVisible: boolean;
  86700. /**
  86701. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86702. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86703. */
  86704. /**
  86705. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86706. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86707. */
  86708. isVisibilityBoxLocked: boolean;
  86709. /**
  86710. * Tells to `setParticles()` to compute the particle rotations or not.
  86711. * Default value : true. The SPS is faster when it's set to false.
  86712. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86713. */
  86714. /**
  86715. * Gets if `setParticles()` computes the particle rotations or not.
  86716. * Default value : true. The SPS is faster when it's set to false.
  86717. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86718. */
  86719. computeParticleRotation: boolean;
  86720. /**
  86721. * Tells to `setParticles()` to compute the particle colors or not.
  86722. * Default value : true. The SPS is faster when it's set to false.
  86723. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86724. */
  86725. /**
  86726. * Gets if `setParticles()` computes the particle colors or not.
  86727. * Default value : true. The SPS is faster when it's set to false.
  86728. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86729. */
  86730. computeParticleColor: boolean;
  86731. /**
  86732. * Gets if `setParticles()` computes the particle textures or not.
  86733. * Default value : true. The SPS is faster when it's set to false.
  86734. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86735. */
  86736. computeParticleTexture: boolean;
  86737. /**
  86738. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86739. * Default value : false. The SPS is faster when it's set to false.
  86740. * Note : the particle custom vertex positions aren't stored values.
  86741. */
  86742. /**
  86743. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86744. * Default value : false. The SPS is faster when it's set to false.
  86745. * Note : the particle custom vertex positions aren't stored values.
  86746. */
  86747. computeParticleVertex: boolean;
  86748. /**
  86749. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86750. */
  86751. /**
  86752. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86753. */
  86754. computeBoundingBox: boolean;
  86755. /**
  86756. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86757. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86758. * Default : `true`
  86759. */
  86760. /**
  86761. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86762. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86763. * Default : `true`
  86764. */
  86765. depthSortParticles: boolean;
  86766. /**
  86767. * This function does nothing. It may be overwritten to set all the particle first values.
  86768. * The SPS doesn't call this function, you may have to call it by your own.
  86769. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86770. */
  86771. initParticles(): void;
  86772. /**
  86773. * This function does nothing. It may be overwritten to recycle a particle.
  86774. * The SPS doesn't call this function, you may have to call it by your own.
  86775. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86776. * @param particle The particle to recycle
  86777. * @returns the recycled particle
  86778. */
  86779. recycleParticle(particle: SolidParticle): SolidParticle;
  86780. /**
  86781. * Updates a particle : this function should be overwritten by the user.
  86782. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86783. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86784. * @example : just set a particle position or velocity and recycle conditions
  86785. * @param particle The particle to update
  86786. * @returns the updated particle
  86787. */
  86788. updateParticle(particle: SolidParticle): SolidParticle;
  86789. /**
  86790. * Updates a vertex of a particle : it can be overwritten by the user.
  86791. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86792. * @param particle the current particle
  86793. * @param vertex the current index of the current particle
  86794. * @param pt the index of the current vertex in the particle shape
  86795. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86796. * @example : just set a vertex particle position
  86797. * @returns the updated vertex
  86798. */
  86799. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86800. /**
  86801. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86802. * This does nothing and may be overwritten by the user.
  86803. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86804. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86805. * @param update the boolean update value actually passed to setParticles()
  86806. */
  86807. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86808. /**
  86809. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86810. * This will be passed three parameters.
  86811. * This does nothing and may be overwritten by the user.
  86812. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86813. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86814. * @param update the boolean update value actually passed to setParticles()
  86815. */
  86816. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86817. }
  86818. }
  86819. declare module BABYLON {
  86820. /**
  86821. * Represents one particle of a solid particle system.
  86822. */
  86823. export class SolidParticle {
  86824. /**
  86825. * particle global index
  86826. */
  86827. idx: number;
  86828. /**
  86829. * The color of the particle
  86830. */
  86831. color: Nullable<Color4>;
  86832. /**
  86833. * The world space position of the particle.
  86834. */
  86835. position: Vector3;
  86836. /**
  86837. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86838. */
  86839. rotation: Vector3;
  86840. /**
  86841. * The world space rotation quaternion of the particle.
  86842. */
  86843. rotationQuaternion: Nullable<Quaternion>;
  86844. /**
  86845. * The scaling of the particle.
  86846. */
  86847. scaling: Vector3;
  86848. /**
  86849. * The uvs of the particle.
  86850. */
  86851. uvs: Vector4;
  86852. /**
  86853. * The current speed of the particle.
  86854. */
  86855. velocity: Vector3;
  86856. /**
  86857. * The pivot point in the particle local space.
  86858. */
  86859. pivot: Vector3;
  86860. /**
  86861. * Must the particle be translated from its pivot point in its local space ?
  86862. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86863. * Default : false
  86864. */
  86865. translateFromPivot: boolean;
  86866. /**
  86867. * Is the particle active or not ?
  86868. */
  86869. alive: boolean;
  86870. /**
  86871. * Is the particle visible or not ?
  86872. */
  86873. isVisible: boolean;
  86874. /**
  86875. * Index of this particle in the global "positions" array (Internal use)
  86876. * @hidden
  86877. */
  86878. _pos: number;
  86879. /**
  86880. * @hidden Index of this particle in the global "indices" array (Internal use)
  86881. */
  86882. _ind: number;
  86883. /**
  86884. * @hidden ModelShape of this particle (Internal use)
  86885. */
  86886. _model: ModelShape;
  86887. /**
  86888. * ModelShape id of this particle
  86889. */
  86890. shapeId: number;
  86891. /**
  86892. * Index of the particle in its shape id (Internal use)
  86893. */
  86894. idxInShape: number;
  86895. /**
  86896. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86897. */
  86898. _modelBoundingInfo: BoundingInfo;
  86899. /**
  86900. * @hidden Particle BoundingInfo object (Internal use)
  86901. */
  86902. _boundingInfo: BoundingInfo;
  86903. /**
  86904. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86905. */
  86906. _sps: SolidParticleSystem;
  86907. /**
  86908. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86909. */
  86910. _stillInvisible: boolean;
  86911. /**
  86912. * @hidden Last computed particle rotation matrix
  86913. */
  86914. _rotationMatrix: number[];
  86915. /**
  86916. * Parent particle Id, if any.
  86917. * Default null.
  86918. */
  86919. parentId: Nullable<number>;
  86920. /**
  86921. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86922. * The possible values are :
  86923. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86924. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86925. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86926. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86927. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86928. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86929. * */
  86930. cullingStrategy: number;
  86931. /**
  86932. * @hidden Internal global position in the SPS.
  86933. */
  86934. _globalPosition: Vector3;
  86935. /**
  86936. * Creates a Solid Particle object.
  86937. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86938. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86939. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86940. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86941. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86942. * @param shapeId (integer) is the model shape identifier in the SPS.
  86943. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86944. * @param sps defines the sps it is associated to
  86945. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86946. */
  86947. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86948. /**
  86949. * Legacy support, changed scale to scaling
  86950. */
  86951. /**
  86952. * Legacy support, changed scale to scaling
  86953. */
  86954. scale: Vector3;
  86955. /**
  86956. * Legacy support, changed quaternion to rotationQuaternion
  86957. */
  86958. /**
  86959. * Legacy support, changed quaternion to rotationQuaternion
  86960. */
  86961. quaternion: Nullable<Quaternion>;
  86962. /**
  86963. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86964. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86965. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86966. * @returns true if it intersects
  86967. */
  86968. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86969. /**
  86970. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86971. * A particle is in the frustum if its bounding box intersects the frustum
  86972. * @param frustumPlanes defines the frustum to test
  86973. * @returns true if the particle is in the frustum planes
  86974. */
  86975. isInFrustum(frustumPlanes: Plane[]): boolean;
  86976. /**
  86977. * get the rotation matrix of the particle
  86978. * @hidden
  86979. */
  86980. getRotationMatrix(m: Matrix): void;
  86981. }
  86982. /**
  86983. * Represents the shape of the model used by one particle of a solid particle system.
  86984. * SPS internal tool, don't use it manually.
  86985. */
  86986. export class ModelShape {
  86987. /**
  86988. * The shape id
  86989. * @hidden
  86990. */
  86991. shapeID: number;
  86992. /**
  86993. * flat array of model positions (internal use)
  86994. * @hidden
  86995. */
  86996. _shape: Vector3[];
  86997. /**
  86998. * flat array of model UVs (internal use)
  86999. * @hidden
  87000. */
  87001. _shapeUV: number[];
  87002. /**
  87003. * length of the shape in the model indices array (internal use)
  87004. * @hidden
  87005. */
  87006. _indicesLength: number;
  87007. /**
  87008. * Custom position function (internal use)
  87009. * @hidden
  87010. */
  87011. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  87012. /**
  87013. * Custom vertex function (internal use)
  87014. * @hidden
  87015. */
  87016. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  87017. /**
  87018. * 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.
  87019. * SPS internal tool, don't use it manually.
  87020. * @hidden
  87021. */
  87022. 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>);
  87023. }
  87024. /**
  87025. * Represents a Depth Sorted Particle in the solid particle system.
  87026. */
  87027. export class DepthSortedParticle {
  87028. /**
  87029. * Index of the particle in the "indices" array
  87030. */
  87031. ind: number;
  87032. /**
  87033. * Length of the particle shape in the "indices" array
  87034. */
  87035. indicesLength: number;
  87036. /**
  87037. * Squared distance from the particle to the camera
  87038. */
  87039. sqDistance: number;
  87040. }
  87041. }
  87042. declare module BABYLON {
  87043. /**
  87044. * @hidden
  87045. */
  87046. export class _MeshCollisionData {
  87047. _checkCollisions: boolean;
  87048. _collisionMask: number;
  87049. _collisionGroup: number;
  87050. _collider: Nullable<Collider>;
  87051. _oldPositionForCollisions: Vector3;
  87052. _diffPositionForCollisions: Vector3;
  87053. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87054. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87055. }
  87056. }
  87057. declare module BABYLON {
  87058. /** @hidden */
  87059. class _FacetDataStorage {
  87060. facetPositions: Vector3[];
  87061. facetNormals: Vector3[];
  87062. facetPartitioning: number[][];
  87063. facetNb: number;
  87064. partitioningSubdivisions: number;
  87065. partitioningBBoxRatio: number;
  87066. facetDataEnabled: boolean;
  87067. facetParameters: any;
  87068. bbSize: Vector3;
  87069. subDiv: {
  87070. max: number;
  87071. X: number;
  87072. Y: number;
  87073. Z: number;
  87074. };
  87075. facetDepthSort: boolean;
  87076. facetDepthSortEnabled: boolean;
  87077. depthSortedIndices: IndicesArray;
  87078. depthSortedFacets: {
  87079. ind: number;
  87080. sqDistance: number;
  87081. }[];
  87082. facetDepthSortFunction: (f1: {
  87083. ind: number;
  87084. sqDistance: number;
  87085. }, f2: {
  87086. ind: number;
  87087. sqDistance: number;
  87088. }) => number;
  87089. facetDepthSortFrom: Vector3;
  87090. facetDepthSortOrigin: Vector3;
  87091. invertedMatrix: Matrix;
  87092. }
  87093. /**
  87094. * @hidden
  87095. **/
  87096. class _InternalAbstractMeshDataInfo {
  87097. _hasVertexAlpha: boolean;
  87098. _useVertexColors: boolean;
  87099. _numBoneInfluencers: number;
  87100. _applyFog: boolean;
  87101. _receiveShadows: boolean;
  87102. _facetData: _FacetDataStorage;
  87103. _visibility: number;
  87104. _skeleton: Nullable<Skeleton>;
  87105. _layerMask: number;
  87106. _computeBonesUsingShaders: boolean;
  87107. _isActive: boolean;
  87108. _onlyForInstances: boolean;
  87109. _isActiveIntermediate: boolean;
  87110. _onlyForInstancesIntermediate: boolean;
  87111. }
  87112. /**
  87113. * Class used to store all common mesh properties
  87114. */
  87115. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87116. /** No occlusion */
  87117. static OCCLUSION_TYPE_NONE: number;
  87118. /** Occlusion set to optimisitic */
  87119. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87120. /** Occlusion set to strict */
  87121. static OCCLUSION_TYPE_STRICT: number;
  87122. /** Use an accurante occlusion algorithm */
  87123. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87124. /** Use a conservative occlusion algorithm */
  87125. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87126. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87127. * Test order :
  87128. * Is the bounding sphere outside the frustum ?
  87129. * If not, are the bounding box vertices outside the frustum ?
  87130. * It not, then the cullable object is in the frustum.
  87131. */
  87132. static readonly CULLINGSTRATEGY_STANDARD: number;
  87133. /** Culling strategy : Bounding Sphere Only.
  87134. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87135. * It's also less accurate than the standard because some not visible objects can still be selected.
  87136. * Test : is the bounding sphere outside the frustum ?
  87137. * If not, then the cullable object is in the frustum.
  87138. */
  87139. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87140. /** Culling strategy : Optimistic Inclusion.
  87141. * This in an inclusion test first, then the standard exclusion test.
  87142. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87143. * 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.
  87144. * Anyway, it's as accurate as the standard strategy.
  87145. * Test :
  87146. * Is the cullable object bounding sphere center in the frustum ?
  87147. * If not, apply the default culling strategy.
  87148. */
  87149. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87150. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87151. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87152. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87153. * 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.
  87154. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87155. * Test :
  87156. * Is the cullable object bounding sphere center in the frustum ?
  87157. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87158. */
  87159. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87160. /**
  87161. * No billboard
  87162. */
  87163. static readonly BILLBOARDMODE_NONE: number;
  87164. /** Billboard on X axis */
  87165. static readonly BILLBOARDMODE_X: number;
  87166. /** Billboard on Y axis */
  87167. static readonly BILLBOARDMODE_Y: number;
  87168. /** Billboard on Z axis */
  87169. static readonly BILLBOARDMODE_Z: number;
  87170. /** Billboard on all axes */
  87171. static readonly BILLBOARDMODE_ALL: number;
  87172. /** @hidden */
  87173. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87174. /**
  87175. * The culling strategy to use to check whether the mesh must be rendered or not.
  87176. * This value can be changed at any time and will be used on the next render mesh selection.
  87177. * The possible values are :
  87178. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87179. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87180. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87181. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87182. * Please read each static variable documentation to get details about the culling process.
  87183. * */
  87184. cullingStrategy: number;
  87185. /**
  87186. * Gets the number of facets in the mesh
  87187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87188. */
  87189. readonly facetNb: number;
  87190. /**
  87191. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87193. */
  87194. partitioningSubdivisions: number;
  87195. /**
  87196. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87197. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87199. */
  87200. partitioningBBoxRatio: number;
  87201. /**
  87202. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87203. * Works only for updatable meshes.
  87204. * Doesn't work with multi-materials
  87205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87206. */
  87207. mustDepthSortFacets: boolean;
  87208. /**
  87209. * The location (Vector3) where the facet depth sort must be computed from.
  87210. * By default, the active camera position.
  87211. * Used only when facet depth sort is enabled
  87212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87213. */
  87214. facetDepthSortFrom: Vector3;
  87215. /**
  87216. * gets a boolean indicating if facetData is enabled
  87217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87218. */
  87219. readonly isFacetDataEnabled: boolean;
  87220. /** @hidden */
  87221. _updateNonUniformScalingState(value: boolean): boolean;
  87222. /**
  87223. * An event triggered when this mesh collides with another one
  87224. */
  87225. onCollideObservable: Observable<AbstractMesh>;
  87226. /** Set a function to call when this mesh collides with another one */
  87227. onCollide: () => void;
  87228. /**
  87229. * An event triggered when the collision's position changes
  87230. */
  87231. onCollisionPositionChangeObservable: Observable<Vector3>;
  87232. /** Set a function to call when the collision's position changes */
  87233. onCollisionPositionChange: () => void;
  87234. /**
  87235. * An event triggered when material is changed
  87236. */
  87237. onMaterialChangedObservable: Observable<AbstractMesh>;
  87238. /**
  87239. * Gets or sets the orientation for POV movement & rotation
  87240. */
  87241. definedFacingForward: boolean;
  87242. /** @hidden */
  87243. _occlusionQuery: Nullable<WebGLQuery>;
  87244. /** @hidden */
  87245. _renderingGroup: Nullable<RenderingGroup>;
  87246. /**
  87247. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87248. */
  87249. /**
  87250. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87251. */
  87252. visibility: number;
  87253. /** Gets or sets the alpha index used to sort transparent meshes
  87254. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87255. */
  87256. alphaIndex: number;
  87257. /**
  87258. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87259. */
  87260. isVisible: boolean;
  87261. /**
  87262. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87263. */
  87264. isPickable: boolean;
  87265. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87266. showSubMeshesBoundingBox: boolean;
  87267. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87268. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87269. */
  87270. isBlocker: boolean;
  87271. /**
  87272. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87273. */
  87274. enablePointerMoveEvents: boolean;
  87275. /**
  87276. * Specifies the rendering group id for this mesh (0 by default)
  87277. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87278. */
  87279. renderingGroupId: number;
  87280. private _material;
  87281. /** Gets or sets current material */
  87282. material: Nullable<Material>;
  87283. /**
  87284. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87285. * @see http://doc.babylonjs.com/babylon101/shadows
  87286. */
  87287. receiveShadows: boolean;
  87288. /** Defines color to use when rendering outline */
  87289. outlineColor: Color3;
  87290. /** Define width to use when rendering outline */
  87291. outlineWidth: number;
  87292. /** Defines color to use when rendering overlay */
  87293. overlayColor: Color3;
  87294. /** Defines alpha to use when rendering overlay */
  87295. overlayAlpha: number;
  87296. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87297. hasVertexAlpha: boolean;
  87298. /** 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) */
  87299. useVertexColors: boolean;
  87300. /**
  87301. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87302. */
  87303. computeBonesUsingShaders: boolean;
  87304. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87305. numBoneInfluencers: number;
  87306. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87307. applyFog: boolean;
  87308. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87309. useOctreeForRenderingSelection: boolean;
  87310. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87311. useOctreeForPicking: boolean;
  87312. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87313. useOctreeForCollisions: boolean;
  87314. /**
  87315. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87316. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87317. */
  87318. layerMask: number;
  87319. /**
  87320. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87321. */
  87322. alwaysSelectAsActiveMesh: boolean;
  87323. /**
  87324. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87325. */
  87326. doNotSyncBoundingInfo: boolean;
  87327. /**
  87328. * Gets or sets the current action manager
  87329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87330. */
  87331. actionManager: Nullable<AbstractActionManager>;
  87332. private _meshCollisionData;
  87333. /**
  87334. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87336. */
  87337. ellipsoid: Vector3;
  87338. /**
  87339. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87340. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87341. */
  87342. ellipsoidOffset: Vector3;
  87343. /**
  87344. * Gets or sets a collision mask used to mask collisions (default is -1).
  87345. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87346. */
  87347. collisionMask: number;
  87348. /**
  87349. * Gets or sets the current collision group mask (-1 by default).
  87350. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87351. */
  87352. collisionGroup: number;
  87353. /**
  87354. * Defines edge width used when edgesRenderer is enabled
  87355. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87356. */
  87357. edgesWidth: number;
  87358. /**
  87359. * Defines edge color used when edgesRenderer is enabled
  87360. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87361. */
  87362. edgesColor: Color4;
  87363. /** @hidden */
  87364. _edgesRenderer: Nullable<IEdgesRenderer>;
  87365. /** @hidden */
  87366. _masterMesh: Nullable<AbstractMesh>;
  87367. /** @hidden */
  87368. _boundingInfo: Nullable<BoundingInfo>;
  87369. /** @hidden */
  87370. _renderId: number;
  87371. /**
  87372. * Gets or sets the list of subMeshes
  87373. * @see http://doc.babylonjs.com/how_to/multi_materials
  87374. */
  87375. subMeshes: SubMesh[];
  87376. /** @hidden */
  87377. _intersectionsInProgress: AbstractMesh[];
  87378. /** @hidden */
  87379. _unIndexed: boolean;
  87380. /** @hidden */
  87381. _lightSources: Light[];
  87382. /** Gets the list of lights affecting that mesh */
  87383. readonly lightSources: Light[];
  87384. /** @hidden */
  87385. readonly _positions: Nullable<Vector3[]>;
  87386. /** @hidden */
  87387. _waitingData: {
  87388. lods: Nullable<any>;
  87389. actions: Nullable<any>;
  87390. freezeWorldMatrix: Nullable<boolean>;
  87391. };
  87392. /** @hidden */
  87393. _bonesTransformMatrices: Nullable<Float32Array>;
  87394. /** @hidden */
  87395. _transformMatrixTexture: Nullable<RawTexture>;
  87396. /**
  87397. * Gets or sets a skeleton to apply skining transformations
  87398. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87399. */
  87400. skeleton: Nullable<Skeleton>;
  87401. /**
  87402. * An event triggered when the mesh is rebuilt.
  87403. */
  87404. onRebuildObservable: Observable<AbstractMesh>;
  87405. /**
  87406. * Creates a new AbstractMesh
  87407. * @param name defines the name of the mesh
  87408. * @param scene defines the hosting scene
  87409. */
  87410. constructor(name: string, scene?: Nullable<Scene>);
  87411. /**
  87412. * Returns the string "AbstractMesh"
  87413. * @returns "AbstractMesh"
  87414. */
  87415. getClassName(): string;
  87416. /**
  87417. * Gets a string representation of the current mesh
  87418. * @param fullDetails defines a boolean indicating if full details must be included
  87419. * @returns a string representation of the current mesh
  87420. */
  87421. toString(fullDetails?: boolean): string;
  87422. /**
  87423. * @hidden
  87424. */
  87425. protected _getEffectiveParent(): Nullable<Node>;
  87426. /** @hidden */
  87427. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87428. /** @hidden */
  87429. _rebuild(): void;
  87430. /** @hidden */
  87431. _resyncLightSources(): void;
  87432. /** @hidden */
  87433. _resyncLighSource(light: Light): void;
  87434. /** @hidden */
  87435. _unBindEffect(): void;
  87436. /** @hidden */
  87437. _removeLightSource(light: Light): void;
  87438. private _markSubMeshesAsDirty;
  87439. /** @hidden */
  87440. _markSubMeshesAsLightDirty(): void;
  87441. /** @hidden */
  87442. _markSubMeshesAsAttributesDirty(): void;
  87443. /** @hidden */
  87444. _markSubMeshesAsMiscDirty(): void;
  87445. /**
  87446. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87447. */
  87448. scaling: Vector3;
  87449. /**
  87450. * Returns true if the mesh is blocked. Implemented by child classes
  87451. */
  87452. readonly isBlocked: boolean;
  87453. /**
  87454. * Returns the mesh itself by default. Implemented by child classes
  87455. * @param camera defines the camera to use to pick the right LOD level
  87456. * @returns the currentAbstractMesh
  87457. */
  87458. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87459. /**
  87460. * Returns 0 by default. Implemented by child classes
  87461. * @returns an integer
  87462. */
  87463. getTotalVertices(): number;
  87464. /**
  87465. * Returns a positive integer : the total number of indices in this mesh geometry.
  87466. * @returns the numner of indices or zero if the mesh has no geometry.
  87467. */
  87468. getTotalIndices(): number;
  87469. /**
  87470. * Returns null by default. Implemented by child classes
  87471. * @returns null
  87472. */
  87473. getIndices(): Nullable<IndicesArray>;
  87474. /**
  87475. * Returns the array of the requested vertex data kind. Implemented by child classes
  87476. * @param kind defines the vertex data kind to use
  87477. * @returns null
  87478. */
  87479. getVerticesData(kind: string): Nullable<FloatArray>;
  87480. /**
  87481. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87482. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87483. * Note that a new underlying VertexBuffer object is created each call.
  87484. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87485. * @param kind defines vertex data kind:
  87486. * * VertexBuffer.PositionKind
  87487. * * VertexBuffer.UVKind
  87488. * * VertexBuffer.UV2Kind
  87489. * * VertexBuffer.UV3Kind
  87490. * * VertexBuffer.UV4Kind
  87491. * * VertexBuffer.UV5Kind
  87492. * * VertexBuffer.UV6Kind
  87493. * * VertexBuffer.ColorKind
  87494. * * VertexBuffer.MatricesIndicesKind
  87495. * * VertexBuffer.MatricesIndicesExtraKind
  87496. * * VertexBuffer.MatricesWeightsKind
  87497. * * VertexBuffer.MatricesWeightsExtraKind
  87498. * @param data defines the data source
  87499. * @param updatable defines if the data must be flagged as updatable (or static)
  87500. * @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
  87501. * @returns the current mesh
  87502. */
  87503. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87504. /**
  87505. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87506. * If the mesh has no geometry, it is simply returned as it is.
  87507. * @param kind defines vertex data kind:
  87508. * * VertexBuffer.PositionKind
  87509. * * VertexBuffer.UVKind
  87510. * * VertexBuffer.UV2Kind
  87511. * * VertexBuffer.UV3Kind
  87512. * * VertexBuffer.UV4Kind
  87513. * * VertexBuffer.UV5Kind
  87514. * * VertexBuffer.UV6Kind
  87515. * * VertexBuffer.ColorKind
  87516. * * VertexBuffer.MatricesIndicesKind
  87517. * * VertexBuffer.MatricesIndicesExtraKind
  87518. * * VertexBuffer.MatricesWeightsKind
  87519. * * VertexBuffer.MatricesWeightsExtraKind
  87520. * @param data defines the data source
  87521. * @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
  87522. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87523. * @returns the current mesh
  87524. */
  87525. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87526. /**
  87527. * Sets the mesh indices,
  87528. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87529. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87530. * @param totalVertices Defines the total number of vertices
  87531. * @returns the current mesh
  87532. */
  87533. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87534. /**
  87535. * Gets a boolean indicating if specific vertex data is present
  87536. * @param kind defines the vertex data kind to use
  87537. * @returns true is data kind is present
  87538. */
  87539. isVerticesDataPresent(kind: string): boolean;
  87540. /**
  87541. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87542. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87543. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87544. * @returns a BoundingInfo
  87545. */
  87546. getBoundingInfo(): BoundingInfo;
  87547. /**
  87548. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87549. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87550. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87551. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87552. * @returns the current mesh
  87553. */
  87554. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87555. /**
  87556. * Overwrite the current bounding info
  87557. * @param boundingInfo defines the new bounding info
  87558. * @returns the current mesh
  87559. */
  87560. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87561. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87562. readonly useBones: boolean;
  87563. /** @hidden */
  87564. _preActivate(): void;
  87565. /** @hidden */
  87566. _preActivateForIntermediateRendering(renderId: number): void;
  87567. /** @hidden */
  87568. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87569. /** @hidden */
  87570. _postActivate(): void;
  87571. /** @hidden */
  87572. _freeze(): void;
  87573. /** @hidden */
  87574. _unFreeze(): void;
  87575. /**
  87576. * Gets the current world matrix
  87577. * @returns a Matrix
  87578. */
  87579. getWorldMatrix(): Matrix;
  87580. /** @hidden */
  87581. _getWorldMatrixDeterminant(): number;
  87582. /**
  87583. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87584. */
  87585. readonly isAnInstance: boolean;
  87586. /**
  87587. * Perform relative position change from the point of view of behind the front of the mesh.
  87588. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87589. * Supports definition of mesh facing forward or backward
  87590. * @param amountRight defines the distance on the right axis
  87591. * @param amountUp defines the distance on the up axis
  87592. * @param amountForward defines the distance on the forward axis
  87593. * @returns the current mesh
  87594. */
  87595. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87596. /**
  87597. * Calculate relative position change from the point of view of behind the front of the mesh.
  87598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87599. * Supports definition of mesh facing forward or backward
  87600. * @param amountRight defines the distance on the right axis
  87601. * @param amountUp defines the distance on the up axis
  87602. * @param amountForward defines the distance on the forward axis
  87603. * @returns the new displacement vector
  87604. */
  87605. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87606. /**
  87607. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87608. * Supports definition of mesh facing forward or backward
  87609. * @param flipBack defines the flip
  87610. * @param twirlClockwise defines the twirl
  87611. * @param tiltRight defines the tilt
  87612. * @returns the current mesh
  87613. */
  87614. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87615. /**
  87616. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87617. * Supports definition of mesh facing forward or backward.
  87618. * @param flipBack defines the flip
  87619. * @param twirlClockwise defines the twirl
  87620. * @param tiltRight defines the tilt
  87621. * @returns the new rotation vector
  87622. */
  87623. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87624. /**
  87625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87626. * This means the mesh underlying bounding box and sphere are recomputed.
  87627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87628. * @returns the current mesh
  87629. */
  87630. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87631. /** @hidden */
  87632. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87633. /** @hidden */
  87634. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87635. /** @hidden */
  87636. _updateBoundingInfo(): AbstractMesh;
  87637. /** @hidden */
  87638. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87639. /** @hidden */
  87640. protected _afterComputeWorldMatrix(): void;
  87641. /** @hidden */
  87642. readonly _effectiveMesh: AbstractMesh;
  87643. /**
  87644. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87645. * A mesh is in the frustum if its bounding box intersects the frustum
  87646. * @param frustumPlanes defines the frustum to test
  87647. * @returns true if the mesh is in the frustum planes
  87648. */
  87649. isInFrustum(frustumPlanes: Plane[]): boolean;
  87650. /**
  87651. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87652. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87653. * @param frustumPlanes defines the frustum to test
  87654. * @returns true if the mesh is completely in the frustum planes
  87655. */
  87656. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87657. /**
  87658. * True if the mesh intersects another mesh or a SolidParticle object
  87659. * @param mesh defines a target mesh or SolidParticle to test
  87660. * @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)
  87661. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87662. * @returns true if there is an intersection
  87663. */
  87664. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87665. /**
  87666. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87667. * @param point defines the point to test
  87668. * @returns true if there is an intersection
  87669. */
  87670. intersectsPoint(point: Vector3): boolean;
  87671. /**
  87672. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87674. */
  87675. checkCollisions: boolean;
  87676. /**
  87677. * Gets Collider object used to compute collisions (not physics)
  87678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87679. */
  87680. readonly collider: Nullable<Collider>;
  87681. /**
  87682. * Move the mesh using collision engine
  87683. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87684. * @param displacement defines the requested displacement vector
  87685. * @returns the current mesh
  87686. */
  87687. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87688. private _onCollisionPositionChange;
  87689. /** @hidden */
  87690. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87691. /** @hidden */
  87692. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87693. /** @hidden */
  87694. _checkCollision(collider: Collider): AbstractMesh;
  87695. /** @hidden */
  87696. _generatePointsArray(): boolean;
  87697. /**
  87698. * Checks if the passed Ray intersects with the mesh
  87699. * @param ray defines the ray to use
  87700. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87701. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87702. * @returns the picking info
  87703. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87704. */
  87705. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87706. /**
  87707. * Clones the current mesh
  87708. * @param name defines the mesh name
  87709. * @param newParent defines the new mesh parent
  87710. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87711. * @returns the new mesh
  87712. */
  87713. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87714. /**
  87715. * Disposes all the submeshes of the current meshnp
  87716. * @returns the current mesh
  87717. */
  87718. releaseSubMeshes(): AbstractMesh;
  87719. /**
  87720. * Releases resources associated with this abstract mesh.
  87721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87723. */
  87724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87725. /**
  87726. * Adds the passed mesh as a child to the current mesh
  87727. * @param mesh defines the child mesh
  87728. * @returns the current mesh
  87729. */
  87730. addChild(mesh: AbstractMesh): AbstractMesh;
  87731. /**
  87732. * Removes the passed mesh from the current mesh children list
  87733. * @param mesh defines the child mesh
  87734. * @returns the current mesh
  87735. */
  87736. removeChild(mesh: AbstractMesh): AbstractMesh;
  87737. /** @hidden */
  87738. private _initFacetData;
  87739. /**
  87740. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87741. * This method can be called within the render loop.
  87742. * 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
  87743. * @returns the current mesh
  87744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87745. */
  87746. updateFacetData(): AbstractMesh;
  87747. /**
  87748. * Returns the facetLocalNormals array.
  87749. * The normals are expressed in the mesh local spac
  87750. * @returns an array of Vector3
  87751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87752. */
  87753. getFacetLocalNormals(): Vector3[];
  87754. /**
  87755. * Returns the facetLocalPositions array.
  87756. * The facet positions are expressed in the mesh local space
  87757. * @returns an array of Vector3
  87758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87759. */
  87760. getFacetLocalPositions(): Vector3[];
  87761. /**
  87762. * Returns the facetLocalPartioning array
  87763. * @returns an array of array of numbers
  87764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87765. */
  87766. getFacetLocalPartitioning(): number[][];
  87767. /**
  87768. * Returns the i-th facet position in the world system.
  87769. * This method allocates a new Vector3 per call
  87770. * @param i defines the facet index
  87771. * @returns a new Vector3
  87772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87773. */
  87774. getFacetPosition(i: number): Vector3;
  87775. /**
  87776. * Sets the reference Vector3 with the i-th facet position in the world system
  87777. * @param i defines the facet index
  87778. * @param ref defines the target vector
  87779. * @returns the current mesh
  87780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87781. */
  87782. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87783. /**
  87784. * Returns the i-th facet normal in the world system.
  87785. * This method allocates a new Vector3 per call
  87786. * @param i defines the facet index
  87787. * @returns a new Vector3
  87788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87789. */
  87790. getFacetNormal(i: number): Vector3;
  87791. /**
  87792. * Sets the reference Vector3 with the i-th facet normal in the world system
  87793. * @param i defines the facet index
  87794. * @param ref defines the target vector
  87795. * @returns the current mesh
  87796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87797. */
  87798. getFacetNormalToRef(i: number, ref: Vector3): this;
  87799. /**
  87800. * 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)
  87801. * @param x defines x coordinate
  87802. * @param y defines y coordinate
  87803. * @param z defines z coordinate
  87804. * @returns the array of facet indexes
  87805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87806. */
  87807. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87808. /**
  87809. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87810. * @param projected sets as the (x,y,z) world projection on the facet
  87811. * @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
  87812. * @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
  87813. * @param x defines x coordinate
  87814. * @param y defines y coordinate
  87815. * @param z defines z coordinate
  87816. * @returns the face index if found (or null instead)
  87817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87818. */
  87819. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87820. /**
  87821. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87822. * @param projected sets as the (x,y,z) local projection on the facet
  87823. * @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
  87824. * @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
  87825. * @param x defines x coordinate
  87826. * @param y defines y coordinate
  87827. * @param z defines z coordinate
  87828. * @returns the face index if found (or null instead)
  87829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87830. */
  87831. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87832. /**
  87833. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87834. * @returns the parameters
  87835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87836. */
  87837. getFacetDataParameters(): any;
  87838. /**
  87839. * Disables the feature FacetData and frees the related memory
  87840. * @returns the current mesh
  87841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87842. */
  87843. disableFacetData(): AbstractMesh;
  87844. /**
  87845. * Updates the AbstractMesh indices array
  87846. * @param indices defines the data source
  87847. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87848. * @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)
  87849. * @returns the current mesh
  87850. */
  87851. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87852. /**
  87853. * Creates new normals data for the mesh
  87854. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87855. * @returns the current mesh
  87856. */
  87857. createNormals(updatable: boolean): AbstractMesh;
  87858. /**
  87859. * Align the mesh with a normal
  87860. * @param normal defines the normal to use
  87861. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87862. * @returns the current mesh
  87863. */
  87864. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87865. /** @hidden */
  87866. _checkOcclusionQuery(): boolean;
  87867. /**
  87868. * Disables the mesh edge rendering mode
  87869. * @returns the currentAbstractMesh
  87870. */
  87871. disableEdgesRendering(): AbstractMesh;
  87872. /**
  87873. * Enables the edge rendering mode on the mesh.
  87874. * This mode makes the mesh edges visible
  87875. * @param epsilon defines the maximal distance between two angles to detect a face
  87876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87877. * @returns the currentAbstractMesh
  87878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87879. */
  87880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87881. }
  87882. }
  87883. declare module BABYLON {
  87884. /**
  87885. * Interface used to define ActionEvent
  87886. */
  87887. export interface IActionEvent {
  87888. /** The mesh or sprite that triggered the action */
  87889. source: any;
  87890. /** The X mouse cursor position at the time of the event */
  87891. pointerX: number;
  87892. /** The Y mouse cursor position at the time of the event */
  87893. pointerY: number;
  87894. /** The mesh that is currently pointed at (can be null) */
  87895. meshUnderPointer: Nullable<AbstractMesh>;
  87896. /** the original (browser) event that triggered the ActionEvent */
  87897. sourceEvent?: any;
  87898. /** additional data for the event */
  87899. additionalData?: any;
  87900. }
  87901. /**
  87902. * ActionEvent is the event being sent when an action is triggered.
  87903. */
  87904. export class ActionEvent implements IActionEvent {
  87905. /** The mesh or sprite that triggered the action */
  87906. source: any;
  87907. /** The X mouse cursor position at the time of the event */
  87908. pointerX: number;
  87909. /** The Y mouse cursor position at the time of the event */
  87910. pointerY: number;
  87911. /** The mesh that is currently pointed at (can be null) */
  87912. meshUnderPointer: Nullable<AbstractMesh>;
  87913. /** the original (browser) event that triggered the ActionEvent */
  87914. sourceEvent?: any;
  87915. /** additional data for the event */
  87916. additionalData?: any;
  87917. /**
  87918. * Creates a new ActionEvent
  87919. * @param source The mesh or sprite that triggered the action
  87920. * @param pointerX The X mouse cursor position at the time of the event
  87921. * @param pointerY The Y mouse cursor position at the time of the event
  87922. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87923. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87924. * @param additionalData additional data for the event
  87925. */
  87926. constructor(
  87927. /** The mesh or sprite that triggered the action */
  87928. source: any,
  87929. /** The X mouse cursor position at the time of the event */
  87930. pointerX: number,
  87931. /** The Y mouse cursor position at the time of the event */
  87932. pointerY: number,
  87933. /** The mesh that is currently pointed at (can be null) */
  87934. meshUnderPointer: Nullable<AbstractMesh>,
  87935. /** the original (browser) event that triggered the ActionEvent */
  87936. sourceEvent?: any,
  87937. /** additional data for the event */
  87938. additionalData?: any);
  87939. /**
  87940. * Helper function to auto-create an ActionEvent from a source mesh.
  87941. * @param source The source mesh that triggered the event
  87942. * @param evt The original (browser) event
  87943. * @param additionalData additional data for the event
  87944. * @returns the new ActionEvent
  87945. */
  87946. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87947. /**
  87948. * Helper function to auto-create an ActionEvent from a source sprite
  87949. * @param source The source sprite that triggered the event
  87950. * @param scene Scene associated with the sprite
  87951. * @param evt The original (browser) event
  87952. * @param additionalData additional data for the event
  87953. * @returns the new ActionEvent
  87954. */
  87955. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87956. /**
  87957. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87958. * @param scene the scene where the event occurred
  87959. * @param evt The original (browser) event
  87960. * @returns the new ActionEvent
  87961. */
  87962. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87963. /**
  87964. * Helper function to auto-create an ActionEvent from a primitive
  87965. * @param prim defines the target primitive
  87966. * @param pointerPos defines the pointer position
  87967. * @param evt The original (browser) event
  87968. * @param additionalData additional data for the event
  87969. * @returns the new ActionEvent
  87970. */
  87971. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87972. }
  87973. }
  87974. declare module BABYLON {
  87975. /**
  87976. * Abstract class used to decouple action Manager from scene and meshes.
  87977. * Do not instantiate.
  87978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87979. */
  87980. export abstract class AbstractActionManager implements IDisposable {
  87981. /** Gets the list of active triggers */
  87982. static Triggers: {
  87983. [key: string]: number;
  87984. };
  87985. /** Gets the cursor to use when hovering items */
  87986. hoverCursor: string;
  87987. /** Gets the list of actions */
  87988. actions: IAction[];
  87989. /**
  87990. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87991. */
  87992. isRecursive: boolean;
  87993. /**
  87994. * Releases all associated resources
  87995. */
  87996. abstract dispose(): void;
  87997. /**
  87998. * Does this action manager has pointer triggers
  87999. */
  88000. abstract readonly hasPointerTriggers: boolean;
  88001. /**
  88002. * Does this action manager has pick triggers
  88003. */
  88004. abstract readonly hasPickTriggers: boolean;
  88005. /**
  88006. * Process a specific trigger
  88007. * @param trigger defines the trigger to process
  88008. * @param evt defines the event details to be processed
  88009. */
  88010. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  88011. /**
  88012. * Does this action manager handles actions of any of the given triggers
  88013. * @param triggers defines the triggers to be tested
  88014. * @return a boolean indicating whether one (or more) of the triggers is handled
  88015. */
  88016. abstract hasSpecificTriggers(triggers: number[]): boolean;
  88017. /**
  88018. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88019. * speed.
  88020. * @param triggerA defines the trigger to be tested
  88021. * @param triggerB defines the trigger to be tested
  88022. * @return a boolean indicating whether one (or more) of the triggers is handled
  88023. */
  88024. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88025. /**
  88026. * Does this action manager handles actions of a given trigger
  88027. * @param trigger defines the trigger to be tested
  88028. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88029. * @return whether the trigger is handled
  88030. */
  88031. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88032. /**
  88033. * Serialize this manager to a JSON object
  88034. * @param name defines the property name to store this manager
  88035. * @returns a JSON representation of this manager
  88036. */
  88037. abstract serialize(name: string): any;
  88038. /**
  88039. * Registers an action to this action manager
  88040. * @param action defines the action to be registered
  88041. * @return the action amended (prepared) after registration
  88042. */
  88043. abstract registerAction(action: IAction): Nullable<IAction>;
  88044. /**
  88045. * Unregisters an action to this action manager
  88046. * @param action defines the action to be unregistered
  88047. * @return a boolean indicating whether the action has been unregistered
  88048. */
  88049. abstract unregisterAction(action: IAction): Boolean;
  88050. /**
  88051. * Does exist one action manager with at least one trigger
  88052. **/
  88053. static readonly HasTriggers: boolean;
  88054. /**
  88055. * Does exist one action manager with at least one pick trigger
  88056. **/
  88057. static readonly HasPickTriggers: boolean;
  88058. /**
  88059. * Does exist one action manager that handles actions of a given trigger
  88060. * @param trigger defines the trigger to be tested
  88061. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88062. **/
  88063. static HasSpecificTrigger(trigger: number): boolean;
  88064. }
  88065. }
  88066. declare module BABYLON {
  88067. /**
  88068. * Defines how a node can be built from a string name.
  88069. */
  88070. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88071. /**
  88072. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88073. */
  88074. export class Node implements IBehaviorAware<Node> {
  88075. /** @hidden */
  88076. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88077. private static _NodeConstructors;
  88078. /**
  88079. * Add a new node constructor
  88080. * @param type defines the type name of the node to construct
  88081. * @param constructorFunc defines the constructor function
  88082. */
  88083. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88084. /**
  88085. * Returns a node constructor based on type name
  88086. * @param type defines the type name
  88087. * @param name defines the new node name
  88088. * @param scene defines the hosting scene
  88089. * @param options defines optional options to transmit to constructors
  88090. * @returns the new constructor or null
  88091. */
  88092. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88093. /**
  88094. * Gets or sets the name of the node
  88095. */
  88096. name: string;
  88097. /**
  88098. * Gets or sets the id of the node
  88099. */
  88100. id: string;
  88101. /**
  88102. * Gets or sets the unique id of the node
  88103. */
  88104. uniqueId: number;
  88105. /**
  88106. * Gets or sets a string used to store user defined state for the node
  88107. */
  88108. state: string;
  88109. /**
  88110. * Gets or sets an object used to store user defined information for the node
  88111. */
  88112. metadata: any;
  88113. /**
  88114. * For internal use only. Please do not use.
  88115. */
  88116. reservedDataStore: any;
  88117. /**
  88118. * List of inspectable custom properties (used by the Inspector)
  88119. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88120. */
  88121. inspectableCustomProperties: IInspectable[];
  88122. /**
  88123. * Gets or sets a boolean used to define if the node must be serialized
  88124. */
  88125. doNotSerialize: boolean;
  88126. /** @hidden */
  88127. _isDisposed: boolean;
  88128. /**
  88129. * Gets a list of Animations associated with the node
  88130. */
  88131. animations: Animation[];
  88132. protected _ranges: {
  88133. [name: string]: Nullable<AnimationRange>;
  88134. };
  88135. /**
  88136. * Callback raised when the node is ready to be used
  88137. */
  88138. onReady: Nullable<(node: Node) => void>;
  88139. private _isEnabled;
  88140. private _isParentEnabled;
  88141. private _isReady;
  88142. /** @hidden */
  88143. _currentRenderId: number;
  88144. private _parentUpdateId;
  88145. /** @hidden */
  88146. _childUpdateId: number;
  88147. /** @hidden */
  88148. _waitingParentId: Nullable<string>;
  88149. /** @hidden */
  88150. _scene: Scene;
  88151. /** @hidden */
  88152. _cache: any;
  88153. private _parentNode;
  88154. private _children;
  88155. /** @hidden */
  88156. _worldMatrix: Matrix;
  88157. /** @hidden */
  88158. _worldMatrixDeterminant: number;
  88159. /** @hidden */
  88160. _worldMatrixDeterminantIsDirty: boolean;
  88161. /** @hidden */
  88162. private _sceneRootNodesIndex;
  88163. /**
  88164. * Gets a boolean indicating if the node has been disposed
  88165. * @returns true if the node was disposed
  88166. */
  88167. isDisposed(): boolean;
  88168. /**
  88169. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88170. * @see https://doc.babylonjs.com/how_to/parenting
  88171. */
  88172. parent: Nullable<Node>;
  88173. private addToSceneRootNodes;
  88174. private removeFromSceneRootNodes;
  88175. private _animationPropertiesOverride;
  88176. /**
  88177. * Gets or sets the animation properties override
  88178. */
  88179. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88180. /**
  88181. * Gets a string idenfifying the name of the class
  88182. * @returns "Node" string
  88183. */
  88184. getClassName(): string;
  88185. /** @hidden */
  88186. readonly _isNode: boolean;
  88187. /**
  88188. * An event triggered when the mesh is disposed
  88189. */
  88190. onDisposeObservable: Observable<Node>;
  88191. private _onDisposeObserver;
  88192. /**
  88193. * Sets a callback that will be raised when the node will be disposed
  88194. */
  88195. onDispose: () => void;
  88196. /**
  88197. * Creates a new Node
  88198. * @param name the name and id to be given to this node
  88199. * @param scene the scene this node will be added to
  88200. * @param addToRootNodes the node will be added to scene.rootNodes
  88201. */
  88202. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88203. /**
  88204. * Gets the scene of the node
  88205. * @returns a scene
  88206. */
  88207. getScene(): Scene;
  88208. /**
  88209. * Gets the engine of the node
  88210. * @returns a Engine
  88211. */
  88212. getEngine(): Engine;
  88213. private _behaviors;
  88214. /**
  88215. * Attach a behavior to the node
  88216. * @see http://doc.babylonjs.com/features/behaviour
  88217. * @param behavior defines the behavior to attach
  88218. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88219. * @returns the current Node
  88220. */
  88221. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88222. /**
  88223. * Remove an attached behavior
  88224. * @see http://doc.babylonjs.com/features/behaviour
  88225. * @param behavior defines the behavior to attach
  88226. * @returns the current Node
  88227. */
  88228. removeBehavior(behavior: Behavior<Node>): Node;
  88229. /**
  88230. * Gets the list of attached behaviors
  88231. * @see http://doc.babylonjs.com/features/behaviour
  88232. */
  88233. readonly behaviors: Behavior<Node>[];
  88234. /**
  88235. * Gets an attached behavior by name
  88236. * @param name defines the name of the behavior to look for
  88237. * @see http://doc.babylonjs.com/features/behaviour
  88238. * @returns null if behavior was not found else the requested behavior
  88239. */
  88240. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88241. /**
  88242. * Returns the latest update of the World matrix
  88243. * @returns a Matrix
  88244. */
  88245. getWorldMatrix(): Matrix;
  88246. /** @hidden */
  88247. _getWorldMatrixDeterminant(): number;
  88248. /**
  88249. * Returns directly the latest state of the mesh World matrix.
  88250. * A Matrix is returned.
  88251. */
  88252. readonly worldMatrixFromCache: Matrix;
  88253. /** @hidden */
  88254. _initCache(): void;
  88255. /** @hidden */
  88256. updateCache(force?: boolean): void;
  88257. /** @hidden */
  88258. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88259. /** @hidden */
  88260. _updateCache(ignoreParentClass?: boolean): void;
  88261. /** @hidden */
  88262. _isSynchronized(): boolean;
  88263. /** @hidden */
  88264. _markSyncedWithParent(): void;
  88265. /** @hidden */
  88266. isSynchronizedWithParent(): boolean;
  88267. /** @hidden */
  88268. isSynchronized(): boolean;
  88269. /**
  88270. * Is this node ready to be used/rendered
  88271. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88272. * @return true if the node is ready
  88273. */
  88274. isReady(completeCheck?: boolean): boolean;
  88275. /**
  88276. * Is this node enabled?
  88277. * 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
  88278. * @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
  88279. * @return whether this node (and its parent) is enabled
  88280. */
  88281. isEnabled(checkAncestors?: boolean): boolean;
  88282. /** @hidden */
  88283. protected _syncParentEnabledState(): void;
  88284. /**
  88285. * Set the enabled state of this node
  88286. * @param value defines the new enabled state
  88287. */
  88288. setEnabled(value: boolean): void;
  88289. /**
  88290. * Is this node a descendant of the given node?
  88291. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88292. * @param ancestor defines the parent node to inspect
  88293. * @returns a boolean indicating if this node is a descendant of the given node
  88294. */
  88295. isDescendantOf(ancestor: Node): boolean;
  88296. /** @hidden */
  88297. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88298. /**
  88299. * Will return all nodes that have this node as ascendant
  88300. * @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
  88301. * @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
  88302. * @return all children nodes of all types
  88303. */
  88304. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88305. /**
  88306. * Get all child-meshes of this node
  88307. * @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)
  88308. * @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
  88309. * @returns an array of AbstractMesh
  88310. */
  88311. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88312. /**
  88313. * Get all direct children of this node
  88314. * @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
  88315. * @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)
  88316. * @returns an array of Node
  88317. */
  88318. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88319. /** @hidden */
  88320. _setReady(state: boolean): void;
  88321. /**
  88322. * Get an animation by name
  88323. * @param name defines the name of the animation to look for
  88324. * @returns null if not found else the requested animation
  88325. */
  88326. getAnimationByName(name: string): Nullable<Animation>;
  88327. /**
  88328. * Creates an animation range for this node
  88329. * @param name defines the name of the range
  88330. * @param from defines the starting key
  88331. * @param to defines the end key
  88332. */
  88333. createAnimationRange(name: string, from: number, to: number): void;
  88334. /**
  88335. * Delete a specific animation range
  88336. * @param name defines the name of the range to delete
  88337. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88338. */
  88339. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88340. /**
  88341. * Get an animation range by name
  88342. * @param name defines the name of the animation range to look for
  88343. * @returns null if not found else the requested animation range
  88344. */
  88345. getAnimationRange(name: string): Nullable<AnimationRange>;
  88346. /**
  88347. * Gets the list of all animation ranges defined on this node
  88348. * @returns an array
  88349. */
  88350. getAnimationRanges(): Nullable<AnimationRange>[];
  88351. /**
  88352. * Will start the animation sequence
  88353. * @param name defines the range frames for animation sequence
  88354. * @param loop defines if the animation should loop (false by default)
  88355. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88356. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88357. * @returns the object created for this animation. If range does not exist, it will return null
  88358. */
  88359. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88360. /**
  88361. * Serialize animation ranges into a JSON compatible object
  88362. * @returns serialization object
  88363. */
  88364. serializeAnimationRanges(): any;
  88365. /**
  88366. * Computes the world matrix of the node
  88367. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88368. * @returns the world matrix
  88369. */
  88370. computeWorldMatrix(force?: boolean): Matrix;
  88371. /**
  88372. * Releases resources associated with this node.
  88373. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88374. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88375. */
  88376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88377. /**
  88378. * Parse animation range data from a serialization object and store them into a given node
  88379. * @param node defines where to store the animation ranges
  88380. * @param parsedNode defines the serialization object to read data from
  88381. * @param scene defines the hosting scene
  88382. */
  88383. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88384. /**
  88385. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88386. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88387. * @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
  88388. * @returns the new bounding vectors
  88389. */
  88390. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88391. min: Vector3;
  88392. max: Vector3;
  88393. };
  88394. }
  88395. }
  88396. declare module BABYLON {
  88397. /**
  88398. * @hidden
  88399. */
  88400. export class _IAnimationState {
  88401. key: number;
  88402. repeatCount: number;
  88403. workValue?: any;
  88404. loopMode?: number;
  88405. offsetValue?: any;
  88406. highLimitValue?: any;
  88407. }
  88408. /**
  88409. * Class used to store any kind of animation
  88410. */
  88411. export class Animation {
  88412. /**Name of the animation */
  88413. name: string;
  88414. /**Property to animate */
  88415. targetProperty: string;
  88416. /**The frames per second of the animation */
  88417. framePerSecond: number;
  88418. /**The data type of the animation */
  88419. dataType: number;
  88420. /**The loop mode of the animation */
  88421. loopMode?: number | undefined;
  88422. /**Specifies if blending should be enabled */
  88423. enableBlending?: boolean | undefined;
  88424. /**
  88425. * Use matrix interpolation instead of using direct key value when animating matrices
  88426. */
  88427. static AllowMatricesInterpolation: boolean;
  88428. /**
  88429. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88430. */
  88431. static AllowMatrixDecomposeForInterpolation: boolean;
  88432. /**
  88433. * Stores the key frames of the animation
  88434. */
  88435. private _keys;
  88436. /**
  88437. * Stores the easing function of the animation
  88438. */
  88439. private _easingFunction;
  88440. /**
  88441. * @hidden Internal use only
  88442. */
  88443. _runtimeAnimations: RuntimeAnimation[];
  88444. /**
  88445. * The set of event that will be linked to this animation
  88446. */
  88447. private _events;
  88448. /**
  88449. * Stores an array of target property paths
  88450. */
  88451. targetPropertyPath: string[];
  88452. /**
  88453. * Stores the blending speed of the animation
  88454. */
  88455. blendingSpeed: number;
  88456. /**
  88457. * Stores the animation ranges for the animation
  88458. */
  88459. private _ranges;
  88460. /**
  88461. * @hidden Internal use
  88462. */
  88463. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88464. /**
  88465. * Sets up an animation
  88466. * @param property The property to animate
  88467. * @param animationType The animation type to apply
  88468. * @param framePerSecond The frames per second of the animation
  88469. * @param easingFunction The easing function used in the animation
  88470. * @returns The created animation
  88471. */
  88472. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88473. /**
  88474. * Create and start an animation on a node
  88475. * @param name defines the name of the global animation that will be run on all nodes
  88476. * @param node defines the root node where the animation will take place
  88477. * @param targetProperty defines property to animate
  88478. * @param framePerSecond defines the number of frame per second yo use
  88479. * @param totalFrame defines the number of frames in total
  88480. * @param from defines the initial value
  88481. * @param to defines the final value
  88482. * @param loopMode defines which loop mode you want to use (off by default)
  88483. * @param easingFunction defines the easing function to use (linear by default)
  88484. * @param onAnimationEnd defines the callback to call when animation end
  88485. * @returns the animatable created for this animation
  88486. */
  88487. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88488. /**
  88489. * Create and start an animation on a node and its descendants
  88490. * @param name defines the name of the global animation that will be run on all nodes
  88491. * @param node defines the root node where the animation will take place
  88492. * @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
  88493. * @param targetProperty defines property to animate
  88494. * @param framePerSecond defines the number of frame per second to use
  88495. * @param totalFrame defines the number of frames in total
  88496. * @param from defines the initial value
  88497. * @param to defines the final value
  88498. * @param loopMode defines which loop mode you want to use (off by default)
  88499. * @param easingFunction defines the easing function to use (linear by default)
  88500. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88501. * @returns the list of animatables created for all nodes
  88502. * @example https://www.babylonjs-playground.com/#MH0VLI
  88503. */
  88504. 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[]>;
  88505. /**
  88506. * Creates a new animation, merges it with the existing animations and starts it
  88507. * @param name Name of the animation
  88508. * @param node Node which contains the scene that begins the animations
  88509. * @param targetProperty Specifies which property to animate
  88510. * @param framePerSecond The frames per second of the animation
  88511. * @param totalFrame The total number of frames
  88512. * @param from The frame at the beginning of the animation
  88513. * @param to The frame at the end of the animation
  88514. * @param loopMode Specifies the loop mode of the animation
  88515. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88516. * @param onAnimationEnd Callback to run once the animation is complete
  88517. * @returns Nullable animation
  88518. */
  88519. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88520. /**
  88521. * Transition property of an host to the target Value
  88522. * @param property The property to transition
  88523. * @param targetValue The target Value of the property
  88524. * @param host The object where the property to animate belongs
  88525. * @param scene Scene used to run the animation
  88526. * @param frameRate Framerate (in frame/s) to use
  88527. * @param transition The transition type we want to use
  88528. * @param duration The duration of the animation, in milliseconds
  88529. * @param onAnimationEnd Callback trigger at the end of the animation
  88530. * @returns Nullable animation
  88531. */
  88532. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88533. /**
  88534. * Return the array of runtime animations currently using this animation
  88535. */
  88536. readonly runtimeAnimations: RuntimeAnimation[];
  88537. /**
  88538. * Specifies if any of the runtime animations are currently running
  88539. */
  88540. readonly hasRunningRuntimeAnimations: boolean;
  88541. /**
  88542. * Initializes the animation
  88543. * @param name Name of the animation
  88544. * @param targetProperty Property to animate
  88545. * @param framePerSecond The frames per second of the animation
  88546. * @param dataType The data type of the animation
  88547. * @param loopMode The loop mode of the animation
  88548. * @param enableBlending Specifies if blending should be enabled
  88549. */
  88550. constructor(
  88551. /**Name of the animation */
  88552. name: string,
  88553. /**Property to animate */
  88554. targetProperty: string,
  88555. /**The frames per second of the animation */
  88556. framePerSecond: number,
  88557. /**The data type of the animation */
  88558. dataType: number,
  88559. /**The loop mode of the animation */
  88560. loopMode?: number | undefined,
  88561. /**Specifies if blending should be enabled */
  88562. enableBlending?: boolean | undefined);
  88563. /**
  88564. * Converts the animation to a string
  88565. * @param fullDetails support for multiple levels of logging within scene loading
  88566. * @returns String form of the animation
  88567. */
  88568. toString(fullDetails?: boolean): string;
  88569. /**
  88570. * Add an event to this animation
  88571. * @param event Event to add
  88572. */
  88573. addEvent(event: AnimationEvent): void;
  88574. /**
  88575. * Remove all events found at the given frame
  88576. * @param frame The frame to remove events from
  88577. */
  88578. removeEvents(frame: number): void;
  88579. /**
  88580. * Retrieves all the events from the animation
  88581. * @returns Events from the animation
  88582. */
  88583. getEvents(): AnimationEvent[];
  88584. /**
  88585. * Creates an animation range
  88586. * @param name Name of the animation range
  88587. * @param from Starting frame of the animation range
  88588. * @param to Ending frame of the animation
  88589. */
  88590. createRange(name: string, from: number, to: number): void;
  88591. /**
  88592. * Deletes an animation range by name
  88593. * @param name Name of the animation range to delete
  88594. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88595. */
  88596. deleteRange(name: string, deleteFrames?: boolean): void;
  88597. /**
  88598. * Gets the animation range by name, or null if not defined
  88599. * @param name Name of the animation range
  88600. * @returns Nullable animation range
  88601. */
  88602. getRange(name: string): Nullable<AnimationRange>;
  88603. /**
  88604. * Gets the key frames from the animation
  88605. * @returns The key frames of the animation
  88606. */
  88607. getKeys(): Array<IAnimationKey>;
  88608. /**
  88609. * Gets the highest frame rate of the animation
  88610. * @returns Highest frame rate of the animation
  88611. */
  88612. getHighestFrame(): number;
  88613. /**
  88614. * Gets the easing function of the animation
  88615. * @returns Easing function of the animation
  88616. */
  88617. getEasingFunction(): IEasingFunction;
  88618. /**
  88619. * Sets the easing function of the animation
  88620. * @param easingFunction A custom mathematical formula for animation
  88621. */
  88622. setEasingFunction(easingFunction: EasingFunction): void;
  88623. /**
  88624. * Interpolates a scalar linearly
  88625. * @param startValue Start value of the animation curve
  88626. * @param endValue End value of the animation curve
  88627. * @param gradient Scalar amount to interpolate
  88628. * @returns Interpolated scalar value
  88629. */
  88630. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88631. /**
  88632. * Interpolates a scalar cubically
  88633. * @param startValue Start value of the animation curve
  88634. * @param outTangent End tangent of the animation
  88635. * @param endValue End value of the animation curve
  88636. * @param inTangent Start tangent of the animation curve
  88637. * @param gradient Scalar amount to interpolate
  88638. * @returns Interpolated scalar value
  88639. */
  88640. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88641. /**
  88642. * Interpolates a quaternion using a spherical linear interpolation
  88643. * @param startValue Start value of the animation curve
  88644. * @param endValue End value of the animation curve
  88645. * @param gradient Scalar amount to interpolate
  88646. * @returns Interpolated quaternion value
  88647. */
  88648. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88649. /**
  88650. * Interpolates a quaternion cubically
  88651. * @param startValue Start value of the animation curve
  88652. * @param outTangent End tangent of the animation curve
  88653. * @param endValue End value of the animation curve
  88654. * @param inTangent Start tangent of the animation curve
  88655. * @param gradient Scalar amount to interpolate
  88656. * @returns Interpolated quaternion value
  88657. */
  88658. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88659. /**
  88660. * Interpolates a Vector3 linearl
  88661. * @param startValue Start value of the animation curve
  88662. * @param endValue End value of the animation curve
  88663. * @param gradient Scalar amount to interpolate
  88664. * @returns Interpolated scalar value
  88665. */
  88666. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88667. /**
  88668. * Interpolates a Vector3 cubically
  88669. * @param startValue Start value of the animation curve
  88670. * @param outTangent End tangent of the animation
  88671. * @param endValue End value of the animation curve
  88672. * @param inTangent Start tangent of the animation curve
  88673. * @param gradient Scalar amount to interpolate
  88674. * @returns InterpolatedVector3 value
  88675. */
  88676. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88677. /**
  88678. * Interpolates a Vector2 linearly
  88679. * @param startValue Start value of the animation curve
  88680. * @param endValue End value of the animation curve
  88681. * @param gradient Scalar amount to interpolate
  88682. * @returns Interpolated Vector2 value
  88683. */
  88684. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88685. /**
  88686. * Interpolates a Vector2 cubically
  88687. * @param startValue Start value of the animation curve
  88688. * @param outTangent End tangent of the animation
  88689. * @param endValue End value of the animation curve
  88690. * @param inTangent Start tangent of the animation curve
  88691. * @param gradient Scalar amount to interpolate
  88692. * @returns Interpolated Vector2 value
  88693. */
  88694. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88695. /**
  88696. * Interpolates a size linearly
  88697. * @param startValue Start value of the animation curve
  88698. * @param endValue End value of the animation curve
  88699. * @param gradient Scalar amount to interpolate
  88700. * @returns Interpolated Size value
  88701. */
  88702. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88703. /**
  88704. * Interpolates a Color3 linearly
  88705. * @param startValue Start value of the animation curve
  88706. * @param endValue End value of the animation curve
  88707. * @param gradient Scalar amount to interpolate
  88708. * @returns Interpolated Color3 value
  88709. */
  88710. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88711. /**
  88712. * @hidden Internal use only
  88713. */
  88714. _getKeyValue(value: any): any;
  88715. /**
  88716. * @hidden Internal use only
  88717. */
  88718. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88719. /**
  88720. * Defines the function to use to interpolate matrices
  88721. * @param startValue defines the start matrix
  88722. * @param endValue defines the end matrix
  88723. * @param gradient defines the gradient between both matrices
  88724. * @param result defines an optional target matrix where to store the interpolation
  88725. * @returns the interpolated matrix
  88726. */
  88727. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88728. /**
  88729. * Makes a copy of the animation
  88730. * @returns Cloned animation
  88731. */
  88732. clone(): Animation;
  88733. /**
  88734. * Sets the key frames of the animation
  88735. * @param values The animation key frames to set
  88736. */
  88737. setKeys(values: Array<IAnimationKey>): void;
  88738. /**
  88739. * Serializes the animation to an object
  88740. * @returns Serialized object
  88741. */
  88742. serialize(): any;
  88743. /**
  88744. * Float animation type
  88745. */
  88746. private static _ANIMATIONTYPE_FLOAT;
  88747. /**
  88748. * Vector3 animation type
  88749. */
  88750. private static _ANIMATIONTYPE_VECTOR3;
  88751. /**
  88752. * Quaternion animation type
  88753. */
  88754. private static _ANIMATIONTYPE_QUATERNION;
  88755. /**
  88756. * Matrix animation type
  88757. */
  88758. private static _ANIMATIONTYPE_MATRIX;
  88759. /**
  88760. * Color3 animation type
  88761. */
  88762. private static _ANIMATIONTYPE_COLOR3;
  88763. /**
  88764. * Vector2 animation type
  88765. */
  88766. private static _ANIMATIONTYPE_VECTOR2;
  88767. /**
  88768. * Size animation type
  88769. */
  88770. private static _ANIMATIONTYPE_SIZE;
  88771. /**
  88772. * Relative Loop Mode
  88773. */
  88774. private static _ANIMATIONLOOPMODE_RELATIVE;
  88775. /**
  88776. * Cycle Loop Mode
  88777. */
  88778. private static _ANIMATIONLOOPMODE_CYCLE;
  88779. /**
  88780. * Constant Loop Mode
  88781. */
  88782. private static _ANIMATIONLOOPMODE_CONSTANT;
  88783. /**
  88784. * Get the float animation type
  88785. */
  88786. static readonly ANIMATIONTYPE_FLOAT: number;
  88787. /**
  88788. * Get the Vector3 animation type
  88789. */
  88790. static readonly ANIMATIONTYPE_VECTOR3: number;
  88791. /**
  88792. * Get the Vector2 animation type
  88793. */
  88794. static readonly ANIMATIONTYPE_VECTOR2: number;
  88795. /**
  88796. * Get the Size animation type
  88797. */
  88798. static readonly ANIMATIONTYPE_SIZE: number;
  88799. /**
  88800. * Get the Quaternion animation type
  88801. */
  88802. static readonly ANIMATIONTYPE_QUATERNION: number;
  88803. /**
  88804. * Get the Matrix animation type
  88805. */
  88806. static readonly ANIMATIONTYPE_MATRIX: number;
  88807. /**
  88808. * Get the Color3 animation type
  88809. */
  88810. static readonly ANIMATIONTYPE_COLOR3: number;
  88811. /**
  88812. * Get the Relative Loop Mode
  88813. */
  88814. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88815. /**
  88816. * Get the Cycle Loop Mode
  88817. */
  88818. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88819. /**
  88820. * Get the Constant Loop Mode
  88821. */
  88822. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88823. /** @hidden */
  88824. static _UniversalLerp(left: any, right: any, amount: number): any;
  88825. /**
  88826. * Parses an animation object and creates an animation
  88827. * @param parsedAnimation Parsed animation object
  88828. * @returns Animation object
  88829. */
  88830. static Parse(parsedAnimation: any): Animation;
  88831. /**
  88832. * Appends the serialized animations from the source animations
  88833. * @param source Source containing the animations
  88834. * @param destination Target to store the animations
  88835. */
  88836. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88837. }
  88838. }
  88839. declare module BABYLON {
  88840. /**
  88841. * Base class of all the textures in babylon.
  88842. * It groups all the common properties the materials, post process, lights... might need
  88843. * in order to make a correct use of the texture.
  88844. */
  88845. export class BaseTexture implements IAnimatable {
  88846. /**
  88847. * Default anisotropic filtering level for the application.
  88848. * It is set to 4 as a good tradeoff between perf and quality.
  88849. */
  88850. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88851. /**
  88852. * Gets or sets the unique id of the texture
  88853. */
  88854. uniqueId: number;
  88855. /**
  88856. * Define the name of the texture.
  88857. */
  88858. name: string;
  88859. /**
  88860. * Gets or sets an object used to store user defined information.
  88861. */
  88862. metadata: any;
  88863. /**
  88864. * For internal use only. Please do not use.
  88865. */
  88866. reservedDataStore: any;
  88867. private _hasAlpha;
  88868. /**
  88869. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88870. */
  88871. hasAlpha: boolean;
  88872. /**
  88873. * Defines if the alpha value should be determined via the rgb values.
  88874. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88875. */
  88876. getAlphaFromRGB: boolean;
  88877. /**
  88878. * Intensity or strength of the texture.
  88879. * It is commonly used by materials to fine tune the intensity of the texture
  88880. */
  88881. level: number;
  88882. /**
  88883. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88884. * This is part of the texture as textures usually maps to one uv set.
  88885. */
  88886. coordinatesIndex: number;
  88887. private _coordinatesMode;
  88888. /**
  88889. * How a texture is mapped.
  88890. *
  88891. * | Value | Type | Description |
  88892. * | ----- | ----------------------------------- | ----------- |
  88893. * | 0 | EXPLICIT_MODE | |
  88894. * | 1 | SPHERICAL_MODE | |
  88895. * | 2 | PLANAR_MODE | |
  88896. * | 3 | CUBIC_MODE | |
  88897. * | 4 | PROJECTION_MODE | |
  88898. * | 5 | SKYBOX_MODE | |
  88899. * | 6 | INVCUBIC_MODE | |
  88900. * | 7 | EQUIRECTANGULAR_MODE | |
  88901. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88902. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88903. */
  88904. coordinatesMode: number;
  88905. /**
  88906. * | Value | Type | Description |
  88907. * | ----- | ------------------ | ----------- |
  88908. * | 0 | CLAMP_ADDRESSMODE | |
  88909. * | 1 | WRAP_ADDRESSMODE | |
  88910. * | 2 | MIRROR_ADDRESSMODE | |
  88911. */
  88912. wrapU: number;
  88913. /**
  88914. * | Value | Type | Description |
  88915. * | ----- | ------------------ | ----------- |
  88916. * | 0 | CLAMP_ADDRESSMODE | |
  88917. * | 1 | WRAP_ADDRESSMODE | |
  88918. * | 2 | MIRROR_ADDRESSMODE | |
  88919. */
  88920. wrapV: number;
  88921. /**
  88922. * | Value | Type | Description |
  88923. * | ----- | ------------------ | ----------- |
  88924. * | 0 | CLAMP_ADDRESSMODE | |
  88925. * | 1 | WRAP_ADDRESSMODE | |
  88926. * | 2 | MIRROR_ADDRESSMODE | |
  88927. */
  88928. wrapR: number;
  88929. /**
  88930. * With compliant hardware and browser (supporting anisotropic filtering)
  88931. * this defines the level of anisotropic filtering in the texture.
  88932. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88933. */
  88934. anisotropicFilteringLevel: number;
  88935. /**
  88936. * Define if the texture is a cube texture or if false a 2d texture.
  88937. */
  88938. isCube: boolean;
  88939. /**
  88940. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88941. */
  88942. is3D: boolean;
  88943. /**
  88944. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88945. * HDR texture are usually stored in linear space.
  88946. * This only impacts the PBR and Background materials
  88947. */
  88948. gammaSpace: boolean;
  88949. /**
  88950. * Gets whether or not the texture contains RGBD data.
  88951. */
  88952. readonly isRGBD: boolean;
  88953. /**
  88954. * Is Z inverted in the texture (useful in a cube texture).
  88955. */
  88956. invertZ: boolean;
  88957. /**
  88958. * Are mip maps generated for this texture or not.
  88959. */
  88960. readonly noMipmap: boolean;
  88961. /**
  88962. * @hidden
  88963. */
  88964. lodLevelInAlpha: boolean;
  88965. /**
  88966. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88967. */
  88968. lodGenerationOffset: number;
  88969. /**
  88970. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88971. */
  88972. lodGenerationScale: number;
  88973. /**
  88974. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88975. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88976. * average roughness values.
  88977. */
  88978. linearSpecularLOD: boolean;
  88979. /**
  88980. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88981. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88982. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88983. */
  88984. irradianceTexture: Nullable<BaseTexture>;
  88985. /**
  88986. * Define if the texture is a render target.
  88987. */
  88988. isRenderTarget: boolean;
  88989. /**
  88990. * Define the unique id of the texture in the scene.
  88991. */
  88992. readonly uid: string;
  88993. /**
  88994. * Return a string representation of the texture.
  88995. * @returns the texture as a string
  88996. */
  88997. toString(): string;
  88998. /**
  88999. * Get the class name of the texture.
  89000. * @returns "BaseTexture"
  89001. */
  89002. getClassName(): string;
  89003. /**
  89004. * Define the list of animation attached to the texture.
  89005. */
  89006. animations: Animation[];
  89007. /**
  89008. * An event triggered when the texture is disposed.
  89009. */
  89010. onDisposeObservable: Observable<BaseTexture>;
  89011. private _onDisposeObserver;
  89012. /**
  89013. * Callback triggered when the texture has been disposed.
  89014. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89015. */
  89016. onDispose: () => void;
  89017. /**
  89018. * Define the current state of the loading sequence when in delayed load mode.
  89019. */
  89020. delayLoadState: number;
  89021. private _scene;
  89022. /** @hidden */
  89023. _texture: Nullable<InternalTexture>;
  89024. private _uid;
  89025. /**
  89026. * Define if the texture is preventinga material to render or not.
  89027. * If not and the texture is not ready, the engine will use a default black texture instead.
  89028. */
  89029. readonly isBlocking: boolean;
  89030. /**
  89031. * Instantiates a new BaseTexture.
  89032. * Base class of all the textures in babylon.
  89033. * It groups all the common properties the materials, post process, lights... might need
  89034. * in order to make a correct use of the texture.
  89035. * @param scene Define the scene the texture blongs to
  89036. */
  89037. constructor(scene: Nullable<Scene>);
  89038. /**
  89039. * Get the scene the texture belongs to.
  89040. * @returns the scene or null if undefined
  89041. */
  89042. getScene(): Nullable<Scene>;
  89043. /**
  89044. * Get the texture transform matrix used to offset tile the texture for istance.
  89045. * @returns the transformation matrix
  89046. */
  89047. getTextureMatrix(): Matrix;
  89048. /**
  89049. * Get the texture reflection matrix used to rotate/transform the reflection.
  89050. * @returns the reflection matrix
  89051. */
  89052. getReflectionTextureMatrix(): Matrix;
  89053. /**
  89054. * Get the underlying lower level texture from Babylon.
  89055. * @returns the insternal texture
  89056. */
  89057. getInternalTexture(): Nullable<InternalTexture>;
  89058. /**
  89059. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89060. * @returns true if ready or not blocking
  89061. */
  89062. isReadyOrNotBlocking(): boolean;
  89063. /**
  89064. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89065. * @returns true if fully ready
  89066. */
  89067. isReady(): boolean;
  89068. private _cachedSize;
  89069. /**
  89070. * Get the size of the texture.
  89071. * @returns the texture size.
  89072. */
  89073. getSize(): ISize;
  89074. /**
  89075. * Get the base size of the texture.
  89076. * It can be different from the size if the texture has been resized for POT for instance
  89077. * @returns the base size
  89078. */
  89079. getBaseSize(): ISize;
  89080. /**
  89081. * Update the sampling mode of the texture.
  89082. * Default is Trilinear mode.
  89083. *
  89084. * | Value | Type | Description |
  89085. * | ----- | ------------------ | ----------- |
  89086. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89087. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89088. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89089. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89090. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89091. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89092. * | 7 | NEAREST_LINEAR | |
  89093. * | 8 | NEAREST_NEAREST | |
  89094. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89095. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89096. * | 11 | LINEAR_LINEAR | |
  89097. * | 12 | LINEAR_NEAREST | |
  89098. *
  89099. * > _mag_: magnification filter (close to the viewer)
  89100. * > _min_: minification filter (far from the viewer)
  89101. * > _mip_: filter used between mip map levels
  89102. *@param samplingMode Define the new sampling mode of the texture
  89103. */
  89104. updateSamplingMode(samplingMode: number): void;
  89105. /**
  89106. * Scales the texture if is `canRescale()`
  89107. * @param ratio the resize factor we want to use to rescale
  89108. */
  89109. scale(ratio: number): void;
  89110. /**
  89111. * Get if the texture can rescale.
  89112. */
  89113. readonly canRescale: boolean;
  89114. /** @hidden */
  89115. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89116. /** @hidden */
  89117. _rebuild(): void;
  89118. /**
  89119. * Triggers the load sequence in delayed load mode.
  89120. */
  89121. delayLoad(): void;
  89122. /**
  89123. * Clones the texture.
  89124. * @returns the cloned texture
  89125. */
  89126. clone(): Nullable<BaseTexture>;
  89127. /**
  89128. * Get the texture underlying type (INT, FLOAT...)
  89129. */
  89130. readonly textureType: number;
  89131. /**
  89132. * Get the texture underlying format (RGB, RGBA...)
  89133. */
  89134. readonly textureFormat: number;
  89135. /**
  89136. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89137. * This will returns an RGBA array buffer containing either in values (0-255) or
  89138. * float values (0-1) depending of the underlying buffer type.
  89139. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89140. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89141. * @param buffer defines a user defined buffer to fill with data (can be null)
  89142. * @returns The Array buffer containing the pixels data.
  89143. */
  89144. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89145. /**
  89146. * Release and destroy the underlying lower level texture aka internalTexture.
  89147. */
  89148. releaseInternalTexture(): void;
  89149. /**
  89150. * Get the polynomial representation of the texture data.
  89151. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89152. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89153. */
  89154. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89155. /** @hidden */
  89156. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89157. /** @hidden */
  89158. readonly _lodTextureMid: Nullable<BaseTexture>;
  89159. /** @hidden */
  89160. readonly _lodTextureLow: Nullable<BaseTexture>;
  89161. /**
  89162. * Dispose the texture and release its associated resources.
  89163. */
  89164. dispose(): void;
  89165. /**
  89166. * Serialize the texture into a JSON representation that can be parsed later on.
  89167. * @returns the JSON representation of the texture
  89168. */
  89169. serialize(): any;
  89170. /**
  89171. * Helper function to be called back once a list of texture contains only ready textures.
  89172. * @param textures Define the list of textures to wait for
  89173. * @param callback Define the callback triggered once the entire list will be ready
  89174. */
  89175. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89176. }
  89177. }
  89178. declare module BABYLON {
  89179. /**
  89180. * Uniform buffer objects.
  89181. *
  89182. * Handles blocks of uniform on the GPU.
  89183. *
  89184. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89185. *
  89186. * For more information, please refer to :
  89187. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89188. */
  89189. export class UniformBuffer {
  89190. private _engine;
  89191. private _buffer;
  89192. private _data;
  89193. private _bufferData;
  89194. private _dynamic?;
  89195. private _uniformLocations;
  89196. private _uniformSizes;
  89197. private _uniformLocationPointer;
  89198. private _needSync;
  89199. private _noUBO;
  89200. private _currentEffect;
  89201. private static _MAX_UNIFORM_SIZE;
  89202. private static _tempBuffer;
  89203. /**
  89204. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89205. * This is dynamic to allow compat with webgl 1 and 2.
  89206. * You will need to pass the name of the uniform as well as the value.
  89207. */
  89208. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89209. /**
  89210. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89211. * This is dynamic to allow compat with webgl 1 and 2.
  89212. * You will need to pass the name of the uniform as well as the value.
  89213. */
  89214. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89215. /**
  89216. * Lambda to Update a single float in a uniform buffer.
  89217. * This is dynamic to allow compat with webgl 1 and 2.
  89218. * You will need to pass the name of the uniform as well as the value.
  89219. */
  89220. updateFloat: (name: string, x: number) => void;
  89221. /**
  89222. * Lambda to Update a vec2 of float in a uniform buffer.
  89223. * This is dynamic to allow compat with webgl 1 and 2.
  89224. * You will need to pass the name of the uniform as well as the value.
  89225. */
  89226. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89227. /**
  89228. * Lambda to Update a vec3 of float in a uniform buffer.
  89229. * This is dynamic to allow compat with webgl 1 and 2.
  89230. * You will need to pass the name of the uniform as well as the value.
  89231. */
  89232. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89233. /**
  89234. * Lambda to Update a vec4 of float in a uniform buffer.
  89235. * This is dynamic to allow compat with webgl 1 and 2.
  89236. * You will need to pass the name of the uniform as well as the value.
  89237. */
  89238. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89239. /**
  89240. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89241. * This is dynamic to allow compat with webgl 1 and 2.
  89242. * You will need to pass the name of the uniform as well as the value.
  89243. */
  89244. updateMatrix: (name: string, mat: Matrix) => void;
  89245. /**
  89246. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89247. * This is dynamic to allow compat with webgl 1 and 2.
  89248. * You will need to pass the name of the uniform as well as the value.
  89249. */
  89250. updateVector3: (name: string, vector: Vector3) => void;
  89251. /**
  89252. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89253. * This is dynamic to allow compat with webgl 1 and 2.
  89254. * You will need to pass the name of the uniform as well as the value.
  89255. */
  89256. updateVector4: (name: string, vector: Vector4) => void;
  89257. /**
  89258. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89259. * This is dynamic to allow compat with webgl 1 and 2.
  89260. * You will need to pass the name of the uniform as well as the value.
  89261. */
  89262. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89263. /**
  89264. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89265. * This is dynamic to allow compat with webgl 1 and 2.
  89266. * You will need to pass the name of the uniform as well as the value.
  89267. */
  89268. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89269. /**
  89270. * Instantiates a new Uniform buffer objects.
  89271. *
  89272. * Handles blocks of uniform on the GPU.
  89273. *
  89274. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89275. *
  89276. * For more information, please refer to :
  89277. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89278. * @param engine Define the engine the buffer is associated with
  89279. * @param data Define the data contained in the buffer
  89280. * @param dynamic Define if the buffer is updatable
  89281. */
  89282. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89283. /**
  89284. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89285. * or just falling back on setUniformXXX calls.
  89286. */
  89287. readonly useUbo: boolean;
  89288. /**
  89289. * Indicates if the WebGL underlying uniform buffer is in sync
  89290. * with the javascript cache data.
  89291. */
  89292. readonly isSync: boolean;
  89293. /**
  89294. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89295. * Also, a dynamic UniformBuffer will disable cache verification and always
  89296. * update the underlying WebGL uniform buffer to the GPU.
  89297. * @returns if Dynamic, otherwise false
  89298. */
  89299. isDynamic(): boolean;
  89300. /**
  89301. * The data cache on JS side.
  89302. * @returns the underlying data as a float array
  89303. */
  89304. getData(): Float32Array;
  89305. /**
  89306. * The underlying WebGL Uniform buffer.
  89307. * @returns the webgl buffer
  89308. */
  89309. getBuffer(): Nullable<DataBuffer>;
  89310. /**
  89311. * std140 layout specifies how to align data within an UBO structure.
  89312. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89313. * for specs.
  89314. */
  89315. private _fillAlignment;
  89316. /**
  89317. * Adds an uniform in the buffer.
  89318. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89319. * for the layout to be correct !
  89320. * @param name Name of the uniform, as used in the uniform block in the shader.
  89321. * @param size Data size, or data directly.
  89322. */
  89323. addUniform(name: string, size: number | number[]): void;
  89324. /**
  89325. * Adds a Matrix 4x4 to the uniform buffer.
  89326. * @param name Name of the uniform, as used in the uniform block in the shader.
  89327. * @param mat A 4x4 matrix.
  89328. */
  89329. addMatrix(name: string, mat: Matrix): void;
  89330. /**
  89331. * Adds a vec2 to the uniform buffer.
  89332. * @param name Name of the uniform, as used in the uniform block in the shader.
  89333. * @param x Define the x component value of the vec2
  89334. * @param y Define the y component value of the vec2
  89335. */
  89336. addFloat2(name: string, x: number, y: number): void;
  89337. /**
  89338. * Adds a vec3 to the uniform buffer.
  89339. * @param name Name of the uniform, as used in the uniform block in the shader.
  89340. * @param x Define the x component value of the vec3
  89341. * @param y Define the y component value of the vec3
  89342. * @param z Define the z component value of the vec3
  89343. */
  89344. addFloat3(name: string, x: number, y: number, z: number): void;
  89345. /**
  89346. * Adds a vec3 to the uniform buffer.
  89347. * @param name Name of the uniform, as used in the uniform block in the shader.
  89348. * @param color Define the vec3 from a Color
  89349. */
  89350. addColor3(name: string, color: Color3): void;
  89351. /**
  89352. * Adds a vec4 to the uniform buffer.
  89353. * @param name Name of the uniform, as used in the uniform block in the shader.
  89354. * @param color Define the rgb components from a Color
  89355. * @param alpha Define the a component of the vec4
  89356. */
  89357. addColor4(name: string, color: Color3, alpha: number): void;
  89358. /**
  89359. * Adds a vec3 to the uniform buffer.
  89360. * @param name Name of the uniform, as used in the uniform block in the shader.
  89361. * @param vector Define the vec3 components from a Vector
  89362. */
  89363. addVector3(name: string, vector: Vector3): void;
  89364. /**
  89365. * Adds a Matrix 3x3 to the uniform buffer.
  89366. * @param name Name of the uniform, as used in the uniform block in the shader.
  89367. */
  89368. addMatrix3x3(name: string): void;
  89369. /**
  89370. * Adds a Matrix 2x2 to the uniform buffer.
  89371. * @param name Name of the uniform, as used in the uniform block in the shader.
  89372. */
  89373. addMatrix2x2(name: string): void;
  89374. /**
  89375. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89376. */
  89377. create(): void;
  89378. /** @hidden */
  89379. _rebuild(): void;
  89380. /**
  89381. * Updates the WebGL Uniform Buffer on the GPU.
  89382. * If the `dynamic` flag is set to true, no cache comparison is done.
  89383. * Otherwise, the buffer will be updated only if the cache differs.
  89384. */
  89385. update(): void;
  89386. /**
  89387. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89388. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89389. * @param data Define the flattened data
  89390. * @param size Define the size of the data.
  89391. */
  89392. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89393. private _updateMatrix3x3ForUniform;
  89394. private _updateMatrix3x3ForEffect;
  89395. private _updateMatrix2x2ForEffect;
  89396. private _updateMatrix2x2ForUniform;
  89397. private _updateFloatForEffect;
  89398. private _updateFloatForUniform;
  89399. private _updateFloat2ForEffect;
  89400. private _updateFloat2ForUniform;
  89401. private _updateFloat3ForEffect;
  89402. private _updateFloat3ForUniform;
  89403. private _updateFloat4ForEffect;
  89404. private _updateFloat4ForUniform;
  89405. private _updateMatrixForEffect;
  89406. private _updateMatrixForUniform;
  89407. private _updateVector3ForEffect;
  89408. private _updateVector3ForUniform;
  89409. private _updateVector4ForEffect;
  89410. private _updateVector4ForUniform;
  89411. private _updateColor3ForEffect;
  89412. private _updateColor3ForUniform;
  89413. private _updateColor4ForEffect;
  89414. private _updateColor4ForUniform;
  89415. /**
  89416. * Sets a sampler uniform on the effect.
  89417. * @param name Define the name of the sampler.
  89418. * @param texture Define the texture to set in the sampler
  89419. */
  89420. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89421. /**
  89422. * Directly updates the value of the uniform in the cache AND on the GPU.
  89423. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89424. * @param data Define the flattened data
  89425. */
  89426. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89427. /**
  89428. * Binds this uniform buffer to an effect.
  89429. * @param effect Define the effect to bind the buffer to
  89430. * @param name Name of the uniform block in the shader.
  89431. */
  89432. bindToEffect(effect: Effect, name: string): void;
  89433. /**
  89434. * Disposes the uniform buffer.
  89435. */
  89436. dispose(): void;
  89437. }
  89438. }
  89439. declare module BABYLON {
  89440. /**
  89441. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89443. */
  89444. export class Analyser {
  89445. /**
  89446. * Gets or sets the smoothing
  89447. * @ignorenaming
  89448. */
  89449. SMOOTHING: number;
  89450. /**
  89451. * Gets or sets the FFT table size
  89452. * @ignorenaming
  89453. */
  89454. FFT_SIZE: number;
  89455. /**
  89456. * Gets or sets the bar graph amplitude
  89457. * @ignorenaming
  89458. */
  89459. BARGRAPHAMPLITUDE: number;
  89460. /**
  89461. * Gets or sets the position of the debug canvas
  89462. * @ignorenaming
  89463. */
  89464. DEBUGCANVASPOS: {
  89465. x: number;
  89466. y: number;
  89467. };
  89468. /**
  89469. * Gets or sets the debug canvas size
  89470. * @ignorenaming
  89471. */
  89472. DEBUGCANVASSIZE: {
  89473. width: number;
  89474. height: number;
  89475. };
  89476. private _byteFreqs;
  89477. private _byteTime;
  89478. private _floatFreqs;
  89479. private _webAudioAnalyser;
  89480. private _debugCanvas;
  89481. private _debugCanvasContext;
  89482. private _scene;
  89483. private _registerFunc;
  89484. private _audioEngine;
  89485. /**
  89486. * Creates a new analyser
  89487. * @param scene defines hosting scene
  89488. */
  89489. constructor(scene: Scene);
  89490. /**
  89491. * Get the number of data values you will have to play with for the visualization
  89492. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89493. * @returns a number
  89494. */
  89495. getFrequencyBinCount(): number;
  89496. /**
  89497. * Gets the current frequency data as a byte array
  89498. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89499. * @returns a Uint8Array
  89500. */
  89501. getByteFrequencyData(): Uint8Array;
  89502. /**
  89503. * Gets the current waveform as a byte array
  89504. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89505. * @returns a Uint8Array
  89506. */
  89507. getByteTimeDomainData(): Uint8Array;
  89508. /**
  89509. * Gets the current frequency data as a float array
  89510. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89511. * @returns a Float32Array
  89512. */
  89513. getFloatFrequencyData(): Float32Array;
  89514. /**
  89515. * Renders the debug canvas
  89516. */
  89517. drawDebugCanvas(): void;
  89518. /**
  89519. * Stops rendering the debug canvas and removes it
  89520. */
  89521. stopDebugCanvas(): void;
  89522. /**
  89523. * Connects two audio nodes
  89524. * @param inputAudioNode defines first node to connect
  89525. * @param outputAudioNode defines second node to connect
  89526. */
  89527. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89528. /**
  89529. * Releases all associated resources
  89530. */
  89531. dispose(): void;
  89532. }
  89533. }
  89534. declare module BABYLON {
  89535. /**
  89536. * This represents an audio engine and it is responsible
  89537. * to play, synchronize and analyse sounds throughout the application.
  89538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89539. */
  89540. export interface IAudioEngine extends IDisposable {
  89541. /**
  89542. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89543. */
  89544. readonly canUseWebAudio: boolean;
  89545. /**
  89546. * Gets the current AudioContext if available.
  89547. */
  89548. readonly audioContext: Nullable<AudioContext>;
  89549. /**
  89550. * The master gain node defines the global audio volume of your audio engine.
  89551. */
  89552. readonly masterGain: GainNode;
  89553. /**
  89554. * Gets whether or not mp3 are supported by your browser.
  89555. */
  89556. readonly isMP3supported: boolean;
  89557. /**
  89558. * Gets whether or not ogg are supported by your browser.
  89559. */
  89560. readonly isOGGsupported: boolean;
  89561. /**
  89562. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89563. * @ignoreNaming
  89564. */
  89565. WarnedWebAudioUnsupported: boolean;
  89566. /**
  89567. * Defines if the audio engine relies on a custom unlocked button.
  89568. * In this case, the embedded button will not be displayed.
  89569. */
  89570. useCustomUnlockedButton: boolean;
  89571. /**
  89572. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89573. */
  89574. readonly unlocked: boolean;
  89575. /**
  89576. * Event raised when audio has been unlocked on the browser.
  89577. */
  89578. onAudioUnlockedObservable: Observable<AudioEngine>;
  89579. /**
  89580. * Event raised when audio has been locked on the browser.
  89581. */
  89582. onAudioLockedObservable: Observable<AudioEngine>;
  89583. /**
  89584. * Flags the audio engine in Locked state.
  89585. * This happens due to new browser policies preventing audio to autoplay.
  89586. */
  89587. lock(): void;
  89588. /**
  89589. * Unlocks the audio engine once a user action has been done on the dom.
  89590. * This is helpful to resume play once browser policies have been satisfied.
  89591. */
  89592. unlock(): void;
  89593. }
  89594. /**
  89595. * This represents the default audio engine used in babylon.
  89596. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89598. */
  89599. export class AudioEngine implements IAudioEngine {
  89600. private _audioContext;
  89601. private _audioContextInitialized;
  89602. private _muteButton;
  89603. private _hostElement;
  89604. /**
  89605. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89606. */
  89607. canUseWebAudio: boolean;
  89608. /**
  89609. * The master gain node defines the global audio volume of your audio engine.
  89610. */
  89611. masterGain: GainNode;
  89612. /**
  89613. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89614. * @ignoreNaming
  89615. */
  89616. WarnedWebAudioUnsupported: boolean;
  89617. /**
  89618. * Gets whether or not mp3 are supported by your browser.
  89619. */
  89620. isMP3supported: boolean;
  89621. /**
  89622. * Gets whether or not ogg are supported by your browser.
  89623. */
  89624. isOGGsupported: boolean;
  89625. /**
  89626. * Gets whether audio has been unlocked on the device.
  89627. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89628. * a user interaction has happened.
  89629. */
  89630. unlocked: boolean;
  89631. /**
  89632. * Defines if the audio engine relies on a custom unlocked button.
  89633. * In this case, the embedded button will not be displayed.
  89634. */
  89635. useCustomUnlockedButton: boolean;
  89636. /**
  89637. * Event raised when audio has been unlocked on the browser.
  89638. */
  89639. onAudioUnlockedObservable: Observable<AudioEngine>;
  89640. /**
  89641. * Event raised when audio has been locked on the browser.
  89642. */
  89643. onAudioLockedObservable: Observable<AudioEngine>;
  89644. /**
  89645. * Gets the current AudioContext if available.
  89646. */
  89647. readonly audioContext: Nullable<AudioContext>;
  89648. private _connectedAnalyser;
  89649. /**
  89650. * Instantiates a new audio engine.
  89651. *
  89652. * There should be only one per page as some browsers restrict the number
  89653. * of audio contexts you can create.
  89654. * @param hostElement defines the host element where to display the mute icon if necessary
  89655. */
  89656. constructor(hostElement?: Nullable<HTMLElement>);
  89657. /**
  89658. * Flags the audio engine in Locked state.
  89659. * This happens due to new browser policies preventing audio to autoplay.
  89660. */
  89661. lock(): void;
  89662. /**
  89663. * Unlocks the audio engine once a user action has been done on the dom.
  89664. * This is helpful to resume play once browser policies have been satisfied.
  89665. */
  89666. unlock(): void;
  89667. private _resumeAudioContext;
  89668. private _initializeAudioContext;
  89669. private _tryToRun;
  89670. private _triggerRunningState;
  89671. private _triggerSuspendedState;
  89672. private _displayMuteButton;
  89673. private _moveButtonToTopLeft;
  89674. private _onResize;
  89675. private _hideMuteButton;
  89676. /**
  89677. * Destroy and release the resources associated with the audio ccontext.
  89678. */
  89679. dispose(): void;
  89680. /**
  89681. * Gets the global volume sets on the master gain.
  89682. * @returns the global volume if set or -1 otherwise
  89683. */
  89684. getGlobalVolume(): number;
  89685. /**
  89686. * Sets the global volume of your experience (sets on the master gain).
  89687. * @param newVolume Defines the new global volume of the application
  89688. */
  89689. setGlobalVolume(newVolume: number): void;
  89690. /**
  89691. * Connect the audio engine to an audio analyser allowing some amazing
  89692. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89694. * @param analyser The analyser to connect to the engine
  89695. */
  89696. connectToAnalyser(analyser: Analyser): void;
  89697. }
  89698. }
  89699. declare module BABYLON {
  89700. /**
  89701. * Interface used to present a loading screen while loading a scene
  89702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89703. */
  89704. export interface ILoadingScreen {
  89705. /**
  89706. * Function called to display the loading screen
  89707. */
  89708. displayLoadingUI: () => void;
  89709. /**
  89710. * Function called to hide the loading screen
  89711. */
  89712. hideLoadingUI: () => void;
  89713. /**
  89714. * Gets or sets the color to use for the background
  89715. */
  89716. loadingUIBackgroundColor: string;
  89717. /**
  89718. * Gets or sets the text to display while loading
  89719. */
  89720. loadingUIText: string;
  89721. }
  89722. /**
  89723. * Class used for the default loading screen
  89724. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89725. */
  89726. export class DefaultLoadingScreen implements ILoadingScreen {
  89727. private _renderingCanvas;
  89728. private _loadingText;
  89729. private _loadingDivBackgroundColor;
  89730. private _loadingDiv;
  89731. private _loadingTextDiv;
  89732. /** Gets or sets the logo url to use for the default loading screen */
  89733. static DefaultLogoUrl: string;
  89734. /** Gets or sets the spinner url to use for the default loading screen */
  89735. static DefaultSpinnerUrl: string;
  89736. /**
  89737. * Creates a new default loading screen
  89738. * @param _renderingCanvas defines the canvas used to render the scene
  89739. * @param _loadingText defines the default text to display
  89740. * @param _loadingDivBackgroundColor defines the default background color
  89741. */
  89742. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  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 text to display while loading
  89753. */
  89754. loadingUIText: string;
  89755. /**
  89756. * Gets or sets the color to use for the background
  89757. */
  89758. loadingUIBackgroundColor: string;
  89759. private _resizeLoadingUI;
  89760. }
  89761. }
  89762. declare module BABYLON {
  89763. /** @hidden */
  89764. export class WebGLPipelineContext implements IPipelineContext {
  89765. engine: Engine;
  89766. program: Nullable<WebGLProgram>;
  89767. context?: WebGLRenderingContext;
  89768. vertexShader?: WebGLShader;
  89769. fragmentShader?: WebGLShader;
  89770. isParallelCompiled: boolean;
  89771. onCompiled?: () => void;
  89772. transformFeedback?: WebGLTransformFeedback | null;
  89773. readonly isAsync: boolean;
  89774. readonly isReady: boolean;
  89775. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89776. }
  89777. }
  89778. declare module BABYLON {
  89779. /** @hidden */
  89780. export class WebGLDataBuffer extends DataBuffer {
  89781. private _buffer;
  89782. constructor(resource: WebGLBuffer);
  89783. readonly underlyingResource: any;
  89784. }
  89785. }
  89786. declare module BABYLON {
  89787. /** @hidden */
  89788. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89789. attributeProcessor(attribute: string): string;
  89790. varyingProcessor(varying: string, isFragment: boolean): string;
  89791. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89792. }
  89793. }
  89794. declare module BABYLON {
  89795. /**
  89796. * Settings for finer control over video usage
  89797. */
  89798. export interface VideoTextureSettings {
  89799. /**
  89800. * Applies `autoplay` to video, if specified
  89801. */
  89802. autoPlay?: boolean;
  89803. /**
  89804. * Applies `loop` to video, if specified
  89805. */
  89806. loop?: boolean;
  89807. /**
  89808. * Automatically updates internal texture from video at every frame in the render loop
  89809. */
  89810. autoUpdateTexture: boolean;
  89811. /**
  89812. * Image src displayed during the video loading or until the user interacts with the video.
  89813. */
  89814. poster?: string;
  89815. }
  89816. /**
  89817. * If you want to display a video in your scene, this is the special texture for that.
  89818. * This special texture works similar to other textures, with the exception of a few parameters.
  89819. * @see https://doc.babylonjs.com/how_to/video_texture
  89820. */
  89821. export class VideoTexture extends Texture {
  89822. /**
  89823. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89824. */
  89825. readonly autoUpdateTexture: boolean;
  89826. /**
  89827. * The video instance used by the texture internally
  89828. */
  89829. readonly video: HTMLVideoElement;
  89830. private _onUserActionRequestedObservable;
  89831. /**
  89832. * Event triggerd when a dom action is required by the user to play the video.
  89833. * This happens due to recent changes in browser policies preventing video to auto start.
  89834. */
  89835. readonly onUserActionRequestedObservable: Observable<Texture>;
  89836. private _generateMipMaps;
  89837. private _engine;
  89838. private _stillImageCaptured;
  89839. private _displayingPosterTexture;
  89840. private _settings;
  89841. private _createInternalTextureOnEvent;
  89842. /**
  89843. * Creates a video texture.
  89844. * If you want to display a video in your scene, this is the special texture for that.
  89845. * This special texture works similar to other textures, with the exception of a few parameters.
  89846. * @see https://doc.babylonjs.com/how_to/video_texture
  89847. * @param name optional name, will detect from video source, if not defined
  89848. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89849. * @param scene is obviously the current scene.
  89850. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89851. * @param invertY is false by default but can be used to invert video on Y axis
  89852. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89853. * @param settings allows finer control over video usage
  89854. */
  89855. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89856. private _getName;
  89857. private _getVideo;
  89858. private _createInternalTexture;
  89859. private reset;
  89860. /**
  89861. * @hidden Internal method to initiate `update`.
  89862. */
  89863. _rebuild(): void;
  89864. /**
  89865. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89866. */
  89867. update(): void;
  89868. /**
  89869. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89870. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89871. */
  89872. updateTexture(isVisible: boolean): void;
  89873. protected _updateInternalTexture: () => void;
  89874. /**
  89875. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89876. * @param url New url.
  89877. */
  89878. updateURL(url: string): void;
  89879. /**
  89880. * Dispose the texture and release its associated resources.
  89881. */
  89882. dispose(): void;
  89883. /**
  89884. * Creates a video texture straight from a stream.
  89885. * @param scene Define the scene the texture should be created in
  89886. * @param stream Define the stream the texture should be created from
  89887. * @returns The created video texture as a promise
  89888. */
  89889. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89890. /**
  89891. * Creates a video texture straight from your WebCam video feed.
  89892. * @param scene Define the scene the texture should be created in
  89893. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89894. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89895. * @returns The created video texture as a promise
  89896. */
  89897. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89898. minWidth: number;
  89899. maxWidth: number;
  89900. minHeight: number;
  89901. maxHeight: number;
  89902. deviceId: string;
  89903. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89904. /**
  89905. * Creates a video texture straight from your WebCam video feed.
  89906. * @param scene Define the scene the texture should be created in
  89907. * @param onReady Define a callback to triggered once the texture will be ready
  89908. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89909. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89910. */
  89911. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89912. minWidth: number;
  89913. maxWidth: number;
  89914. minHeight: number;
  89915. maxHeight: number;
  89916. deviceId: string;
  89917. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89918. }
  89919. }
  89920. declare module BABYLON {
  89921. /**
  89922. * Interface for attribute information associated with buffer instanciation
  89923. */
  89924. export class InstancingAttributeInfo {
  89925. /**
  89926. * Index/offset of the attribute in the vertex shader
  89927. */
  89928. index: number;
  89929. /**
  89930. * size of the attribute, 1, 2, 3 or 4
  89931. */
  89932. attributeSize: number;
  89933. /**
  89934. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89935. * default is FLOAT
  89936. */
  89937. attribyteType: number;
  89938. /**
  89939. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89940. */
  89941. normalized: boolean;
  89942. /**
  89943. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89944. */
  89945. offset: number;
  89946. /**
  89947. * Name of the GLSL attribute, for debugging purpose only
  89948. */
  89949. attributeName: string;
  89950. }
  89951. /**
  89952. * Define options used to create a depth texture
  89953. */
  89954. export class DepthTextureCreationOptions {
  89955. /** Specifies whether or not a stencil should be allocated in the texture */
  89956. generateStencil?: boolean;
  89957. /** Specifies whether or not bilinear filtering is enable on the texture */
  89958. bilinearFiltering?: boolean;
  89959. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89960. comparisonFunction?: number;
  89961. /** Specifies if the created texture is a cube texture */
  89962. isCube?: boolean;
  89963. }
  89964. /**
  89965. * Class used to describe the capabilities of the engine relatively to the current browser
  89966. */
  89967. export class EngineCapabilities {
  89968. /** Maximum textures units per fragment shader */
  89969. maxTexturesImageUnits: number;
  89970. /** Maximum texture units per vertex shader */
  89971. maxVertexTextureImageUnits: number;
  89972. /** Maximum textures units in the entire pipeline */
  89973. maxCombinedTexturesImageUnits: number;
  89974. /** Maximum texture size */
  89975. maxTextureSize: number;
  89976. /** Maximum cube texture size */
  89977. maxCubemapTextureSize: number;
  89978. /** Maximum render texture size */
  89979. maxRenderTextureSize: number;
  89980. /** Maximum number of vertex attributes */
  89981. maxVertexAttribs: number;
  89982. /** Maximum number of varyings */
  89983. maxVaryingVectors: number;
  89984. /** Maximum number of uniforms per vertex shader */
  89985. maxVertexUniformVectors: number;
  89986. /** Maximum number of uniforms per fragment shader */
  89987. maxFragmentUniformVectors: number;
  89988. /** Defines if standard derivates (dx/dy) are supported */
  89989. standardDerivatives: boolean;
  89990. /** Defines if s3tc texture compression is supported */
  89991. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89992. /** Defines if pvrtc texture compression is supported */
  89993. pvrtc: any;
  89994. /** Defines if etc1 texture compression is supported */
  89995. etc1: any;
  89996. /** Defines if etc2 texture compression is supported */
  89997. etc2: any;
  89998. /** Defines if astc texture compression is supported */
  89999. astc: any;
  90000. /** Defines if float textures are supported */
  90001. textureFloat: boolean;
  90002. /** Defines if vertex array objects are supported */
  90003. vertexArrayObject: boolean;
  90004. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  90005. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  90006. /** Gets the maximum level of anisotropy supported */
  90007. maxAnisotropy: number;
  90008. /** Defines if instancing is supported */
  90009. instancedArrays: boolean;
  90010. /** Defines if 32 bits indices are supported */
  90011. uintIndices: boolean;
  90012. /** Defines if high precision shaders are supported */
  90013. highPrecisionShaderSupported: boolean;
  90014. /** Defines if depth reading in the fragment shader is supported */
  90015. fragmentDepthSupported: boolean;
  90016. /** Defines if float texture linear filtering is supported*/
  90017. textureFloatLinearFiltering: boolean;
  90018. /** Defines if rendering to float textures is supported */
  90019. textureFloatRender: boolean;
  90020. /** Defines if half float textures are supported*/
  90021. textureHalfFloat: boolean;
  90022. /** Defines if half float texture linear filtering is supported*/
  90023. textureHalfFloatLinearFiltering: boolean;
  90024. /** Defines if rendering to half float textures is supported */
  90025. textureHalfFloatRender: boolean;
  90026. /** Defines if textureLOD shader command is supported */
  90027. textureLOD: boolean;
  90028. /** Defines if draw buffers extension is supported */
  90029. drawBuffersExtension: boolean;
  90030. /** Defines if depth textures are supported */
  90031. depthTextureExtension: boolean;
  90032. /** Defines if float color buffer are supported */
  90033. colorBufferFloat: boolean;
  90034. /** Gets disjoint timer query extension (null if not supported) */
  90035. timerQuery: EXT_disjoint_timer_query;
  90036. /** Defines if timestamp can be used with timer query */
  90037. canUseTimestampForTimerQuery: boolean;
  90038. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  90039. multiview: any;
  90040. /** Function used to let the system compiles shaders in background */
  90041. parallelShaderCompile: {
  90042. COMPLETION_STATUS_KHR: number;
  90043. };
  90044. }
  90045. /** Interface defining initialization parameters for Engine class */
  90046. export interface EngineOptions extends WebGLContextAttributes {
  90047. /**
  90048. * Defines if the engine should no exceed a specified device ratio
  90049. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90050. */
  90051. limitDeviceRatio?: number;
  90052. /**
  90053. * Defines if webvr should be enabled automatically
  90054. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90055. */
  90056. autoEnableWebVR?: boolean;
  90057. /**
  90058. * Defines if webgl2 should be turned off even if supported
  90059. * @see http://doc.babylonjs.com/features/webgl2
  90060. */
  90061. disableWebGL2Support?: boolean;
  90062. /**
  90063. * Defines if webaudio should be initialized as well
  90064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90065. */
  90066. audioEngine?: boolean;
  90067. /**
  90068. * Defines if animations should run using a deterministic lock step
  90069. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90070. */
  90071. deterministicLockstep?: boolean;
  90072. /** Defines the maximum steps to use with deterministic lock step mode */
  90073. lockstepMaxSteps?: number;
  90074. /**
  90075. * Defines that engine should ignore context lost events
  90076. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90077. */
  90078. doNotHandleContextLost?: boolean;
  90079. /**
  90080. * Defines that engine should ignore modifying touch action attribute and style
  90081. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90082. */
  90083. doNotHandleTouchAction?: boolean;
  90084. /**
  90085. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90086. */
  90087. useHighPrecisionFloats?: boolean;
  90088. }
  90089. /**
  90090. * Defines the interface used by display changed events
  90091. */
  90092. export interface IDisplayChangedEventArgs {
  90093. /** Gets the vrDisplay object (if any) */
  90094. vrDisplay: Nullable<any>;
  90095. /** Gets a boolean indicating if webVR is supported */
  90096. vrSupported: boolean;
  90097. }
  90098. /**
  90099. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90100. */
  90101. export class Engine {
  90102. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90103. static ExceptionList: ({
  90104. key: string;
  90105. capture: string;
  90106. captureConstraint: number;
  90107. targets: string[];
  90108. } | {
  90109. key: string;
  90110. capture: null;
  90111. captureConstraint: null;
  90112. targets: string[];
  90113. })[];
  90114. /** Gets the list of created engines */
  90115. static readonly Instances: Engine[];
  90116. /**
  90117. * Gets the latest created engine
  90118. */
  90119. static readonly LastCreatedEngine: Nullable<Engine>;
  90120. /**
  90121. * Gets the latest created scene
  90122. */
  90123. static readonly LastCreatedScene: Nullable<Scene>;
  90124. /**
  90125. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90126. * @param flag defines which part of the materials must be marked as dirty
  90127. * @param predicate defines a predicate used to filter which materials should be affected
  90128. */
  90129. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90130. /** @hidden */
  90131. static _TextureLoaders: IInternalTextureLoader[];
  90132. /** Defines that alpha blending is disabled */
  90133. static readonly ALPHA_DISABLE: number;
  90134. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90135. static readonly ALPHA_ADD: number;
  90136. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90137. static readonly ALPHA_COMBINE: number;
  90138. /** Defines that alpha blending to DEST - SRC * DEST */
  90139. static readonly ALPHA_SUBTRACT: number;
  90140. /** Defines that alpha blending to SRC * DEST */
  90141. static readonly ALPHA_MULTIPLY: number;
  90142. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90143. static readonly ALPHA_MAXIMIZED: number;
  90144. /** Defines that alpha blending to SRC + DEST */
  90145. static readonly ALPHA_ONEONE: number;
  90146. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90147. static readonly ALPHA_PREMULTIPLIED: number;
  90148. /**
  90149. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90150. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90151. */
  90152. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90153. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90154. static readonly ALPHA_INTERPOLATE: number;
  90155. /**
  90156. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90157. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90158. */
  90159. static readonly ALPHA_SCREENMODE: number;
  90160. /** Defines that the ressource is not delayed*/
  90161. static readonly DELAYLOADSTATE_NONE: number;
  90162. /** Defines that the ressource was successfully delay loaded */
  90163. static readonly DELAYLOADSTATE_LOADED: number;
  90164. /** Defines that the ressource is currently delay loading */
  90165. static readonly DELAYLOADSTATE_LOADING: number;
  90166. /** Defines that the ressource is delayed and has not started loading */
  90167. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90168. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90169. static readonly NEVER: number;
  90170. /** 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 */
  90171. static readonly ALWAYS: number;
  90172. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90173. static readonly LESS: number;
  90174. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90175. static readonly EQUAL: number;
  90176. /** 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 */
  90177. static readonly LEQUAL: number;
  90178. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90179. static readonly GREATER: number;
  90180. /** 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 */
  90181. static readonly GEQUAL: number;
  90182. /** 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 */
  90183. static readonly NOTEQUAL: number;
  90184. /** Passed to stencilOperation to specify that stencil value must be kept */
  90185. static readonly KEEP: number;
  90186. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90187. static readonly REPLACE: number;
  90188. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90189. static readonly INCR: number;
  90190. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90191. static readonly DECR: number;
  90192. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90193. static readonly INVERT: number;
  90194. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90195. static readonly INCR_WRAP: number;
  90196. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90197. static readonly DECR_WRAP: number;
  90198. /** Texture is not repeating outside of 0..1 UVs */
  90199. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90200. /** Texture is repeating outside of 0..1 UVs */
  90201. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90202. /** Texture is repeating and mirrored */
  90203. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90204. /** ALPHA */
  90205. static readonly TEXTUREFORMAT_ALPHA: number;
  90206. /** LUMINANCE */
  90207. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90208. /** LUMINANCE_ALPHA */
  90209. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90210. /** RGB */
  90211. static readonly TEXTUREFORMAT_RGB: number;
  90212. /** RGBA */
  90213. static readonly TEXTUREFORMAT_RGBA: number;
  90214. /** RED */
  90215. static readonly TEXTUREFORMAT_RED: number;
  90216. /** RED (2nd reference) */
  90217. static readonly TEXTUREFORMAT_R: number;
  90218. /** RG */
  90219. static readonly TEXTUREFORMAT_RG: number;
  90220. /** RED_INTEGER */
  90221. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90222. /** RED_INTEGER (2nd reference) */
  90223. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90224. /** RG_INTEGER */
  90225. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90226. /** RGB_INTEGER */
  90227. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90228. /** RGBA_INTEGER */
  90229. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90230. /** UNSIGNED_BYTE */
  90231. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90232. /** UNSIGNED_BYTE (2nd reference) */
  90233. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90234. /** FLOAT */
  90235. static readonly TEXTURETYPE_FLOAT: number;
  90236. /** HALF_FLOAT */
  90237. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90238. /** BYTE */
  90239. static readonly TEXTURETYPE_BYTE: number;
  90240. /** SHORT */
  90241. static readonly TEXTURETYPE_SHORT: number;
  90242. /** UNSIGNED_SHORT */
  90243. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90244. /** INT */
  90245. static readonly TEXTURETYPE_INT: number;
  90246. /** UNSIGNED_INT */
  90247. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90248. /** UNSIGNED_SHORT_4_4_4_4 */
  90249. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90250. /** UNSIGNED_SHORT_5_5_5_1 */
  90251. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90252. /** UNSIGNED_SHORT_5_6_5 */
  90253. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90254. /** UNSIGNED_INT_2_10_10_10_REV */
  90255. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90256. /** UNSIGNED_INT_24_8 */
  90257. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90258. /** UNSIGNED_INT_10F_11F_11F_REV */
  90259. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90260. /** UNSIGNED_INT_5_9_9_9_REV */
  90261. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90262. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90263. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90264. /** nearest is mag = nearest and min = nearest and mip = linear */
  90265. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90266. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90267. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90268. /** Trilinear is mag = linear and min = linear and mip = linear */
  90269. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90270. /** nearest is mag = nearest and min = nearest and mip = linear */
  90271. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90272. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90273. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90274. /** Trilinear is mag = linear and min = linear and mip = linear */
  90275. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90276. /** mag = nearest and min = nearest and mip = nearest */
  90277. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90278. /** mag = nearest and min = linear and mip = nearest */
  90279. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90280. /** mag = nearest and min = linear and mip = linear */
  90281. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90282. /** mag = nearest and min = linear and mip = none */
  90283. static readonly TEXTURE_NEAREST_LINEAR: number;
  90284. /** mag = nearest and min = nearest and mip = none */
  90285. static readonly TEXTURE_NEAREST_NEAREST: number;
  90286. /** mag = linear and min = nearest and mip = nearest */
  90287. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90288. /** mag = linear and min = nearest and mip = linear */
  90289. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90290. /** mag = linear and min = linear and mip = none */
  90291. static readonly TEXTURE_LINEAR_LINEAR: number;
  90292. /** mag = linear and min = nearest and mip = none */
  90293. static readonly TEXTURE_LINEAR_NEAREST: number;
  90294. /** Explicit coordinates mode */
  90295. static readonly TEXTURE_EXPLICIT_MODE: number;
  90296. /** Spherical coordinates mode */
  90297. static readonly TEXTURE_SPHERICAL_MODE: number;
  90298. /** Planar coordinates mode */
  90299. static readonly TEXTURE_PLANAR_MODE: number;
  90300. /** Cubic coordinates mode */
  90301. static readonly TEXTURE_CUBIC_MODE: number;
  90302. /** Projection coordinates mode */
  90303. static readonly TEXTURE_PROJECTION_MODE: number;
  90304. /** Skybox coordinates mode */
  90305. static readonly TEXTURE_SKYBOX_MODE: number;
  90306. /** Inverse Cubic coordinates mode */
  90307. static readonly TEXTURE_INVCUBIC_MODE: number;
  90308. /** Equirectangular coordinates mode */
  90309. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90310. /** Equirectangular Fixed coordinates mode */
  90311. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90312. /** Equirectangular Fixed Mirrored coordinates mode */
  90313. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90314. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90315. static readonly SCALEMODE_FLOOR: number;
  90316. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90317. static readonly SCALEMODE_NEAREST: number;
  90318. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90319. static readonly SCALEMODE_CEILING: number;
  90320. /**
  90321. * Returns the current npm package of the sdk
  90322. */
  90323. static readonly NpmPackage: string;
  90324. /**
  90325. * Returns the current version of the framework
  90326. */
  90327. static readonly Version: string;
  90328. /**
  90329. * Returns a string describing the current engine
  90330. */
  90331. readonly description: string;
  90332. /**
  90333. * Gets or sets the epsilon value used by collision engine
  90334. */
  90335. static CollisionsEpsilon: number;
  90336. /**
  90337. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90338. */
  90339. static ShadersRepository: string;
  90340. /**
  90341. * Method called to create the default loading screen.
  90342. * This can be overriden in your own app.
  90343. * @param canvas The rendering canvas element
  90344. * @returns The loading screen
  90345. */
  90346. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90347. /**
  90348. * Method called to create the default rescale post process on each engine.
  90349. */
  90350. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90351. /** @hidden */
  90352. _shaderProcessor: IShaderProcessor;
  90353. /**
  90354. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90355. */
  90356. forcePOTTextures: boolean;
  90357. /**
  90358. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90359. */
  90360. isFullscreen: boolean;
  90361. /**
  90362. * Gets a boolean indicating if the pointer is currently locked
  90363. */
  90364. isPointerLock: boolean;
  90365. /**
  90366. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90367. */
  90368. cullBackFaces: boolean;
  90369. /**
  90370. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90371. */
  90372. renderEvenInBackground: boolean;
  90373. /**
  90374. * Gets or sets a boolean indicating that cache can be kept between frames
  90375. */
  90376. preventCacheWipeBetweenFrames: boolean;
  90377. /**
  90378. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90379. **/
  90380. enableOfflineSupport: boolean;
  90381. /**
  90382. * 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)
  90383. **/
  90384. disableManifestCheck: boolean;
  90385. /**
  90386. * Gets the list of created scenes
  90387. */
  90388. scenes: Scene[];
  90389. /**
  90390. * Event raised when a new scene is created
  90391. */
  90392. onNewSceneAddedObservable: Observable<Scene>;
  90393. /**
  90394. * Gets the list of created postprocesses
  90395. */
  90396. postProcesses: PostProcess[];
  90397. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90398. validateShaderPrograms: boolean;
  90399. /**
  90400. * Observable event triggered each time the rendering canvas is resized
  90401. */
  90402. onResizeObservable: Observable<Engine>;
  90403. /**
  90404. * Observable event triggered each time the canvas loses focus
  90405. */
  90406. onCanvasBlurObservable: Observable<Engine>;
  90407. /**
  90408. * Observable event triggered each time the canvas gains focus
  90409. */
  90410. onCanvasFocusObservable: Observable<Engine>;
  90411. /**
  90412. * Observable event triggered each time the canvas receives pointerout event
  90413. */
  90414. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90415. /**
  90416. * Observable event triggered before each texture is initialized
  90417. */
  90418. onBeforeTextureInitObservable: Observable<Texture>;
  90419. /**
  90420. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90421. */
  90422. disableUniformBuffers: boolean;
  90423. /** @hidden */
  90424. _uniformBuffers: UniformBuffer[];
  90425. /**
  90426. * Gets a boolean indicating that the engine supports uniform buffers
  90427. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90428. */
  90429. readonly supportsUniformBuffers: boolean;
  90430. /**
  90431. * Observable raised when the engine begins a new frame
  90432. */
  90433. onBeginFrameObservable: Observable<Engine>;
  90434. /**
  90435. * If set, will be used to request the next animation frame for the render loop
  90436. */
  90437. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90438. /**
  90439. * Observable raised when the engine ends the current frame
  90440. */
  90441. onEndFrameObservable: Observable<Engine>;
  90442. /**
  90443. * Observable raised when the engine is about to compile a shader
  90444. */
  90445. onBeforeShaderCompilationObservable: Observable<Engine>;
  90446. /**
  90447. * Observable raised when the engine has jsut compiled a shader
  90448. */
  90449. onAfterShaderCompilationObservable: Observable<Engine>;
  90450. /** @hidden */
  90451. _gl: WebGLRenderingContext;
  90452. private _renderingCanvas;
  90453. private _windowIsBackground;
  90454. private _webGLVersion;
  90455. protected _highPrecisionShadersAllowed: boolean;
  90456. /** @hidden */
  90457. readonly _shouldUseHighPrecisionShader: boolean;
  90458. /**
  90459. * Gets a boolean indicating that only power of 2 textures are supported
  90460. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90461. */
  90462. readonly needPOTTextures: boolean;
  90463. /** @hidden */
  90464. _badOS: boolean;
  90465. /** @hidden */
  90466. _badDesktopOS: boolean;
  90467. /**
  90468. * Gets the audio engine
  90469. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90470. * @ignorenaming
  90471. */
  90472. static audioEngine: IAudioEngine;
  90473. /**
  90474. * Default AudioEngine factory responsible of creating the Audio Engine.
  90475. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90476. */
  90477. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90478. /**
  90479. * Default offline support factory responsible of creating a tool used to store data locally.
  90480. * By default, this will create a Database object if the workload has been embedded.
  90481. */
  90482. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90483. private _onFocus;
  90484. private _onBlur;
  90485. private _onCanvasPointerOut;
  90486. private _onCanvasBlur;
  90487. private _onCanvasFocus;
  90488. private _onFullscreenChange;
  90489. private _onPointerLockChange;
  90490. private _hardwareScalingLevel;
  90491. /** @hidden */
  90492. _caps: EngineCapabilities;
  90493. private _pointerLockRequested;
  90494. private _isStencilEnable;
  90495. private _colorWrite;
  90496. private _loadingScreen;
  90497. /** @hidden */
  90498. _drawCalls: PerfCounter;
  90499. private _glVersion;
  90500. private _glRenderer;
  90501. private _glVendor;
  90502. private _videoTextureSupported;
  90503. private _renderingQueueLaunched;
  90504. private _activeRenderLoops;
  90505. private _deterministicLockstep;
  90506. private _lockstepMaxSteps;
  90507. /**
  90508. * Observable signaled when a context lost event is raised
  90509. */
  90510. onContextLostObservable: Observable<Engine>;
  90511. /**
  90512. * Observable signaled when a context restored event is raised
  90513. */
  90514. onContextRestoredObservable: Observable<Engine>;
  90515. private _onContextLost;
  90516. private _onContextRestored;
  90517. private _contextWasLost;
  90518. /** @hidden */
  90519. _doNotHandleContextLost: boolean;
  90520. /**
  90521. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90523. */
  90524. doNotHandleContextLost: boolean;
  90525. private _performanceMonitor;
  90526. private _fps;
  90527. private _deltaTime;
  90528. /**
  90529. * Turn this value on if you want to pause FPS computation when in background
  90530. */
  90531. disablePerformanceMonitorInBackground: boolean;
  90532. /**
  90533. * Gets the performance monitor attached to this engine
  90534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90535. */
  90536. readonly performanceMonitor: PerformanceMonitor;
  90537. /**
  90538. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90539. */
  90540. disableVertexArrayObjects: boolean;
  90541. /** @hidden */
  90542. protected _depthCullingState: _DepthCullingState;
  90543. /** @hidden */
  90544. protected _stencilState: _StencilState;
  90545. /** @hidden */
  90546. protected _alphaState: _AlphaState;
  90547. /** @hidden */
  90548. protected _alphaMode: number;
  90549. /** @hidden */
  90550. _internalTexturesCache: InternalTexture[];
  90551. /** @hidden */
  90552. protected _activeChannel: number;
  90553. private _currentTextureChannel;
  90554. /** @hidden */
  90555. protected _boundTexturesCache: {
  90556. [key: string]: Nullable<InternalTexture>;
  90557. };
  90558. /** @hidden */
  90559. protected _currentEffect: Nullable<Effect>;
  90560. /** @hidden */
  90561. protected _currentProgram: Nullable<WebGLProgram>;
  90562. private _compiledEffects;
  90563. private _vertexAttribArraysEnabled;
  90564. /** @hidden */
  90565. protected _cachedViewport: Nullable<Viewport>;
  90566. private _cachedVertexArrayObject;
  90567. /** @hidden */
  90568. protected _cachedVertexBuffers: any;
  90569. /** @hidden */
  90570. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90571. /** @hidden */
  90572. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90573. /** @hidden */
  90574. _currentRenderTarget: Nullable<InternalTexture>;
  90575. private _uintIndicesCurrentlySet;
  90576. private _currentBoundBuffer;
  90577. /** @hidden */
  90578. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90579. private _currentBufferPointers;
  90580. private _currentInstanceLocations;
  90581. private _currentInstanceBuffers;
  90582. private _textureUnits;
  90583. /** @hidden */
  90584. _workingCanvas: Nullable<HTMLCanvasElement>;
  90585. /** @hidden */
  90586. _workingContext: Nullable<CanvasRenderingContext2D>;
  90587. private _rescalePostProcess;
  90588. private _dummyFramebuffer;
  90589. private _externalData;
  90590. /** @hidden */
  90591. _bindedRenderFunction: any;
  90592. private _vaoRecordInProgress;
  90593. private _mustWipeVertexAttributes;
  90594. private _emptyTexture;
  90595. private _emptyCubeTexture;
  90596. private _emptyTexture3D;
  90597. /** @hidden */
  90598. _frameHandler: number;
  90599. private _nextFreeTextureSlots;
  90600. private _maxSimultaneousTextures;
  90601. private _activeRequests;
  90602. private _texturesSupported;
  90603. /** @hidden */
  90604. _textureFormatInUse: Nullable<string>;
  90605. /**
  90606. * Gets the list of texture formats supported
  90607. */
  90608. readonly texturesSupported: Array<string>;
  90609. /**
  90610. * Gets the list of texture formats in use
  90611. */
  90612. readonly textureFormatInUse: Nullable<string>;
  90613. /**
  90614. * Gets the current viewport
  90615. */
  90616. readonly currentViewport: Nullable<Viewport>;
  90617. /**
  90618. * Gets the default empty texture
  90619. */
  90620. readonly emptyTexture: InternalTexture;
  90621. /**
  90622. * Gets the default empty 3D texture
  90623. */
  90624. readonly emptyTexture3D: InternalTexture;
  90625. /**
  90626. * Gets the default empty cube texture
  90627. */
  90628. readonly emptyCubeTexture: InternalTexture;
  90629. /**
  90630. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90631. */
  90632. readonly premultipliedAlpha: boolean;
  90633. /**
  90634. * Creates a new engine
  90635. * @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
  90636. * @param antialias defines enable antialiasing (default: false)
  90637. * @param options defines further options to be sent to the getContext() function
  90638. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90639. */
  90640. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90641. /**
  90642. * Initializes a webVR display and starts listening to display change events
  90643. * The onVRDisplayChangedObservable will be notified upon these changes
  90644. * @returns The onVRDisplayChangedObservable
  90645. */
  90646. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90647. /** @hidden */
  90648. _prepareVRComponent(): void;
  90649. /** @hidden */
  90650. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90651. /** @hidden */
  90652. _submitVRFrame(): void;
  90653. /**
  90654. * Call this function to leave webVR mode
  90655. * Will do nothing if webVR is not supported or if there is no webVR device
  90656. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90657. */
  90658. disableVR(): void;
  90659. /**
  90660. * Gets a boolean indicating that the system is in VR mode and is presenting
  90661. * @returns true if VR mode is engaged
  90662. */
  90663. isVRPresenting(): boolean;
  90664. /** @hidden */
  90665. _requestVRFrame(): void;
  90666. private _disableTouchAction;
  90667. private _rebuildInternalTextures;
  90668. private _rebuildEffects;
  90669. /**
  90670. * Gets a boolean indicating if all created effects are ready
  90671. * @returns true if all effects are ready
  90672. */
  90673. areAllEffectsReady(): boolean;
  90674. private _rebuildBuffers;
  90675. private _initGLContext;
  90676. /**
  90677. * Gets version of the current webGL context
  90678. */
  90679. readonly webGLVersion: number;
  90680. /**
  90681. * Gets a string idenfifying the name of the class
  90682. * @returns "Engine" string
  90683. */
  90684. getClassName(): string;
  90685. /**
  90686. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90687. */
  90688. readonly isStencilEnable: boolean;
  90689. /** @hidden */
  90690. _prepareWorkingCanvas(): void;
  90691. /**
  90692. * Reset the texture cache to empty state
  90693. */
  90694. resetTextureCache(): void;
  90695. /**
  90696. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90697. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90698. * @returns true if engine is in deterministic lock step mode
  90699. */
  90700. isDeterministicLockStep(): boolean;
  90701. /**
  90702. * Gets the max steps when engine is running in deterministic lock step
  90703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90704. * @returns the max steps
  90705. */
  90706. getLockstepMaxSteps(): number;
  90707. /**
  90708. * Gets an object containing information about the current webGL context
  90709. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90710. */
  90711. getGlInfo(): {
  90712. vendor: string;
  90713. renderer: string;
  90714. version: string;
  90715. };
  90716. /**
  90717. * Gets current aspect ratio
  90718. * @param camera defines the camera to use to get the aspect ratio
  90719. * @param useScreen defines if screen size must be used (or the current render target if any)
  90720. * @returns a number defining the aspect ratio
  90721. */
  90722. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90723. /**
  90724. * Gets current screen aspect ratio
  90725. * @returns a number defining the aspect ratio
  90726. */
  90727. getScreenAspectRatio(): number;
  90728. /**
  90729. * Gets the current render width
  90730. * @param useScreen defines if screen size must be used (or the current render target if any)
  90731. * @returns a number defining the current render width
  90732. */
  90733. getRenderWidth(useScreen?: boolean): number;
  90734. /**
  90735. * Gets the current render height
  90736. * @param useScreen defines if screen size must be used (or the current render target if any)
  90737. * @returns a number defining the current render height
  90738. */
  90739. getRenderHeight(useScreen?: boolean): number;
  90740. /**
  90741. * Gets the HTML canvas attached with the current webGL context
  90742. * @returns a HTML canvas
  90743. */
  90744. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90745. /**
  90746. * Gets the client rect of the HTML canvas attached with the current webGL context
  90747. * @returns a client rectanglee
  90748. */
  90749. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90750. /**
  90751. * Defines the hardware scaling level.
  90752. * By default the hardware scaling level is computed from the window device ratio.
  90753. * 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.
  90754. * @param level defines the level to use
  90755. */
  90756. setHardwareScalingLevel(level: number): void;
  90757. /**
  90758. * Gets the current hardware scaling level.
  90759. * By default the hardware scaling level is computed from the window device ratio.
  90760. * 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.
  90761. * @returns a number indicating the current hardware scaling level
  90762. */
  90763. getHardwareScalingLevel(): number;
  90764. /**
  90765. * Gets the list of loaded textures
  90766. * @returns an array containing all loaded textures
  90767. */
  90768. getLoadedTexturesCache(): InternalTexture[];
  90769. /**
  90770. * Gets the object containing all engine capabilities
  90771. * @returns the EngineCapabilities object
  90772. */
  90773. getCaps(): EngineCapabilities;
  90774. /**
  90775. * Gets the current depth function
  90776. * @returns a number defining the depth function
  90777. */
  90778. getDepthFunction(): Nullable<number>;
  90779. /**
  90780. * Sets the current depth function
  90781. * @param depthFunc defines the function to use
  90782. */
  90783. setDepthFunction(depthFunc: number): void;
  90784. /**
  90785. * Sets the current depth function to GREATER
  90786. */
  90787. setDepthFunctionToGreater(): void;
  90788. /**
  90789. * Sets the current depth function to GEQUAL
  90790. */
  90791. setDepthFunctionToGreaterOrEqual(): void;
  90792. /**
  90793. * Sets the current depth function to LESS
  90794. */
  90795. setDepthFunctionToLess(): void;
  90796. private _cachedStencilBuffer;
  90797. private _cachedStencilFunction;
  90798. private _cachedStencilMask;
  90799. private _cachedStencilOperationPass;
  90800. private _cachedStencilOperationFail;
  90801. private _cachedStencilOperationDepthFail;
  90802. private _cachedStencilReference;
  90803. /**
  90804. * Caches the the state of the stencil buffer
  90805. */
  90806. cacheStencilState(): void;
  90807. /**
  90808. * Restores the state of the stencil buffer
  90809. */
  90810. restoreStencilState(): void;
  90811. /**
  90812. * Sets the current depth function to LEQUAL
  90813. */
  90814. setDepthFunctionToLessOrEqual(): void;
  90815. /**
  90816. * Gets a boolean indicating if stencil buffer is enabled
  90817. * @returns the current stencil buffer state
  90818. */
  90819. getStencilBuffer(): boolean;
  90820. /**
  90821. * Enable or disable the stencil buffer
  90822. * @param enable defines if the stencil buffer must be enabled or disabled
  90823. */
  90824. setStencilBuffer(enable: boolean): void;
  90825. /**
  90826. * Gets the current stencil mask
  90827. * @returns a number defining the new stencil mask to use
  90828. */
  90829. getStencilMask(): number;
  90830. /**
  90831. * Sets the current stencil mask
  90832. * @param mask defines the new stencil mask to use
  90833. */
  90834. setStencilMask(mask: number): void;
  90835. /**
  90836. * Gets the current stencil function
  90837. * @returns a number defining the stencil function to use
  90838. */
  90839. getStencilFunction(): number;
  90840. /**
  90841. * Gets the current stencil reference value
  90842. * @returns a number defining the stencil reference value to use
  90843. */
  90844. getStencilFunctionReference(): number;
  90845. /**
  90846. * Gets the current stencil mask
  90847. * @returns a number defining the stencil mask to use
  90848. */
  90849. getStencilFunctionMask(): number;
  90850. /**
  90851. * Sets the current stencil function
  90852. * @param stencilFunc defines the new stencil function to use
  90853. */
  90854. setStencilFunction(stencilFunc: number): void;
  90855. /**
  90856. * Sets the current stencil reference
  90857. * @param reference defines the new stencil reference to use
  90858. */
  90859. setStencilFunctionReference(reference: number): void;
  90860. /**
  90861. * Sets the current stencil mask
  90862. * @param mask defines the new stencil mask to use
  90863. */
  90864. setStencilFunctionMask(mask: number): void;
  90865. /**
  90866. * Gets the current stencil operation when stencil fails
  90867. * @returns a number defining stencil operation to use when stencil fails
  90868. */
  90869. getStencilOperationFail(): number;
  90870. /**
  90871. * Gets the current stencil operation when depth fails
  90872. * @returns a number defining stencil operation to use when depth fails
  90873. */
  90874. getStencilOperationDepthFail(): number;
  90875. /**
  90876. * Gets the current stencil operation when stencil passes
  90877. * @returns a number defining stencil operation to use when stencil passes
  90878. */
  90879. getStencilOperationPass(): number;
  90880. /**
  90881. * Sets the stencil operation to use when stencil fails
  90882. * @param operation defines the stencil operation to use when stencil fails
  90883. */
  90884. setStencilOperationFail(operation: number): void;
  90885. /**
  90886. * Sets the stencil operation to use when depth fails
  90887. * @param operation defines the stencil operation to use when depth fails
  90888. */
  90889. setStencilOperationDepthFail(operation: number): void;
  90890. /**
  90891. * Sets the stencil operation to use when stencil passes
  90892. * @param operation defines the stencil operation to use when stencil passes
  90893. */
  90894. setStencilOperationPass(operation: number): void;
  90895. /**
  90896. * Sets a boolean indicating if the dithering state is enabled or disabled
  90897. * @param value defines the dithering state
  90898. */
  90899. setDitheringState(value: boolean): void;
  90900. /**
  90901. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90902. * @param value defines the rasterizer state
  90903. */
  90904. setRasterizerState(value: boolean): void;
  90905. /**
  90906. * stop executing a render loop function and remove it from the execution array
  90907. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90908. */
  90909. stopRenderLoop(renderFunction?: () => void): void;
  90910. /** @hidden */
  90911. _renderLoop(): void;
  90912. /**
  90913. * Register and execute a render loop. The engine can have more than one render function
  90914. * @param renderFunction defines the function to continuously execute
  90915. */
  90916. runRenderLoop(renderFunction: () => void): void;
  90917. /**
  90918. * Toggle full screen mode
  90919. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90920. */
  90921. switchFullscreen(requestPointerLock: boolean): void;
  90922. /**
  90923. * Enters full screen mode
  90924. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90925. */
  90926. enterFullscreen(requestPointerLock: boolean): void;
  90927. /**
  90928. * Exits full screen mode
  90929. */
  90930. exitFullscreen(): void;
  90931. /**
  90932. * Enters Pointerlock mode
  90933. */
  90934. enterPointerlock(): void;
  90935. /**
  90936. * Exits Pointerlock mode
  90937. */
  90938. exitPointerlock(): void;
  90939. /**
  90940. * Clear the current render buffer or the current render target (if any is set up)
  90941. * @param color defines the color to use
  90942. * @param backBuffer defines if the back buffer must be cleared
  90943. * @param depth defines if the depth buffer must be cleared
  90944. * @param stencil defines if the stencil buffer must be cleared
  90945. */
  90946. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90947. /**
  90948. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90949. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90950. * @param y defines the y-coordinate of the corner of the clear rectangle
  90951. * @param width defines the width of the clear rectangle
  90952. * @param height defines the height of the clear rectangle
  90953. * @param clearColor defines the clear color
  90954. */
  90955. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90956. /**
  90957. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90958. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90959. * @param y defines the y-coordinate of the corner of the clear rectangle
  90960. * @param width defines the width of the clear rectangle
  90961. * @param height defines the height of the clear rectangle
  90962. */
  90963. enableScissor(x: number, y: number, width: number, height: number): void;
  90964. /**
  90965. * Disable previously set scissor test rectangle
  90966. */
  90967. disableScissor(): void;
  90968. private _viewportCached;
  90969. /** @hidden */
  90970. _viewport(x: number, y: number, width: number, height: number): void;
  90971. /**
  90972. * Set the WebGL's viewport
  90973. * @param viewport defines the viewport element to be used
  90974. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90975. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90976. */
  90977. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90978. /**
  90979. * Directly set the WebGL Viewport
  90980. * @param x defines the x coordinate of the viewport (in screen space)
  90981. * @param y defines the y coordinate of the viewport (in screen space)
  90982. * @param width defines the width of the viewport (in screen space)
  90983. * @param height defines the height of the viewport (in screen space)
  90984. * @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
  90985. */
  90986. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90987. /**
  90988. * Begin a new frame
  90989. */
  90990. beginFrame(): void;
  90991. /**
  90992. * Enf the current frame
  90993. */
  90994. endFrame(): void;
  90995. /**
  90996. * Resize the view according to the canvas' size
  90997. */
  90998. resize(): void;
  90999. /**
  91000. * Force a specific size of the canvas
  91001. * @param width defines the new canvas' width
  91002. * @param height defines the new canvas' height
  91003. */
  91004. setSize(width: number, height: number): void;
  91005. /**
  91006. * Binds the frame buffer to the specified texture.
  91007. * @param texture The texture to render to or null for the default canvas
  91008. * @param faceIndex The face of the texture to render to in case of cube texture
  91009. * @param requiredWidth The width of the target to render to
  91010. * @param requiredHeight The height of the target to render to
  91011. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  91012. * @param depthStencilTexture The depth stencil texture to use to render
  91013. * @param lodLevel defines le lod level to bind to the frame buffer
  91014. */
  91015. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  91016. /** @hidden */
  91017. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  91018. /**
  91019. * Unbind the current render target texture from the webGL context
  91020. * @param texture defines the render target texture to unbind
  91021. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  91022. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  91023. */
  91024. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  91025. /**
  91026. * Force the mipmap generation for the given render target texture
  91027. * @param texture defines the render target texture to use
  91028. */
  91029. generateMipMapsForCubemap(texture: InternalTexture): void;
  91030. /**
  91031. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  91032. */
  91033. flushFramebuffer(): void;
  91034. /**
  91035. * Unbind the current render target and bind the default framebuffer
  91036. */
  91037. restoreDefaultFramebuffer(): void;
  91038. /**
  91039. * Create an uniform buffer
  91040. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91041. * @param elements defines the content of the uniform buffer
  91042. * @returns the webGL uniform buffer
  91043. */
  91044. createUniformBuffer(elements: FloatArray): DataBuffer;
  91045. /**
  91046. * Create a dynamic uniform buffer
  91047. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91048. * @param elements defines the content of the uniform buffer
  91049. * @returns the webGL uniform buffer
  91050. */
  91051. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91052. /**
  91053. * Update an existing uniform buffer
  91054. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91055. * @param uniformBuffer defines the target uniform buffer
  91056. * @param elements defines the content to update
  91057. * @param offset defines the offset in the uniform buffer where update should start
  91058. * @param count defines the size of the data to update
  91059. */
  91060. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91061. private _resetVertexBufferBinding;
  91062. /**
  91063. * Creates a vertex buffer
  91064. * @param data the data for the vertex buffer
  91065. * @returns the new WebGL static buffer
  91066. */
  91067. createVertexBuffer(data: DataArray): DataBuffer;
  91068. /**
  91069. * Creates a dynamic vertex buffer
  91070. * @param data the data for the dynamic vertex buffer
  91071. * @returns the new WebGL dynamic buffer
  91072. */
  91073. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91074. /**
  91075. * Update a dynamic index buffer
  91076. * @param indexBuffer defines the target index buffer
  91077. * @param indices defines the data to update
  91078. * @param offset defines the offset in the target index buffer where update should start
  91079. */
  91080. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91081. /**
  91082. * Updates a dynamic vertex buffer.
  91083. * @param vertexBuffer the vertex buffer to update
  91084. * @param data the data used to update the vertex buffer
  91085. * @param byteOffset the byte offset of the data
  91086. * @param byteLength the byte length of the data
  91087. */
  91088. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91089. private _resetIndexBufferBinding;
  91090. /**
  91091. * Creates a new index buffer
  91092. * @param indices defines the content of the index buffer
  91093. * @param updatable defines if the index buffer must be updatable
  91094. * @returns a new webGL buffer
  91095. */
  91096. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91097. /**
  91098. * Bind a webGL buffer to the webGL context
  91099. * @param buffer defines the buffer to bind
  91100. */
  91101. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91102. /**
  91103. * Bind an uniform buffer to the current webGL context
  91104. * @param buffer defines the buffer to bind
  91105. */
  91106. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91107. /**
  91108. * Bind a buffer to the current webGL context at a given location
  91109. * @param buffer defines the buffer to bind
  91110. * @param location defines the index where to bind the buffer
  91111. */
  91112. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91113. /**
  91114. * Bind a specific block at a given index in a specific shader program
  91115. * @param pipelineContext defines the pipeline context to use
  91116. * @param blockName defines the block name
  91117. * @param index defines the index where to bind the block
  91118. */
  91119. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91120. private bindIndexBuffer;
  91121. private bindBuffer;
  91122. /**
  91123. * update the bound buffer with the given data
  91124. * @param data defines the data to update
  91125. */
  91126. updateArrayBuffer(data: Float32Array): void;
  91127. private _vertexAttribPointer;
  91128. private _bindIndexBufferWithCache;
  91129. private _bindVertexBuffersAttributes;
  91130. /**
  91131. * Records a vertex array object
  91132. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91133. * @param vertexBuffers defines the list of vertex buffers to store
  91134. * @param indexBuffer defines the index buffer to store
  91135. * @param effect defines the effect to store
  91136. * @returns the new vertex array object
  91137. */
  91138. recordVertexArrayObject(vertexBuffers: {
  91139. [key: string]: VertexBuffer;
  91140. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91141. /**
  91142. * Bind a specific vertex array object
  91143. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91144. * @param vertexArrayObject defines the vertex array object to bind
  91145. * @param indexBuffer defines the index buffer to bind
  91146. */
  91147. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91148. /**
  91149. * Bind webGl buffers directly to the webGL context
  91150. * @param vertexBuffer defines the vertex buffer to bind
  91151. * @param indexBuffer defines the index buffer to bind
  91152. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91153. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91154. * @param effect defines the effect associated with the vertex buffer
  91155. */
  91156. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91157. private _unbindVertexArrayObject;
  91158. /**
  91159. * Bind a list of vertex buffers to the webGL context
  91160. * @param vertexBuffers defines the list of vertex buffers to bind
  91161. * @param indexBuffer defines the index buffer to bind
  91162. * @param effect defines the effect associated with the vertex buffers
  91163. */
  91164. bindBuffers(vertexBuffers: {
  91165. [key: string]: Nullable<VertexBuffer>;
  91166. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91167. /**
  91168. * Unbind all instance attributes
  91169. */
  91170. unbindInstanceAttributes(): void;
  91171. /**
  91172. * Release and free the memory of a vertex array object
  91173. * @param vao defines the vertex array object to delete
  91174. */
  91175. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91176. /** @hidden */
  91177. _releaseBuffer(buffer: DataBuffer): boolean;
  91178. /**
  91179. * Creates a webGL buffer to use with instanciation
  91180. * @param capacity defines the size of the buffer
  91181. * @returns the webGL buffer
  91182. */
  91183. createInstancesBuffer(capacity: number): DataBuffer;
  91184. /**
  91185. * Delete a webGL buffer used with instanciation
  91186. * @param buffer defines the webGL buffer to delete
  91187. */
  91188. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91189. /**
  91190. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91191. * @param instancesBuffer defines the webGL buffer to update and bind
  91192. * @param data defines the data to store in the buffer
  91193. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91194. */
  91195. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91196. /**
  91197. * Apply all cached states (depth, culling, stencil and alpha)
  91198. */
  91199. applyStates(): void;
  91200. /**
  91201. * Send a draw order
  91202. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91203. * @param indexStart defines the starting index
  91204. * @param indexCount defines the number of index to draw
  91205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91206. */
  91207. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91208. /**
  91209. * Draw a list of points
  91210. * @param verticesStart defines the index of first vertex to draw
  91211. * @param verticesCount defines the count of vertices to draw
  91212. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91213. */
  91214. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91215. /**
  91216. * Draw a list of unindexed primitives
  91217. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91218. * @param verticesStart defines the index of first vertex to draw
  91219. * @param verticesCount defines the count of vertices to draw
  91220. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91221. */
  91222. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91223. /**
  91224. * Draw a list of indexed primitives
  91225. * @param fillMode defines the primitive to use
  91226. * @param indexStart defines the starting index
  91227. * @param indexCount defines the number of index to draw
  91228. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91229. */
  91230. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91231. /**
  91232. * Draw a list of unindexed primitives
  91233. * @param fillMode defines the primitive to use
  91234. * @param verticesStart defines the index of first vertex to draw
  91235. * @param verticesCount defines the count of vertices to draw
  91236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91237. */
  91238. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91239. private _drawMode;
  91240. /** @hidden */
  91241. _releaseEffect(effect: Effect): void;
  91242. /** @hidden */
  91243. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91244. /**
  91245. * Create a new effect (used to store vertex/fragment shaders)
  91246. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91247. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91248. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91249. * @param samplers defines an array of string used to represent textures
  91250. * @param defines defines the string containing the defines to use to compile the shaders
  91251. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91252. * @param onCompiled defines a function to call when the effect creation is successful
  91253. * @param onError defines a function to call when the effect creation has failed
  91254. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91255. * @returns the new Effect
  91256. */
  91257. 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;
  91258. private _compileShader;
  91259. private _compileRawShader;
  91260. /**
  91261. * Directly creates a webGL program
  91262. * @param pipelineContext defines the pipeline context to attach to
  91263. * @param vertexCode defines the vertex shader code to use
  91264. * @param fragmentCode defines the fragment shader code to use
  91265. * @param context defines the webGL context to use (if not set, the current one will be used)
  91266. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91267. * @returns the new webGL program
  91268. */
  91269. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91270. /**
  91271. * Creates a webGL program
  91272. * @param pipelineContext defines the pipeline context to attach to
  91273. * @param vertexCode defines the vertex shader code to use
  91274. * @param fragmentCode defines the fragment shader code to use
  91275. * @param defines defines the string containing the defines to use to compile the shaders
  91276. * @param context defines the webGL context to use (if not set, the current one will be used)
  91277. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91278. * @returns the new webGL program
  91279. */
  91280. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91281. /**
  91282. * Creates a new pipeline context
  91283. * @returns the new pipeline
  91284. */
  91285. createPipelineContext(): WebGLPipelineContext;
  91286. private _createShaderProgram;
  91287. private _finalizePipelineContext;
  91288. /** @hidden */
  91289. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91290. /** @hidden */
  91291. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91292. /** @hidden */
  91293. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91294. /**
  91295. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91296. * @param pipelineContext defines the pipeline context to use
  91297. * @param uniformsNames defines the list of uniform names
  91298. * @returns an array of webGL uniform locations
  91299. */
  91300. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91301. /**
  91302. * Gets the lsit of active attributes for a given webGL program
  91303. * @param pipelineContext defines the pipeline context to use
  91304. * @param attributesNames defines the list of attribute names to get
  91305. * @returns an array of indices indicating the offset of each attribute
  91306. */
  91307. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91308. /**
  91309. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91310. * @param effect defines the effect to activate
  91311. */
  91312. enableEffect(effect: Nullable<Effect>): void;
  91313. /**
  91314. * Set the value of an uniform to an array of int32
  91315. * @param uniform defines the webGL uniform location where to store the value
  91316. * @param array defines the array of int32 to store
  91317. */
  91318. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91319. /**
  91320. * Set the value of an uniform to an array of int32 (stored as vec2)
  91321. * @param uniform defines the webGL uniform location where to store the value
  91322. * @param array defines the array of int32 to store
  91323. */
  91324. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91325. /**
  91326. * Set the value of an uniform to an array of int32 (stored as vec3)
  91327. * @param uniform defines the webGL uniform location where to store the value
  91328. * @param array defines the array of int32 to store
  91329. */
  91330. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91331. /**
  91332. * Set the value of an uniform to an array of int32 (stored as vec4)
  91333. * @param uniform defines the webGL uniform location where to store the value
  91334. * @param array defines the array of int32 to store
  91335. */
  91336. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91337. /**
  91338. * Set the value of an uniform to an array of float32
  91339. * @param uniform defines the webGL uniform location where to store the value
  91340. * @param array defines the array of float32 to store
  91341. */
  91342. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91343. /**
  91344. * Set the value of an uniform to an array of float32 (stored as vec2)
  91345. * @param uniform defines the webGL uniform location where to store the value
  91346. * @param array defines the array of float32 to store
  91347. */
  91348. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91349. /**
  91350. * Set the value of an uniform to an array of float32 (stored as vec3)
  91351. * @param uniform defines the webGL uniform location where to store the value
  91352. * @param array defines the array of float32 to store
  91353. */
  91354. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91355. /**
  91356. * Set the value of an uniform to an array of float32 (stored as vec4)
  91357. * @param uniform defines the webGL uniform location where to store the value
  91358. * @param array defines the array of float32 to store
  91359. */
  91360. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91361. /**
  91362. * Set the value of an uniform to an array of number
  91363. * @param uniform defines the webGL uniform location where to store the value
  91364. * @param array defines the array of number to store
  91365. */
  91366. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91367. /**
  91368. * Set the value of an uniform to an array of number (stored as vec2)
  91369. * @param uniform defines the webGL uniform location where to store the value
  91370. * @param array defines the array of number to store
  91371. */
  91372. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91373. /**
  91374. * Set the value of an uniform to an array of number (stored as vec3)
  91375. * @param uniform defines the webGL uniform location where to store the value
  91376. * @param array defines the array of number to store
  91377. */
  91378. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91379. /**
  91380. * Set the value of an uniform to an array of number (stored as vec4)
  91381. * @param uniform defines the webGL uniform location where to store the value
  91382. * @param array defines the array of number to store
  91383. */
  91384. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91385. /**
  91386. * Set the value of an uniform to an array of float32 (stored as matrices)
  91387. * @param uniform defines the webGL uniform location where to store the value
  91388. * @param matrices defines the array of float32 to store
  91389. */
  91390. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91391. /**
  91392. * Set the value of an uniform to a matrix
  91393. * @param uniform defines the webGL uniform location where to store the value
  91394. * @param matrix defines the matrix to store
  91395. */
  91396. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91397. /**
  91398. * Set the value of an uniform to a matrix (3x3)
  91399. * @param uniform defines the webGL uniform location where to store the value
  91400. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91401. */
  91402. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91403. /**
  91404. * Set the value of an uniform to a matrix (2x2)
  91405. * @param uniform defines the webGL uniform location where to store the value
  91406. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91407. */
  91408. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91409. /**
  91410. * Set the value of an uniform to a number (int)
  91411. * @param uniform defines the webGL uniform location where to store the value
  91412. * @param value defines the int number to store
  91413. */
  91414. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91415. /**
  91416. * Set the value of an uniform to a number (float)
  91417. * @param uniform defines the webGL uniform location where to store the value
  91418. * @param value defines the float number to store
  91419. */
  91420. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91421. /**
  91422. * Set the value of an uniform to a vec2
  91423. * @param uniform defines the webGL uniform location where to store the value
  91424. * @param x defines the 1st component of the value
  91425. * @param y defines the 2nd component of the value
  91426. */
  91427. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91428. /**
  91429. * Set the value of an uniform to a vec3
  91430. * @param uniform defines the webGL uniform location where to store the value
  91431. * @param x defines the 1st component of the value
  91432. * @param y defines the 2nd component of the value
  91433. * @param z defines the 3rd component of the value
  91434. */
  91435. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91436. /**
  91437. * Set the value of an uniform to a boolean
  91438. * @param uniform defines the webGL uniform location where to store the value
  91439. * @param bool defines the boolean to store
  91440. */
  91441. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91442. /**
  91443. * Set the value of an uniform to a vec4
  91444. * @param uniform defines the webGL uniform location where to store the value
  91445. * @param x defines the 1st component of the value
  91446. * @param y defines the 2nd component of the value
  91447. * @param z defines the 3rd component of the value
  91448. * @param w defines the 4th component of the value
  91449. */
  91450. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91451. /**
  91452. * Set the value of an uniform to a Color3
  91453. * @param uniform defines the webGL uniform location where to store the value
  91454. * @param color3 defines the color to store
  91455. */
  91456. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91457. /**
  91458. * Set the value of an uniform to a Color3 and an alpha value
  91459. * @param uniform defines the webGL uniform location where to store the value
  91460. * @param color3 defines the color to store
  91461. * @param alpha defines the alpha component to store
  91462. */
  91463. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91464. /**
  91465. * Sets a Color4 on a uniform variable
  91466. * @param uniform defines the uniform location
  91467. * @param color4 defines the value to be set
  91468. */
  91469. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91470. /**
  91471. * Set various states to the webGL context
  91472. * @param culling defines backface culling state
  91473. * @param zOffset defines the value to apply to zOffset (0 by default)
  91474. * @param force defines if states must be applied even if cache is up to date
  91475. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91476. */
  91477. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91478. /**
  91479. * Set the z offset to apply to current rendering
  91480. * @param value defines the offset to apply
  91481. */
  91482. setZOffset(value: number): void;
  91483. /**
  91484. * Gets the current value of the zOffset
  91485. * @returns the current zOffset state
  91486. */
  91487. getZOffset(): number;
  91488. /**
  91489. * Enable or disable depth buffering
  91490. * @param enable defines the state to set
  91491. */
  91492. setDepthBuffer(enable: boolean): void;
  91493. /**
  91494. * Gets a boolean indicating if depth writing is enabled
  91495. * @returns the current depth writing state
  91496. */
  91497. getDepthWrite(): boolean;
  91498. /**
  91499. * Enable or disable depth writing
  91500. * @param enable defines the state to set
  91501. */
  91502. setDepthWrite(enable: boolean): void;
  91503. /**
  91504. * Enable or disable color writing
  91505. * @param enable defines the state to set
  91506. */
  91507. setColorWrite(enable: boolean): void;
  91508. /**
  91509. * Gets a boolean indicating if color writing is enabled
  91510. * @returns the current color writing state
  91511. */
  91512. getColorWrite(): boolean;
  91513. /**
  91514. * Sets alpha constants used by some alpha blending modes
  91515. * @param r defines the red component
  91516. * @param g defines the green component
  91517. * @param b defines the blue component
  91518. * @param a defines the alpha component
  91519. */
  91520. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91521. /**
  91522. * Sets the current alpha mode
  91523. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91524. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91526. */
  91527. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91528. /**
  91529. * Gets the current alpha mode
  91530. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91531. * @returns the current alpha mode
  91532. */
  91533. getAlphaMode(): number;
  91534. /**
  91535. * Clears the list of texture accessible through engine.
  91536. * This can help preventing texture load conflict due to name collision.
  91537. */
  91538. clearInternalTexturesCache(): void;
  91539. /**
  91540. * Force the entire cache to be cleared
  91541. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91542. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91543. */
  91544. wipeCaches(bruteForce?: boolean): void;
  91545. /**
  91546. * Set the compressed texture format to use, based on the formats you have, and the formats
  91547. * supported by the hardware / browser.
  91548. *
  91549. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91550. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91551. * to API arguments needed to compressed textures. This puts the burden on the container
  91552. * generator to house the arcane code for determining these for current & future formats.
  91553. *
  91554. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91555. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91556. *
  91557. * Note: The result of this call is not taken into account when a texture is base64.
  91558. *
  91559. * @param formatsAvailable defines the list of those format families you have created
  91560. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91561. *
  91562. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91563. * @returns The extension selected.
  91564. */
  91565. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91566. /** @hidden */
  91567. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91568. min: number;
  91569. mag: number;
  91570. };
  91571. /** @hidden */
  91572. _createTexture(): WebGLTexture;
  91573. /**
  91574. * Usually called from Texture.ts.
  91575. * Passed information to create a WebGLTexture
  91576. * @param urlArg defines a value which contains one of the following:
  91577. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91578. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91579. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91580. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91581. * @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)
  91582. * @param scene needed for loading to the correct scene
  91583. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91584. * @param onLoad optional callback to be called upon successful completion
  91585. * @param onError optional callback to be called upon failure
  91586. * @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
  91587. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91588. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91589. * @param forcedExtension defines the extension to use to pick the right loader
  91590. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91591. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91592. */
  91593. 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;
  91594. /**
  91595. * @hidden
  91596. * Rescales a texture
  91597. * @param source input texutre
  91598. * @param destination destination texture
  91599. * @param scene scene to use to render the resize
  91600. * @param internalFormat format to use when resizing
  91601. * @param onComplete callback to be called when resize has completed
  91602. */
  91603. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91604. private _unpackFlipYCached;
  91605. /**
  91606. * In case you are sharing the context with other applications, it might
  91607. * be interested to not cache the unpack flip y state to ensure a consistent
  91608. * value would be set.
  91609. */
  91610. enableUnpackFlipYCached: boolean;
  91611. /** @hidden */
  91612. _unpackFlipY(value: boolean): void;
  91613. /** @hidden */
  91614. _getUnpackAlignement(): number;
  91615. /**
  91616. * Creates a dynamic texture
  91617. * @param width defines the width of the texture
  91618. * @param height defines the height of the texture
  91619. * @param generateMipMaps defines if the engine should generate the mip levels
  91620. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91621. * @returns the dynamic texture inside an InternalTexture
  91622. */
  91623. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91624. /**
  91625. * Update the sampling mode of a given texture
  91626. * @param samplingMode defines the required sampling mode
  91627. * @param texture defines the texture to update
  91628. */
  91629. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91630. /**
  91631. * Update the content of a dynamic texture
  91632. * @param texture defines the texture to update
  91633. * @param canvas defines the canvas containing the source
  91634. * @param invertY defines if data must be stored with Y axis inverted
  91635. * @param premulAlpha defines if alpha is stored as premultiplied
  91636. * @param format defines the format of the data
  91637. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91638. */
  91639. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91640. /**
  91641. * Update a video texture
  91642. * @param texture defines the texture to update
  91643. * @param video defines the video element to use
  91644. * @param invertY defines if data must be stored with Y axis inverted
  91645. */
  91646. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91647. /**
  91648. * Updates a depth texture Comparison Mode and Function.
  91649. * If the comparison Function is equal to 0, the mode will be set to none.
  91650. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91651. * @param texture The texture to set the comparison function for
  91652. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91653. */
  91654. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91655. /** @hidden */
  91656. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91657. width: number;
  91658. height: number;
  91659. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91660. /**
  91661. * Creates a depth stencil texture.
  91662. * This is only available in WebGL 2 or with the depth texture extension available.
  91663. * @param size The size of face edge in the texture.
  91664. * @param options The options defining the texture.
  91665. * @returns The texture
  91666. */
  91667. createDepthStencilTexture(size: number | {
  91668. width: number;
  91669. height: number;
  91670. }, options: DepthTextureCreationOptions): InternalTexture;
  91671. /**
  91672. * Creates a depth stencil texture.
  91673. * This is only available in WebGL 2 or with the depth texture extension available.
  91674. * @param size The size of face edge in the texture.
  91675. * @param options The options defining the texture.
  91676. * @returns The texture
  91677. */
  91678. private _createDepthStencilTexture;
  91679. /**
  91680. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91681. * @param renderTarget The render target to set the frame buffer for
  91682. */
  91683. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91684. /**
  91685. * Creates a new render target texture
  91686. * @param size defines the size of the texture
  91687. * @param options defines the options used to create the texture
  91688. * @returns a new render target texture stored in an InternalTexture
  91689. */
  91690. createRenderTargetTexture(size: number | {
  91691. width: number;
  91692. height: number;
  91693. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91694. /** @hidden */
  91695. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91696. /**
  91697. * Updates the sample count of a render target texture
  91698. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91699. * @param texture defines the texture to update
  91700. * @param samples defines the sample count to set
  91701. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91702. */
  91703. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91704. /** @hidden */
  91705. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91706. /** @hidden */
  91707. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91708. /** @hidden */
  91709. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91710. /** @hidden */
  91711. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91712. /**
  91713. * @hidden
  91714. */
  91715. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91716. private _prepareWebGLTextureContinuation;
  91717. private _prepareWebGLTexture;
  91718. /** @hidden */
  91719. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91720. /** @hidden */
  91721. _releaseFramebufferObjects(texture: InternalTexture): void;
  91722. /** @hidden */
  91723. _releaseTexture(texture: InternalTexture): void;
  91724. private setProgram;
  91725. private _boundUniforms;
  91726. /**
  91727. * Binds an effect to the webGL context
  91728. * @param effect defines the effect to bind
  91729. */
  91730. bindSamplers(effect: Effect): void;
  91731. private _activateCurrentTexture;
  91732. /** @hidden */
  91733. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91734. /** @hidden */
  91735. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91736. /**
  91737. * Sets a texture to the webGL context from a postprocess
  91738. * @param channel defines the channel to use
  91739. * @param postProcess defines the source postprocess
  91740. */
  91741. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91742. /**
  91743. * Binds the output of the passed in post process to the texture channel specified
  91744. * @param channel The channel the texture should be bound to
  91745. * @param postProcess The post process which's output should be bound
  91746. */
  91747. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91748. /**
  91749. * Unbind all textures from the webGL context
  91750. */
  91751. unbindAllTextures(): void;
  91752. /**
  91753. * Sets a texture to the according uniform.
  91754. * @param channel The texture channel
  91755. * @param uniform The uniform to set
  91756. * @param texture The texture to apply
  91757. */
  91758. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91759. /**
  91760. * Sets a depth stencil texture from a render target to the according uniform.
  91761. * @param channel The texture channel
  91762. * @param uniform The uniform to set
  91763. * @param texture The render target texture containing the depth stencil texture to apply
  91764. */
  91765. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91766. private _bindSamplerUniformToChannel;
  91767. private _getTextureWrapMode;
  91768. private _setTexture;
  91769. /**
  91770. * Sets an array of texture to the webGL context
  91771. * @param channel defines the channel where the texture array must be set
  91772. * @param uniform defines the associated uniform location
  91773. * @param textures defines the array of textures to bind
  91774. */
  91775. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91776. /** @hidden */
  91777. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91778. private _setTextureParameterFloat;
  91779. private _setTextureParameterInteger;
  91780. /**
  91781. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91782. * @param x defines the x coordinate of the rectangle where pixels must be read
  91783. * @param y defines the y coordinate of the rectangle where pixels must be read
  91784. * @param width defines the width of the rectangle where pixels must be read
  91785. * @param height defines the height of the rectangle where pixels must be read
  91786. * @returns a Uint8Array containing RGBA colors
  91787. */
  91788. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91789. /**
  91790. * Add an externaly attached data from its key.
  91791. * This method call will fail and return false, if such key already exists.
  91792. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91793. * @param key the unique key that identifies the data
  91794. * @param data the data object to associate to the key for this Engine instance
  91795. * @return true if no such key were already present and the data was added successfully, false otherwise
  91796. */
  91797. addExternalData<T>(key: string, data: T): boolean;
  91798. /**
  91799. * Get an externaly attached data from its key
  91800. * @param key the unique key that identifies the data
  91801. * @return the associated data, if present (can be null), or undefined if not present
  91802. */
  91803. getExternalData<T>(key: string): T;
  91804. /**
  91805. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91806. * @param key the unique key that identifies the data
  91807. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91808. * @return the associated data, can be null if the factory returned null.
  91809. */
  91810. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91811. /**
  91812. * Remove an externaly attached data from the Engine instance
  91813. * @param key the unique key that identifies the data
  91814. * @return true if the data was successfully removed, false if it doesn't exist
  91815. */
  91816. removeExternalData(key: string): boolean;
  91817. /**
  91818. * Unbind all vertex attributes from the webGL context
  91819. */
  91820. unbindAllAttributes(): void;
  91821. /**
  91822. * 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
  91823. */
  91824. releaseEffects(): void;
  91825. /**
  91826. * Dispose and release all associated resources
  91827. */
  91828. dispose(): void;
  91829. /**
  91830. * Display the loading screen
  91831. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91832. */
  91833. displayLoadingUI(): void;
  91834. /**
  91835. * Hide the loading screen
  91836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91837. */
  91838. hideLoadingUI(): void;
  91839. /**
  91840. * Gets the current loading screen object
  91841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91842. */
  91843. /**
  91844. * Sets the current loading screen object
  91845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91846. */
  91847. loadingScreen: ILoadingScreen;
  91848. /**
  91849. * Sets the current loading screen text
  91850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91851. */
  91852. loadingUIText: string;
  91853. /**
  91854. * Sets the current loading screen background color
  91855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91856. */
  91857. loadingUIBackgroundColor: string;
  91858. /**
  91859. * Attach a new callback raised when context lost event is fired
  91860. * @param callback defines the callback to call
  91861. */
  91862. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91863. /**
  91864. * Attach a new callback raised when context restored event is fired
  91865. * @param callback defines the callback to call
  91866. */
  91867. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91868. /**
  91869. * Gets the source code of the vertex shader associated with a specific webGL program
  91870. * @param program defines the program to use
  91871. * @returns a string containing the source code of the vertex shader associated with the program
  91872. */
  91873. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91874. /**
  91875. * Gets the source code of the fragment shader associated with a specific webGL program
  91876. * @param program defines the program to use
  91877. * @returns a string containing the source code of the fragment shader associated with the program
  91878. */
  91879. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91880. /**
  91881. * Get the current error code of the webGL context
  91882. * @returns the error code
  91883. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91884. */
  91885. getError(): number;
  91886. /**
  91887. * Gets the current framerate
  91888. * @returns a number representing the framerate
  91889. */
  91890. getFps(): number;
  91891. /**
  91892. * Gets the time spent between current and previous frame
  91893. * @returns a number representing the delta time in ms
  91894. */
  91895. getDeltaTime(): number;
  91896. private _measureFps;
  91897. /** @hidden */
  91898. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91899. private _canRenderToFloatFramebuffer;
  91900. private _canRenderToHalfFloatFramebuffer;
  91901. private _canRenderToFramebuffer;
  91902. /** @hidden */
  91903. _getWebGLTextureType(type: number): number;
  91904. /** @hidden */
  91905. _getInternalFormat(format: number): number;
  91906. /** @hidden */
  91907. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91908. /** @hidden */
  91909. _getRGBAMultiSampleBufferFormat(type: number): number;
  91910. /** @hidden */
  91911. _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;
  91912. /** @hidden */
  91913. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91914. /**
  91915. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91916. * @returns true if the engine can be created
  91917. * @ignorenaming
  91918. */
  91919. static isSupported(): boolean;
  91920. }
  91921. }
  91922. declare module BABYLON {
  91923. /**
  91924. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91925. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91926. */
  91927. export class EffectFallbacks {
  91928. private _defines;
  91929. private _currentRank;
  91930. private _maxRank;
  91931. private _mesh;
  91932. /**
  91933. * Removes the fallback from the bound mesh.
  91934. */
  91935. unBindMesh(): void;
  91936. /**
  91937. * Adds a fallback on the specified property.
  91938. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91939. * @param define The name of the define in the shader
  91940. */
  91941. addFallback(rank: number, define: string): void;
  91942. /**
  91943. * Sets the mesh to use CPU skinning when needing to fallback.
  91944. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91945. * @param mesh The mesh to use the fallbacks.
  91946. */
  91947. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91948. /**
  91949. * Checks to see if more fallbacks are still availible.
  91950. */
  91951. readonly isMoreFallbacks: boolean;
  91952. /**
  91953. * Removes the defines that should be removed when falling back.
  91954. * @param currentDefines defines the current define statements for the shader.
  91955. * @param effect defines the current effect we try to compile
  91956. * @returns The resulting defines with defines of the current rank removed.
  91957. */
  91958. reduce(currentDefines: string, effect: Effect): string;
  91959. }
  91960. /**
  91961. * Options to be used when creating an effect.
  91962. */
  91963. export class EffectCreationOptions {
  91964. /**
  91965. * Atrributes that will be used in the shader.
  91966. */
  91967. attributes: string[];
  91968. /**
  91969. * Uniform varible names that will be set in the shader.
  91970. */
  91971. uniformsNames: string[];
  91972. /**
  91973. * Uniform buffer varible names that will be set in the shader.
  91974. */
  91975. uniformBuffersNames: string[];
  91976. /**
  91977. * Sampler texture variable names that will be set in the shader.
  91978. */
  91979. samplers: string[];
  91980. /**
  91981. * Define statements that will be set in the shader.
  91982. */
  91983. defines: any;
  91984. /**
  91985. * Possible fallbacks for this effect to improve performance when needed.
  91986. */
  91987. fallbacks: Nullable<EffectFallbacks>;
  91988. /**
  91989. * Callback that will be called when the shader is compiled.
  91990. */
  91991. onCompiled: Nullable<(effect: Effect) => void>;
  91992. /**
  91993. * Callback that will be called if an error occurs during shader compilation.
  91994. */
  91995. onError: Nullable<(effect: Effect, errors: string) => void>;
  91996. /**
  91997. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91998. */
  91999. indexParameters: any;
  92000. /**
  92001. * Max number of lights that can be used in the shader.
  92002. */
  92003. maxSimultaneousLights: number;
  92004. /**
  92005. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92006. */
  92007. transformFeedbackVaryings: Nullable<string[]>;
  92008. }
  92009. /**
  92010. * Effect containing vertex and fragment shader that can be executed on an object.
  92011. */
  92012. export class Effect implements IDisposable {
  92013. /**
  92014. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92015. */
  92016. static ShadersRepository: string;
  92017. /**
  92018. * Name of the effect.
  92019. */
  92020. name: any;
  92021. /**
  92022. * String container all the define statements that should be set on the shader.
  92023. */
  92024. defines: string;
  92025. /**
  92026. * Callback that will be called when the shader is compiled.
  92027. */
  92028. onCompiled: Nullable<(effect: Effect) => void>;
  92029. /**
  92030. * Callback that will be called if an error occurs during shader compilation.
  92031. */
  92032. onError: Nullable<(effect: Effect, errors: string) => void>;
  92033. /**
  92034. * Callback that will be called when effect is bound.
  92035. */
  92036. onBind: Nullable<(effect: Effect) => void>;
  92037. /**
  92038. * Unique ID of the effect.
  92039. */
  92040. uniqueId: number;
  92041. /**
  92042. * Observable that will be called when the shader is compiled.
  92043. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92044. */
  92045. onCompileObservable: Observable<Effect>;
  92046. /**
  92047. * Observable that will be called if an error occurs during shader compilation.
  92048. */
  92049. onErrorObservable: Observable<Effect>;
  92050. /** @hidden */
  92051. _onBindObservable: Nullable<Observable<Effect>>;
  92052. /**
  92053. * Observable that will be called when effect is bound.
  92054. */
  92055. readonly onBindObservable: Observable<Effect>;
  92056. /** @hidden */
  92057. _bonesComputationForcedToCPU: boolean;
  92058. private static _uniqueIdSeed;
  92059. private _engine;
  92060. private _uniformBuffersNames;
  92061. private _uniformsNames;
  92062. private _samplerList;
  92063. private _samplers;
  92064. private _isReady;
  92065. private _compilationError;
  92066. private _attributesNames;
  92067. private _attributes;
  92068. private _uniforms;
  92069. /**
  92070. * Key for the effect.
  92071. * @hidden
  92072. */
  92073. _key: string;
  92074. private _indexParameters;
  92075. private _fallbacks;
  92076. private _vertexSourceCode;
  92077. private _fragmentSourceCode;
  92078. private _vertexSourceCodeOverride;
  92079. private _fragmentSourceCodeOverride;
  92080. private _transformFeedbackVaryings;
  92081. /**
  92082. * Compiled shader to webGL program.
  92083. * @hidden
  92084. */
  92085. _pipelineContext: Nullable<IPipelineContext>;
  92086. private _valueCache;
  92087. private static _baseCache;
  92088. /**
  92089. * Instantiates an effect.
  92090. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92091. * @param baseName Name of the effect.
  92092. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92093. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92094. * @param samplers List of sampler variables that will be passed to the shader.
  92095. * @param engine Engine to be used to render the effect
  92096. * @param defines Define statements to be added to the shader.
  92097. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92098. * @param onCompiled Callback that will be called when the shader is compiled.
  92099. * @param onError Callback that will be called if an error occurs during shader compilation.
  92100. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92101. */
  92102. 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);
  92103. private _useFinalCode;
  92104. /**
  92105. * Unique key for this effect
  92106. */
  92107. readonly key: string;
  92108. /**
  92109. * If the effect has been compiled and prepared.
  92110. * @returns if the effect is compiled and prepared.
  92111. */
  92112. isReady(): boolean;
  92113. /**
  92114. * The engine the effect was initialized with.
  92115. * @returns the engine.
  92116. */
  92117. getEngine(): Engine;
  92118. /**
  92119. * The pipeline context for this effect
  92120. * @returns the associated pipeline context
  92121. */
  92122. getPipelineContext(): Nullable<IPipelineContext>;
  92123. /**
  92124. * The set of names of attribute variables for the shader.
  92125. * @returns An array of attribute names.
  92126. */
  92127. getAttributesNames(): string[];
  92128. /**
  92129. * Returns the attribute at the given index.
  92130. * @param index The index of the attribute.
  92131. * @returns The location of the attribute.
  92132. */
  92133. getAttributeLocation(index: number): number;
  92134. /**
  92135. * Returns the attribute based on the name of the variable.
  92136. * @param name of the attribute to look up.
  92137. * @returns the attribute location.
  92138. */
  92139. getAttributeLocationByName(name: string): number;
  92140. /**
  92141. * The number of attributes.
  92142. * @returns the numnber of attributes.
  92143. */
  92144. getAttributesCount(): number;
  92145. /**
  92146. * Gets the index of a uniform variable.
  92147. * @param uniformName of the uniform to look up.
  92148. * @returns the index.
  92149. */
  92150. getUniformIndex(uniformName: string): number;
  92151. /**
  92152. * Returns the attribute based on the name of the variable.
  92153. * @param uniformName of the uniform to look up.
  92154. * @returns the location of the uniform.
  92155. */
  92156. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92157. /**
  92158. * Returns an array of sampler variable names
  92159. * @returns The array of sampler variable neames.
  92160. */
  92161. getSamplers(): string[];
  92162. /**
  92163. * The error from the last compilation.
  92164. * @returns the error string.
  92165. */
  92166. getCompilationError(): string;
  92167. /**
  92168. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92169. * @param func The callback to be used.
  92170. */
  92171. executeWhenCompiled(func: (effect: Effect) => void): void;
  92172. private _checkIsReady;
  92173. /** @hidden */
  92174. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92175. /** @hidden */
  92176. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92177. /** @hidden */
  92178. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92179. /**
  92180. * Recompiles the webGL program
  92181. * @param vertexSourceCode The source code for the vertex shader.
  92182. * @param fragmentSourceCode The source code for the fragment shader.
  92183. * @param onCompiled Callback called when completed.
  92184. * @param onError Callback called on error.
  92185. * @hidden
  92186. */
  92187. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92188. /**
  92189. * Prepares the effect
  92190. * @hidden
  92191. */
  92192. _prepareEffect(): void;
  92193. /**
  92194. * Checks if the effect is supported. (Must be called after compilation)
  92195. */
  92196. readonly isSupported: boolean;
  92197. /**
  92198. * Binds a texture to the engine to be used as output of the shader.
  92199. * @param channel Name of the output variable.
  92200. * @param texture Texture to bind.
  92201. * @hidden
  92202. */
  92203. _bindTexture(channel: string, texture: InternalTexture): void;
  92204. /**
  92205. * Sets a texture on the engine to be used in the shader.
  92206. * @param channel Name of the sampler variable.
  92207. * @param texture Texture to set.
  92208. */
  92209. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92210. /**
  92211. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92212. * @param channel Name of the sampler variable.
  92213. * @param texture Texture to set.
  92214. */
  92215. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92216. /**
  92217. * Sets an array of textures on the engine to be used in the shader.
  92218. * @param channel Name of the variable.
  92219. * @param textures Textures to set.
  92220. */
  92221. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92222. /**
  92223. * 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)
  92224. * @param channel Name of the sampler variable.
  92225. * @param postProcess Post process to get the input texture from.
  92226. */
  92227. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92228. /**
  92229. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92230. * 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)
  92231. * @param channel Name of the sampler variable.
  92232. * @param postProcess Post process to get the output texture from.
  92233. */
  92234. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92235. /** @hidden */
  92236. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92237. /** @hidden */
  92238. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92239. /** @hidden */
  92240. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92241. /** @hidden */
  92242. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92243. /**
  92244. * Binds a buffer to a uniform.
  92245. * @param buffer Buffer to bind.
  92246. * @param name Name of the uniform variable to bind to.
  92247. */
  92248. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92249. /**
  92250. * Binds block to a uniform.
  92251. * @param blockName Name of the block to bind.
  92252. * @param index Index to bind.
  92253. */
  92254. bindUniformBlock(blockName: string, index: number): void;
  92255. /**
  92256. * Sets an interger value on a uniform variable.
  92257. * @param uniformName Name of the variable.
  92258. * @param value Value to be set.
  92259. * @returns this effect.
  92260. */
  92261. setInt(uniformName: string, value: number): Effect;
  92262. /**
  92263. * Sets an int array on a uniform variable.
  92264. * @param uniformName Name of the variable.
  92265. * @param array array to be set.
  92266. * @returns this effect.
  92267. */
  92268. setIntArray(uniformName: string, array: Int32Array): Effect;
  92269. /**
  92270. * 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)
  92271. * @param uniformName Name of the variable.
  92272. * @param array array to be set.
  92273. * @returns this effect.
  92274. */
  92275. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92276. /**
  92277. * 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)
  92278. * @param uniformName Name of the variable.
  92279. * @param array array to be set.
  92280. * @returns this effect.
  92281. */
  92282. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92283. /**
  92284. * 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)
  92285. * @param uniformName Name of the variable.
  92286. * @param array array to be set.
  92287. * @returns this effect.
  92288. */
  92289. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92290. /**
  92291. * Sets an float array on a uniform variable.
  92292. * @param uniformName Name of the variable.
  92293. * @param array array to be set.
  92294. * @returns this effect.
  92295. */
  92296. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92297. /**
  92298. * 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)
  92299. * @param uniformName Name of the variable.
  92300. * @param array array to be set.
  92301. * @returns this effect.
  92302. */
  92303. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92304. /**
  92305. * 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)
  92306. * @param uniformName Name of the variable.
  92307. * @param array array to be set.
  92308. * @returns this effect.
  92309. */
  92310. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92311. /**
  92312. * 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)
  92313. * @param uniformName Name of the variable.
  92314. * @param array array to be set.
  92315. * @returns this effect.
  92316. */
  92317. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92318. /**
  92319. * Sets an array on a uniform variable.
  92320. * @param uniformName Name of the variable.
  92321. * @param array array to be set.
  92322. * @returns this effect.
  92323. */
  92324. setArray(uniformName: string, array: number[]): Effect;
  92325. /**
  92326. * 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)
  92327. * @param uniformName Name of the variable.
  92328. * @param array array to be set.
  92329. * @returns this effect.
  92330. */
  92331. setArray2(uniformName: string, array: number[]): Effect;
  92332. /**
  92333. * 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)
  92334. * @param uniformName Name of the variable.
  92335. * @param array array to be set.
  92336. * @returns this effect.
  92337. */
  92338. setArray3(uniformName: string, array: number[]): Effect;
  92339. /**
  92340. * 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)
  92341. * @param uniformName Name of the variable.
  92342. * @param array array to be set.
  92343. * @returns this effect.
  92344. */
  92345. setArray4(uniformName: string, array: number[]): Effect;
  92346. /**
  92347. * Sets matrices on a uniform variable.
  92348. * @param uniformName Name of the variable.
  92349. * @param matrices matrices to be set.
  92350. * @returns this effect.
  92351. */
  92352. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92353. /**
  92354. * Sets matrix on a uniform variable.
  92355. * @param uniformName Name of the variable.
  92356. * @param matrix matrix to be set.
  92357. * @returns this effect.
  92358. */
  92359. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92360. /**
  92361. * 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)
  92362. * @param uniformName Name of the variable.
  92363. * @param matrix matrix to be set.
  92364. * @returns this effect.
  92365. */
  92366. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92367. /**
  92368. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92369. * @param uniformName Name of the variable.
  92370. * @param matrix matrix to be set.
  92371. * @returns this effect.
  92372. */
  92373. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92374. /**
  92375. * Sets a float on a uniform variable.
  92376. * @param uniformName Name of the variable.
  92377. * @param value value to be set.
  92378. * @returns this effect.
  92379. */
  92380. setFloat(uniformName: string, value: number): Effect;
  92381. /**
  92382. * Sets a boolean on a uniform variable.
  92383. * @param uniformName Name of the variable.
  92384. * @param bool value to be set.
  92385. * @returns this effect.
  92386. */
  92387. setBool(uniformName: string, bool: boolean): Effect;
  92388. /**
  92389. * Sets a Vector2 on a uniform variable.
  92390. * @param uniformName Name of the variable.
  92391. * @param vector2 vector2 to be set.
  92392. * @returns this effect.
  92393. */
  92394. setVector2(uniformName: string, vector2: Vector2): Effect;
  92395. /**
  92396. * Sets a float2 on a uniform variable.
  92397. * @param uniformName Name of the variable.
  92398. * @param x First float in float2.
  92399. * @param y Second float in float2.
  92400. * @returns this effect.
  92401. */
  92402. setFloat2(uniformName: string, x: number, y: number): Effect;
  92403. /**
  92404. * Sets a Vector3 on a uniform variable.
  92405. * @param uniformName Name of the variable.
  92406. * @param vector3 Value to be set.
  92407. * @returns this effect.
  92408. */
  92409. setVector3(uniformName: string, vector3: Vector3): Effect;
  92410. /**
  92411. * Sets a float3 on a uniform variable.
  92412. * @param uniformName Name of the variable.
  92413. * @param x First float in float3.
  92414. * @param y Second float in float3.
  92415. * @param z Third float in float3.
  92416. * @returns this effect.
  92417. */
  92418. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92419. /**
  92420. * Sets a Vector4 on a uniform variable.
  92421. * @param uniformName Name of the variable.
  92422. * @param vector4 Value to be set.
  92423. * @returns this effect.
  92424. */
  92425. setVector4(uniformName: string, vector4: Vector4): Effect;
  92426. /**
  92427. * Sets a float4 on a uniform variable.
  92428. * @param uniformName Name of the variable.
  92429. * @param x First float in float4.
  92430. * @param y Second float in float4.
  92431. * @param z Third float in float4.
  92432. * @param w Fourth float in float4.
  92433. * @returns this effect.
  92434. */
  92435. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92436. /**
  92437. * Sets a Color3 on a uniform variable.
  92438. * @param uniformName Name of the variable.
  92439. * @param color3 Value to be set.
  92440. * @returns this effect.
  92441. */
  92442. setColor3(uniformName: string, color3: Color3): Effect;
  92443. /**
  92444. * Sets a Color4 on a uniform variable.
  92445. * @param uniformName Name of the variable.
  92446. * @param color3 Value to be set.
  92447. * @param alpha Alpha value to be set.
  92448. * @returns this effect.
  92449. */
  92450. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92451. /**
  92452. * Sets a Color4 on a uniform variable
  92453. * @param uniformName defines the name of the variable
  92454. * @param color4 defines the value to be set
  92455. * @returns this effect.
  92456. */
  92457. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92458. /** Release all associated resources */
  92459. dispose(): void;
  92460. /**
  92461. * This function will add a new shader to the shader store
  92462. * @param name the name of the shader
  92463. * @param pixelShader optional pixel shader content
  92464. * @param vertexShader optional vertex shader content
  92465. */
  92466. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92467. /**
  92468. * Store of each shader (The can be looked up using effect.key)
  92469. */
  92470. static ShadersStore: {
  92471. [key: string]: string;
  92472. };
  92473. /**
  92474. * Store of each included file for a shader (The can be looked up using effect.key)
  92475. */
  92476. static IncludesShadersStore: {
  92477. [key: string]: string;
  92478. };
  92479. /**
  92480. * Resets the cache of effects.
  92481. */
  92482. static ResetCache(): void;
  92483. }
  92484. }
  92485. declare module BABYLON {
  92486. /**
  92487. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92488. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92489. * 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;
  92490. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92491. */
  92492. export class ColorCurves {
  92493. private _dirty;
  92494. private _tempColor;
  92495. private _globalCurve;
  92496. private _highlightsCurve;
  92497. private _midtonesCurve;
  92498. private _shadowsCurve;
  92499. private _positiveCurve;
  92500. private _negativeCurve;
  92501. private _globalHue;
  92502. private _globalDensity;
  92503. private _globalSaturation;
  92504. private _globalExposure;
  92505. /**
  92506. * Gets the global Hue value.
  92507. * 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).
  92508. */
  92509. /**
  92510. * Sets the global Hue value.
  92511. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  92512. */
  92513. globalHue: number;
  92514. /**
  92515. * Gets the global Density value.
  92516. * 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.
  92517. * Values less than zero provide a filter of opposite hue.
  92518. */
  92519. /**
  92520. * Sets the global Density value.
  92521. * 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.
  92522. * Values less than zero provide a filter of opposite hue.
  92523. */
  92524. globalDensity: number;
  92525. /**
  92526. * Gets the global Saturation value.
  92527. * 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.
  92528. */
  92529. /**
  92530. * Sets the global Saturation value.
  92531. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  92532. */
  92533. globalSaturation: number;
  92534. /**
  92535. * Gets the global Exposure value.
  92536. * 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.
  92537. */
  92538. /**
  92539. * Sets the global Exposure value.
  92540. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  92541. */
  92542. globalExposure: number;
  92543. private _highlightsHue;
  92544. private _highlightsDensity;
  92545. private _highlightsSaturation;
  92546. private _highlightsExposure;
  92547. /**
  92548. * Gets the highlights 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. /**
  92552. * Sets the highlights Hue value.
  92553. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  92554. */
  92555. highlightsHue: number;
  92556. /**
  92557. * Gets the highlights Density value.
  92558. * 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.
  92559. * Values less than zero provide a filter of opposite hue.
  92560. */
  92561. /**
  92562. * Sets the highlights Density value.
  92563. * 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.
  92564. * Values less than zero provide a filter of opposite hue.
  92565. */
  92566. highlightsDensity: number;
  92567. /**
  92568. * Gets the highlights 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. /**
  92572. * Sets the highlights Saturation value.
  92573. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  92574. */
  92575. highlightsSaturation: number;
  92576. /**
  92577. * Gets the highlights 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. /**
  92581. * Sets the highlights Exposure value.
  92582. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  92583. */
  92584. highlightsExposure: number;
  92585. private _midtonesHue;
  92586. private _midtonesDensity;
  92587. private _midtonesSaturation;
  92588. private _midtonesExposure;
  92589. /**
  92590. * Gets the midtones 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. /**
  92594. * Sets the midtones Hue value.
  92595. * 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).
  92596. */
  92597. midtonesHue: number;
  92598. /**
  92599. * Gets the midtones Density value.
  92600. * 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.
  92601. * Values less than zero provide a filter of opposite hue.
  92602. */
  92603. /**
  92604. * Sets the midtones Density value.
  92605. * 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.
  92606. * Values less than zero provide a filter of opposite hue.
  92607. */
  92608. midtonesDensity: number;
  92609. /**
  92610. * Gets the midtones 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. /**
  92614. * Sets the midtones Saturation value.
  92615. * 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.
  92616. */
  92617. midtonesSaturation: number;
  92618. /**
  92619. * Gets the midtones 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. /**
  92623. * Sets the midtones Exposure value.
  92624. * 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.
  92625. */
  92626. midtonesExposure: number;
  92627. private _shadowsHue;
  92628. private _shadowsDensity;
  92629. private _shadowsSaturation;
  92630. private _shadowsExposure;
  92631. /**
  92632. * Gets the shadows 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. /**
  92636. * Sets the shadows Hue value.
  92637. * 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).
  92638. */
  92639. shadowsHue: number;
  92640. /**
  92641. * Gets the shadows Density value.
  92642. * 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.
  92643. * Values less than zero provide a filter of opposite hue.
  92644. */
  92645. /**
  92646. * Sets the shadows Density value.
  92647. * 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.
  92648. * Values less than zero provide a filter of opposite hue.
  92649. */
  92650. shadowsDensity: number;
  92651. /**
  92652. * Gets the shadows 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. /**
  92656. * Sets the shadows Saturation value.
  92657. * 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.
  92658. */
  92659. shadowsSaturation: number;
  92660. /**
  92661. * Gets the shadows 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. /**
  92665. * Sets the shadows Exposure value.
  92666. * 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.
  92667. */
  92668. shadowsExposure: number;
  92669. /**
  92670. * Returns the class name
  92671. * @returns The class name
  92672. */
  92673. getClassName(): string;
  92674. /**
  92675. * Binds the color curves to the shader.
  92676. * @param colorCurves The color curve to bind
  92677. * @param effect The effect to bind to
  92678. * @param positiveUniform The positive uniform shader parameter
  92679. * @param neutralUniform The neutral uniform shader parameter
  92680. * @param negativeUniform The negative uniform shader parameter
  92681. */
  92682. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92683. /**
  92684. * Prepare the list of uniforms associated with the ColorCurves effects.
  92685. * @param uniformsList The list of uniforms used in the effect
  92686. */
  92687. static PrepareUniforms(uniformsList: string[]): void;
  92688. /**
  92689. * Returns color grading data based on a hue, density, saturation and exposure value.
  92690. * @param filterHue The hue of the color filter.
  92691. * @param filterDensity The density of the color filter.
  92692. * @param saturation The saturation.
  92693. * @param exposure The exposure.
  92694. * @param result The result data container.
  92695. */
  92696. private getColorGradingDataToRef;
  92697. /**
  92698. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92699. * @param value The input slider value in range [-100,100].
  92700. * @returns Adjusted value.
  92701. */
  92702. private static applyColorGradingSliderNonlinear;
  92703. /**
  92704. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92705. * @param hue The hue (H) input.
  92706. * @param saturation The saturation (S) input.
  92707. * @param brightness The brightness (B) input.
  92708. * @result An RGBA color represented as Vector4.
  92709. */
  92710. private static fromHSBToRef;
  92711. /**
  92712. * Returns a value clamped between min and max
  92713. * @param value The value to clamp
  92714. * @param min The minimum of value
  92715. * @param max The maximum of value
  92716. * @returns The clamped value.
  92717. */
  92718. private static clamp;
  92719. /**
  92720. * Clones the current color curve instance.
  92721. * @return The cloned curves
  92722. */
  92723. clone(): ColorCurves;
  92724. /**
  92725. * Serializes the current color curve instance to a json representation.
  92726. * @return a JSON representation
  92727. */
  92728. serialize(): any;
  92729. /**
  92730. * Parses the color curve from a json representation.
  92731. * @param source the JSON source to parse
  92732. * @return The parsed curves
  92733. */
  92734. static Parse(source: any): ColorCurves;
  92735. }
  92736. }
  92737. declare module BABYLON {
  92738. /**
  92739. * Interface to follow in your material defines to integrate easily the
  92740. * Image proccessing functions.
  92741. * @hidden
  92742. */
  92743. export interface IImageProcessingConfigurationDefines {
  92744. IMAGEPROCESSING: boolean;
  92745. VIGNETTE: boolean;
  92746. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92747. VIGNETTEBLENDMODEOPAQUE: boolean;
  92748. TONEMAPPING: boolean;
  92749. TONEMAPPING_ACES: boolean;
  92750. CONTRAST: boolean;
  92751. EXPOSURE: boolean;
  92752. COLORCURVES: boolean;
  92753. COLORGRADING: boolean;
  92754. COLORGRADING3D: boolean;
  92755. SAMPLER3DGREENDEPTH: boolean;
  92756. SAMPLER3DBGRMAP: boolean;
  92757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92758. }
  92759. /**
  92760. * @hidden
  92761. */
  92762. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92763. IMAGEPROCESSING: boolean;
  92764. VIGNETTE: boolean;
  92765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92766. VIGNETTEBLENDMODEOPAQUE: boolean;
  92767. TONEMAPPING: boolean;
  92768. TONEMAPPING_ACES: boolean;
  92769. CONTRAST: boolean;
  92770. COLORCURVES: boolean;
  92771. COLORGRADING: boolean;
  92772. COLORGRADING3D: boolean;
  92773. SAMPLER3DGREENDEPTH: boolean;
  92774. SAMPLER3DBGRMAP: boolean;
  92775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92776. EXPOSURE: boolean;
  92777. constructor();
  92778. }
  92779. /**
  92780. * This groups together the common properties used for image processing either in direct forward pass
  92781. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92782. * or not.
  92783. */
  92784. export class ImageProcessingConfiguration {
  92785. /**
  92786. * Default tone mapping applied in BabylonJS.
  92787. */
  92788. static readonly TONEMAPPING_STANDARD: number;
  92789. /**
  92790. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92791. * to other engines rendering to increase portability.
  92792. */
  92793. static readonly TONEMAPPING_ACES: number;
  92794. /**
  92795. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92796. */
  92797. colorCurves: Nullable<ColorCurves>;
  92798. private _colorCurvesEnabled;
  92799. /**
  92800. * Gets wether the color curves effect is enabled.
  92801. */
  92802. /**
  92803. * Sets wether the color curves effect is enabled.
  92804. */
  92805. colorCurvesEnabled: boolean;
  92806. private _colorGradingTexture;
  92807. /**
  92808. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92809. */
  92810. /**
  92811. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92812. */
  92813. colorGradingTexture: Nullable<BaseTexture>;
  92814. private _colorGradingEnabled;
  92815. /**
  92816. * Gets wether the color grading effect is enabled.
  92817. */
  92818. /**
  92819. * Sets wether the color grading effect is enabled.
  92820. */
  92821. colorGradingEnabled: boolean;
  92822. private _colorGradingWithGreenDepth;
  92823. /**
  92824. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92825. */
  92826. /**
  92827. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92828. */
  92829. colorGradingWithGreenDepth: boolean;
  92830. private _colorGradingBGR;
  92831. /**
  92832. * Gets wether the color grading texture contains BGR values.
  92833. */
  92834. /**
  92835. * Sets wether the color grading texture contains BGR values.
  92836. */
  92837. colorGradingBGR: boolean;
  92838. /** @hidden */
  92839. _exposure: number;
  92840. /**
  92841. * Gets the Exposure used in the effect.
  92842. */
  92843. /**
  92844. * Sets the Exposure used in the effect.
  92845. */
  92846. exposure: number;
  92847. private _toneMappingEnabled;
  92848. /**
  92849. * Gets wether the tone mapping effect is enabled.
  92850. */
  92851. /**
  92852. * Sets wether the tone mapping effect is enabled.
  92853. */
  92854. toneMappingEnabled: boolean;
  92855. private _toneMappingType;
  92856. /**
  92857. * Gets the type of tone mapping effect.
  92858. */
  92859. /**
  92860. * Sets the type of tone mapping effect used in BabylonJS.
  92861. */
  92862. toneMappingType: number;
  92863. protected _contrast: number;
  92864. /**
  92865. * Gets the contrast used in the effect.
  92866. */
  92867. /**
  92868. * Sets the contrast used in the effect.
  92869. */
  92870. contrast: number;
  92871. /**
  92872. * Vignette stretch size.
  92873. */
  92874. vignetteStretch: number;
  92875. /**
  92876. * Vignette centre X Offset.
  92877. */
  92878. vignetteCentreX: number;
  92879. /**
  92880. * Vignette centre Y Offset.
  92881. */
  92882. vignetteCentreY: number;
  92883. /**
  92884. * Vignette weight or intensity of the vignette effect.
  92885. */
  92886. vignetteWeight: number;
  92887. /**
  92888. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92889. * if vignetteEnabled is set to true.
  92890. */
  92891. vignetteColor: Color4;
  92892. /**
  92893. * Camera field of view used by the Vignette effect.
  92894. */
  92895. vignetteCameraFov: number;
  92896. private _vignetteBlendMode;
  92897. /**
  92898. * Gets the vignette blend mode allowing different kind of effect.
  92899. */
  92900. /**
  92901. * Sets the vignette blend mode allowing different kind of effect.
  92902. */
  92903. vignetteBlendMode: number;
  92904. private _vignetteEnabled;
  92905. /**
  92906. * Gets wether the vignette effect is enabled.
  92907. */
  92908. /**
  92909. * Sets wether the vignette effect is enabled.
  92910. */
  92911. vignetteEnabled: boolean;
  92912. private _applyByPostProcess;
  92913. /**
  92914. * Gets wether the image processing is applied through a post process or not.
  92915. */
  92916. /**
  92917. * Sets wether the image processing is applied through a post process or not.
  92918. */
  92919. applyByPostProcess: boolean;
  92920. private _isEnabled;
  92921. /**
  92922. * Gets wether the image processing is enabled or not.
  92923. */
  92924. /**
  92925. * Sets wether the image processing is enabled or not.
  92926. */
  92927. isEnabled: boolean;
  92928. /**
  92929. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92930. */
  92931. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92932. /**
  92933. * Method called each time the image processing information changes requires to recompile the effect.
  92934. */
  92935. protected _updateParameters(): void;
  92936. /**
  92937. * Gets the current class name.
  92938. * @return "ImageProcessingConfiguration"
  92939. */
  92940. getClassName(): string;
  92941. /**
  92942. * Prepare the list of uniforms associated with the Image Processing effects.
  92943. * @param uniforms The list of uniforms used in the effect
  92944. * @param defines the list of defines currently in use
  92945. */
  92946. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92947. /**
  92948. * Prepare the list of samplers associated with the Image Processing effects.
  92949. * @param samplersList The list of uniforms used in the effect
  92950. * @param defines the list of defines currently in use
  92951. */
  92952. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92953. /**
  92954. * Prepare the list of defines associated to the shader.
  92955. * @param defines the list of defines to complete
  92956. * @param forPostProcess Define if we are currently in post process mode or not
  92957. */
  92958. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92959. /**
  92960. * Returns true if all the image processing information are ready.
  92961. * @returns True if ready, otherwise, false
  92962. */
  92963. isReady(): boolean;
  92964. /**
  92965. * Binds the image processing to the shader.
  92966. * @param effect The effect to bind to
  92967. * @param aspectRatio Define the current aspect ratio of the effect
  92968. */
  92969. bind(effect: Effect, aspectRatio?: number): void;
  92970. /**
  92971. * Clones the current image processing instance.
  92972. * @return The cloned image processing
  92973. */
  92974. clone(): ImageProcessingConfiguration;
  92975. /**
  92976. * Serializes the current image processing instance to a json representation.
  92977. * @return a JSON representation
  92978. */
  92979. serialize(): any;
  92980. /**
  92981. * Parses the image processing from a json representation.
  92982. * @param source the JSON source to parse
  92983. * @return The parsed image processing
  92984. */
  92985. static Parse(source: any): ImageProcessingConfiguration;
  92986. private static _VIGNETTEMODE_MULTIPLY;
  92987. private static _VIGNETTEMODE_OPAQUE;
  92988. /**
  92989. * Used to apply the vignette as a mix with the pixel color.
  92990. */
  92991. static readonly VIGNETTEMODE_MULTIPLY: number;
  92992. /**
  92993. * Used to apply the vignette as a replacement of the pixel color.
  92994. */
  92995. static readonly VIGNETTEMODE_OPAQUE: number;
  92996. }
  92997. }
  92998. declare module BABYLON {
  92999. /**
  93000. * This represents all the required information to add a fresnel effect on a material:
  93001. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93002. */
  93003. export class FresnelParameters {
  93004. private _isEnabled;
  93005. /**
  93006. * Define if the fresnel effect is enable or not.
  93007. */
  93008. isEnabled: boolean;
  93009. /**
  93010. * Define the color used on edges (grazing angle)
  93011. */
  93012. leftColor: Color3;
  93013. /**
  93014. * Define the color used on center
  93015. */
  93016. rightColor: Color3;
  93017. /**
  93018. * Define bias applied to computed fresnel term
  93019. */
  93020. bias: number;
  93021. /**
  93022. * Defined the power exponent applied to fresnel term
  93023. */
  93024. power: number;
  93025. /**
  93026. * Clones the current fresnel and its valuues
  93027. * @returns a clone fresnel configuration
  93028. */
  93029. clone(): FresnelParameters;
  93030. /**
  93031. * Serializes the current fresnel parameters to a JSON representation.
  93032. * @return the JSON serialization
  93033. */
  93034. serialize(): any;
  93035. /**
  93036. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93037. * @param parsedFresnelParameters Define the JSON representation
  93038. * @returns the parsed parameters
  93039. */
  93040. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93041. }
  93042. }
  93043. declare module BABYLON {
  93044. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93045. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93046. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93047. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93048. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93049. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93050. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93051. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93052. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93053. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93054. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93055. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93056. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93057. /**
  93058. * Decorator used to define property that can be serialized as reference to a camera
  93059. * @param sourceName defines the name of the property to decorate
  93060. */
  93061. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93062. /**
  93063. * Class used to help serialization objects
  93064. */
  93065. export class SerializationHelper {
  93066. /** @hidden */
  93067. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93068. /** @hidden */
  93069. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93070. /** @hidden */
  93071. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93072. /** @hidden */
  93073. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93074. /**
  93075. * Appends the serialized animations from the source animations
  93076. * @param source Source containing the animations
  93077. * @param destination Target to store the animations
  93078. */
  93079. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93080. /**
  93081. * Static function used to serialized a specific entity
  93082. * @param entity defines the entity to serialize
  93083. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93084. * @returns a JSON compatible object representing the serialization of the entity
  93085. */
  93086. static Serialize<T>(entity: T, serializationObject?: any): any;
  93087. /**
  93088. * Creates a new entity from a serialization data object
  93089. * @param creationFunction defines a function used to instanciated the new entity
  93090. * @param source defines the source serialization data
  93091. * @param scene defines the hosting scene
  93092. * @param rootUrl defines the root url for resources
  93093. * @returns a new entity
  93094. */
  93095. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93096. /**
  93097. * Clones an object
  93098. * @param creationFunction defines the function used to instanciate the new object
  93099. * @param source defines the source object
  93100. * @returns the cloned object
  93101. */
  93102. static Clone<T>(creationFunction: () => T, source: T): T;
  93103. /**
  93104. * Instanciates a new object based on a source one (some data will be shared between both object)
  93105. * @param creationFunction defines the function used to instanciate the new object
  93106. * @param source defines the source object
  93107. * @returns the new object
  93108. */
  93109. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93110. }
  93111. }
  93112. declare module BABYLON {
  93113. /**
  93114. * This is the base class of all the camera used in the application.
  93115. * @see http://doc.babylonjs.com/features/cameras
  93116. */
  93117. export class Camera extends Node {
  93118. /** @hidden */
  93119. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93120. /**
  93121. * This is the default projection mode used by the cameras.
  93122. * It helps recreating a feeling of perspective and better appreciate depth.
  93123. * This is the best way to simulate real life cameras.
  93124. */
  93125. static readonly PERSPECTIVE_CAMERA: number;
  93126. /**
  93127. * This helps creating camera with an orthographic mode.
  93128. * 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.
  93129. */
  93130. static readonly ORTHOGRAPHIC_CAMERA: number;
  93131. /**
  93132. * This is the default FOV mode for perspective cameras.
  93133. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93134. */
  93135. static readonly FOVMODE_VERTICAL_FIXED: number;
  93136. /**
  93137. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93138. */
  93139. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93140. /**
  93141. * This specifies ther is no need for a camera rig.
  93142. * Basically only one eye is rendered corresponding to the camera.
  93143. */
  93144. static readonly RIG_MODE_NONE: number;
  93145. /**
  93146. * Simulates a camera Rig with one blue eye and one red eye.
  93147. * This can be use with 3d blue and red glasses.
  93148. */
  93149. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93150. /**
  93151. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93152. */
  93153. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93154. /**
  93155. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93156. */
  93157. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93158. /**
  93159. * Defines that both eyes of the camera will be rendered over under each other.
  93160. */
  93161. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93162. /**
  93163. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93164. */
  93165. static readonly RIG_MODE_VR: number;
  93166. /**
  93167. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93168. */
  93169. static readonly RIG_MODE_WEBVR: number;
  93170. /**
  93171. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93172. */
  93173. static readonly RIG_MODE_CUSTOM: number;
  93174. /**
  93175. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93176. */
  93177. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93178. /**
  93179. * Define the input manager associated with the camera.
  93180. */
  93181. inputs: CameraInputsManager<Camera>;
  93182. /** @hidden */
  93183. _position: Vector3;
  93184. /**
  93185. * Define the current local position of the camera in the scene
  93186. */
  93187. position: Vector3;
  93188. /**
  93189. * The vector the camera should consider as up.
  93190. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93191. */
  93192. upVector: Vector3;
  93193. /**
  93194. * Define the current limit on the left side for an orthographic camera
  93195. * In scene unit
  93196. */
  93197. orthoLeft: Nullable<number>;
  93198. /**
  93199. * Define the current limit on the right side for an orthographic camera
  93200. * In scene unit
  93201. */
  93202. orthoRight: Nullable<number>;
  93203. /**
  93204. * Define the current limit on the bottom side for an orthographic camera
  93205. * In scene unit
  93206. */
  93207. orthoBottom: Nullable<number>;
  93208. /**
  93209. * Define the current limit on the top side for an orthographic camera
  93210. * In scene unit
  93211. */
  93212. orthoTop: Nullable<number>;
  93213. /**
  93214. * Field Of View is set in Radians. (default is 0.8)
  93215. */
  93216. fov: number;
  93217. /**
  93218. * Define the minimum distance the camera can see from.
  93219. * This is important to note that the depth buffer are not infinite and the closer it starts
  93220. * the more your scene might encounter depth fighting issue.
  93221. */
  93222. minZ: number;
  93223. /**
  93224. * Define the maximum distance the camera can see to.
  93225. * This is important to note that the depth buffer are not infinite and the further it end
  93226. * the more your scene might encounter depth fighting issue.
  93227. */
  93228. maxZ: number;
  93229. /**
  93230. * Define the default inertia of the camera.
  93231. * This helps giving a smooth feeling to the camera movement.
  93232. */
  93233. inertia: number;
  93234. /**
  93235. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93236. */
  93237. mode: number;
  93238. /**
  93239. * Define wether the camera is intermediate.
  93240. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93241. */
  93242. isIntermediate: boolean;
  93243. /**
  93244. * Define the viewport of the camera.
  93245. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93246. */
  93247. viewport: Viewport;
  93248. /**
  93249. * Restricts the camera to viewing objects with the same layerMask.
  93250. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93251. */
  93252. layerMask: number;
  93253. /**
  93254. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93255. */
  93256. fovMode: number;
  93257. /**
  93258. * Rig mode of the camera.
  93259. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93260. * This is normally controlled byt the camera themselves as internal use.
  93261. */
  93262. cameraRigMode: number;
  93263. /**
  93264. * Defines the distance between both "eyes" in case of a RIG
  93265. */
  93266. interaxialDistance: number;
  93267. /**
  93268. * Defines if stereoscopic rendering is done side by side or over under.
  93269. */
  93270. isStereoscopicSideBySide: boolean;
  93271. /**
  93272. * 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
  93273. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93274. * else in the scene.
  93275. */
  93276. customRenderTargets: RenderTargetTexture[];
  93277. /**
  93278. * When set, the camera will render to this render target instead of the default canvas
  93279. */
  93280. outputRenderTarget: Nullable<RenderTargetTexture>;
  93281. /**
  93282. * Observable triggered when the camera view matrix has changed.
  93283. */
  93284. onViewMatrixChangedObservable: Observable<Camera>;
  93285. /**
  93286. * Observable triggered when the camera Projection matrix has changed.
  93287. */
  93288. onProjectionMatrixChangedObservable: Observable<Camera>;
  93289. /**
  93290. * Observable triggered when the inputs have been processed.
  93291. */
  93292. onAfterCheckInputsObservable: Observable<Camera>;
  93293. /**
  93294. * Observable triggered when reset has been called and applied to the camera.
  93295. */
  93296. onRestoreStateObservable: Observable<Camera>;
  93297. /** @hidden */
  93298. _cameraRigParams: any;
  93299. /** @hidden */
  93300. _rigCameras: Camera[];
  93301. /** @hidden */
  93302. _rigPostProcess: Nullable<PostProcess>;
  93303. protected _webvrViewMatrix: Matrix;
  93304. /** @hidden */
  93305. _skipRendering: boolean;
  93306. /** @hidden */
  93307. _projectionMatrix: Matrix;
  93308. /** @hidden */
  93309. _postProcesses: Nullable<PostProcess>[];
  93310. /** @hidden */
  93311. _activeMeshes: SmartArray<AbstractMesh>;
  93312. protected _globalPosition: Vector3;
  93313. /** @hidden */
  93314. _computedViewMatrix: Matrix;
  93315. private _doNotComputeProjectionMatrix;
  93316. private _transformMatrix;
  93317. private _frustumPlanes;
  93318. private _refreshFrustumPlanes;
  93319. private _storedFov;
  93320. private _stateStored;
  93321. /**
  93322. * Instantiates a new camera object.
  93323. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93324. * @see http://doc.babylonjs.com/features/cameras
  93325. * @param name Defines the name of the camera in the scene
  93326. * @param position Defines the position of the camera
  93327. * @param scene Defines the scene the camera belongs too
  93328. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93329. */
  93330. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93331. /**
  93332. * Store current camera state (fov, position, etc..)
  93333. * @returns the camera
  93334. */
  93335. storeState(): Camera;
  93336. /**
  93337. * Restores the camera state values if it has been stored. You must call storeState() first
  93338. */
  93339. protected _restoreStateValues(): boolean;
  93340. /**
  93341. * Restored camera state. You must call storeState() first.
  93342. * @returns true if restored and false otherwise
  93343. */
  93344. restoreState(): boolean;
  93345. /**
  93346. * Gets the class name of the camera.
  93347. * @returns the class name
  93348. */
  93349. getClassName(): string;
  93350. /** @hidden */
  93351. readonly _isCamera: boolean;
  93352. /**
  93353. * Gets a string representation of the camera useful for debug purpose.
  93354. * @param fullDetails Defines that a more verboe level of logging is required
  93355. * @returns the string representation
  93356. */
  93357. toString(fullDetails?: boolean): string;
  93358. /**
  93359. * Gets the current world space position of the camera.
  93360. */
  93361. readonly globalPosition: Vector3;
  93362. /**
  93363. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93364. * @returns the active meshe list
  93365. */
  93366. getActiveMeshes(): SmartArray<AbstractMesh>;
  93367. /**
  93368. * Check wether a mesh is part of the current active mesh list of the camera
  93369. * @param mesh Defines the mesh to check
  93370. * @returns true if active, false otherwise
  93371. */
  93372. isActiveMesh(mesh: Mesh): boolean;
  93373. /**
  93374. * Is this camera ready to be used/rendered
  93375. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93376. * @return true if the camera is ready
  93377. */
  93378. isReady(completeCheck?: boolean): boolean;
  93379. /** @hidden */
  93380. _initCache(): void;
  93381. /** @hidden */
  93382. _updateCache(ignoreParentClass?: boolean): void;
  93383. /** @hidden */
  93384. _isSynchronized(): boolean;
  93385. /** @hidden */
  93386. _isSynchronizedViewMatrix(): boolean;
  93387. /** @hidden */
  93388. _isSynchronizedProjectionMatrix(): boolean;
  93389. /**
  93390. * Attach the input controls to a specific dom element to get the input from.
  93391. * @param element Defines the element the controls should be listened from
  93392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93393. */
  93394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93395. /**
  93396. * Detach the current controls from the specified dom element.
  93397. * @param element Defines the element to stop listening the inputs from
  93398. */
  93399. detachControl(element: HTMLElement): void;
  93400. /**
  93401. * Update the camera state according to the different inputs gathered during the frame.
  93402. */
  93403. update(): void;
  93404. /** @hidden */
  93405. _checkInputs(): void;
  93406. /** @hidden */
  93407. readonly rigCameras: Camera[];
  93408. /**
  93409. * Gets the post process used by the rig cameras
  93410. */
  93411. readonly rigPostProcess: Nullable<PostProcess>;
  93412. /**
  93413. * Internal, gets the first post proces.
  93414. * @returns the first post process to be run on this camera.
  93415. */
  93416. _getFirstPostProcess(): Nullable<PostProcess>;
  93417. private _cascadePostProcessesToRigCams;
  93418. /**
  93419. * Attach a post process to the camera.
  93420. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93421. * @param postProcess The post process to attach to the camera
  93422. * @param insertAt The position of the post process in case several of them are in use in the scene
  93423. * @returns the position the post process has been inserted at
  93424. */
  93425. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93426. /**
  93427. * Detach a post process to the camera.
  93428. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93429. * @param postProcess The post process to detach from the camera
  93430. */
  93431. detachPostProcess(postProcess: PostProcess): void;
  93432. /**
  93433. * Gets the current world matrix of the camera
  93434. */
  93435. getWorldMatrix(): Matrix;
  93436. /** @hidden */
  93437. _getViewMatrix(): Matrix;
  93438. /**
  93439. * Gets the current view matrix of the camera.
  93440. * @param force forces the camera to recompute the matrix without looking at the cached state
  93441. * @returns the view matrix
  93442. */
  93443. getViewMatrix(force?: boolean): Matrix;
  93444. /**
  93445. * Freeze the projection matrix.
  93446. * It will prevent the cache check of the camera projection compute and can speed up perf
  93447. * if no parameter of the camera are meant to change
  93448. * @param projection Defines manually a projection if necessary
  93449. */
  93450. freezeProjectionMatrix(projection?: Matrix): void;
  93451. /**
  93452. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93453. */
  93454. unfreezeProjectionMatrix(): void;
  93455. /**
  93456. * Gets the current projection matrix of the camera.
  93457. * @param force forces the camera to recompute the matrix without looking at the cached state
  93458. * @returns the projection matrix
  93459. */
  93460. getProjectionMatrix(force?: boolean): Matrix;
  93461. /**
  93462. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93463. * @returns a Matrix
  93464. */
  93465. getTransformationMatrix(): Matrix;
  93466. private _updateFrustumPlanes;
  93467. /**
  93468. * Checks if a cullable object (mesh...) is in the camera frustum
  93469. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93470. * @param target The object to check
  93471. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93472. * @returns true if the object is in frustum otherwise false
  93473. */
  93474. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93475. /**
  93476. * Checks if a cullable object (mesh...) is in the camera frustum
  93477. * Unlike isInFrustum this cheks the full bounding box
  93478. * @param target The object to check
  93479. * @returns true if the object is in frustum otherwise false
  93480. */
  93481. isCompletelyInFrustum(target: ICullable): boolean;
  93482. /**
  93483. * Gets a ray in the forward direction from the camera.
  93484. * @param length Defines the length of the ray to create
  93485. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93486. * @param origin Defines the start point of the ray which defaults to the camera position
  93487. * @returns the forward ray
  93488. */
  93489. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93490. /**
  93491. * Releases resources associated with this node.
  93492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93494. */
  93495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93496. /** @hidden */
  93497. _isLeftCamera: boolean;
  93498. /**
  93499. * Gets the left camera of a rig setup in case of Rigged Camera
  93500. */
  93501. readonly isLeftCamera: boolean;
  93502. /** @hidden */
  93503. _isRightCamera: boolean;
  93504. /**
  93505. * Gets the right camera of a rig setup in case of Rigged Camera
  93506. */
  93507. readonly isRightCamera: boolean;
  93508. /**
  93509. * Gets the left camera of a rig setup in case of Rigged Camera
  93510. */
  93511. readonly leftCamera: Nullable<FreeCamera>;
  93512. /**
  93513. * Gets the right camera of a rig setup in case of Rigged Camera
  93514. */
  93515. readonly rightCamera: Nullable<FreeCamera>;
  93516. /**
  93517. * Gets the left camera target of a rig setup in case of Rigged Camera
  93518. * @returns the target position
  93519. */
  93520. getLeftTarget(): Nullable<Vector3>;
  93521. /**
  93522. * Gets the right camera target of a rig setup in case of Rigged Camera
  93523. * @returns the target position
  93524. */
  93525. getRightTarget(): Nullable<Vector3>;
  93526. /**
  93527. * @hidden
  93528. */
  93529. setCameraRigMode(mode: number, rigParams: any): void;
  93530. /** @hidden */
  93531. static _setStereoscopicRigMode(camera: Camera): void;
  93532. /** @hidden */
  93533. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93534. /** @hidden */
  93535. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93536. /** @hidden */
  93537. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93538. /** @hidden */
  93539. _getVRProjectionMatrix(): Matrix;
  93540. protected _updateCameraRotationMatrix(): void;
  93541. protected _updateWebVRCameraRotationMatrix(): void;
  93542. /**
  93543. * This function MUST be overwritten by the different WebVR cameras available.
  93544. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93545. * @hidden
  93546. */
  93547. _getWebVRProjectionMatrix(): Matrix;
  93548. /**
  93549. * This function MUST be overwritten by the different WebVR cameras available.
  93550. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93551. * @hidden
  93552. */
  93553. _getWebVRViewMatrix(): Matrix;
  93554. /** @hidden */
  93555. setCameraRigParameter(name: string, value: any): void;
  93556. /**
  93557. * needs to be overridden by children so sub has required properties to be copied
  93558. * @hidden
  93559. */
  93560. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93561. /**
  93562. * May need to be overridden by children
  93563. * @hidden
  93564. */
  93565. _updateRigCameras(): void;
  93566. /** @hidden */
  93567. _setupInputs(): void;
  93568. /**
  93569. * Serialiaze the camera setup to a json represention
  93570. * @returns the JSON representation
  93571. */
  93572. serialize(): any;
  93573. /**
  93574. * Clones the current camera.
  93575. * @param name The cloned camera name
  93576. * @returns the cloned camera
  93577. */
  93578. clone(name: string): Camera;
  93579. /**
  93580. * Gets the direction of the camera relative to a given local axis.
  93581. * @param localAxis Defines the reference axis to provide a relative direction.
  93582. * @return the direction
  93583. */
  93584. getDirection(localAxis: Vector3): Vector3;
  93585. /**
  93586. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93587. * @param localAxis Defines the reference axis to provide a relative direction.
  93588. * @param result Defines the vector to store the result in
  93589. */
  93590. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93591. /**
  93592. * Gets a camera constructor for a given camera type
  93593. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93594. * @param name The name of the camera the result will be able to instantiate
  93595. * @param scene The scene the result will construct the camera in
  93596. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93597. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93598. * @returns a factory method to construc the camera
  93599. */
  93600. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93601. /**
  93602. * Compute the world matrix of the camera.
  93603. * @returns the camera workd matrix
  93604. */
  93605. computeWorldMatrix(): Matrix;
  93606. /**
  93607. * Parse a JSON and creates the camera from the parsed information
  93608. * @param parsedCamera The JSON to parse
  93609. * @param scene The scene to instantiate the camera in
  93610. * @returns the newly constructed camera
  93611. */
  93612. static Parse(parsedCamera: any, scene: Scene): Camera;
  93613. }
  93614. }
  93615. declare module BABYLON {
  93616. /**
  93617. * Interface for any object that can request an animation frame
  93618. */
  93619. export interface ICustomAnimationFrameRequester {
  93620. /**
  93621. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93622. */
  93623. renderFunction?: Function;
  93624. /**
  93625. * Called to request the next frame to render to
  93626. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93627. */
  93628. requestAnimationFrame: Function;
  93629. /**
  93630. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93631. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93632. */
  93633. requestID?: number;
  93634. }
  93635. /**
  93636. * Interface containing an array of animations
  93637. */
  93638. export interface IAnimatable {
  93639. /**
  93640. * Array of animations
  93641. */
  93642. animations: Nullable<Array<Animation>>;
  93643. }
  93644. /** Interface used by value gradients (color, factor, ...) */
  93645. export interface IValueGradient {
  93646. /**
  93647. * Gets or sets the gradient value (between 0 and 1)
  93648. */
  93649. gradient: number;
  93650. }
  93651. /** Class used to store color4 gradient */
  93652. export class ColorGradient implements IValueGradient {
  93653. /**
  93654. * Gets or sets the gradient value (between 0 and 1)
  93655. */
  93656. gradient: number;
  93657. /**
  93658. * Gets or sets first associated color
  93659. */
  93660. color1: Color4;
  93661. /**
  93662. * Gets or sets second associated color
  93663. */
  93664. color2?: Color4;
  93665. /**
  93666. * Will get a color picked randomly between color1 and color2.
  93667. * If color2 is undefined then color1 will be used
  93668. * @param result defines the target Color4 to store the result in
  93669. */
  93670. getColorToRef(result: Color4): void;
  93671. }
  93672. /** Class used to store color 3 gradient */
  93673. export class Color3Gradient implements IValueGradient {
  93674. /**
  93675. * Gets or sets the gradient value (between 0 and 1)
  93676. */
  93677. gradient: number;
  93678. /**
  93679. * Gets or sets the associated color
  93680. */
  93681. color: Color3;
  93682. }
  93683. /** Class used to store factor gradient */
  93684. export class FactorGradient implements IValueGradient {
  93685. /**
  93686. * Gets or sets the gradient value (between 0 and 1)
  93687. */
  93688. gradient: number;
  93689. /**
  93690. * Gets or sets first associated factor
  93691. */
  93692. factor1: number;
  93693. /**
  93694. * Gets or sets second associated factor
  93695. */
  93696. factor2?: number;
  93697. /**
  93698. * Will get a number picked randomly between factor1 and factor2.
  93699. * If factor2 is undefined then factor1 will be used
  93700. * @returns the picked number
  93701. */
  93702. getFactor(): number;
  93703. }
  93704. /**
  93705. * @ignore
  93706. * Application error to support additional information when loading a file
  93707. */
  93708. export class LoadFileError extends Error {
  93709. /** defines the optional web request */
  93710. request?: WebRequest | undefined;
  93711. private static _setPrototypeOf;
  93712. /**
  93713. * Creates a new LoadFileError
  93714. * @param message defines the message of the error
  93715. * @param request defines the optional web request
  93716. */
  93717. constructor(message: string,
  93718. /** defines the optional web request */
  93719. request?: WebRequest | undefined);
  93720. }
  93721. /**
  93722. * Class used to define a retry strategy when error happens while loading assets
  93723. */
  93724. export class RetryStrategy {
  93725. /**
  93726. * Function used to defines an exponential back off strategy
  93727. * @param maxRetries defines the maximum number of retries (3 by default)
  93728. * @param baseInterval defines the interval between retries
  93729. * @returns the strategy function to use
  93730. */
  93731. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93732. }
  93733. /**
  93734. * File request interface
  93735. */
  93736. export interface IFileRequest {
  93737. /**
  93738. * Raised when the request is complete (success or error).
  93739. */
  93740. onCompleteObservable: Observable<IFileRequest>;
  93741. /**
  93742. * Aborts the request for a file.
  93743. */
  93744. abort: () => void;
  93745. }
  93746. /**
  93747. * Class containing a set of static utilities functions
  93748. */
  93749. export class Tools {
  93750. /**
  93751. * Gets or sets the base URL to use to load assets
  93752. */
  93753. static BaseUrl: string;
  93754. /**
  93755. * Enable/Disable Custom HTTP Request Headers globally.
  93756. * default = false
  93757. * @see CustomRequestHeaders
  93758. */
  93759. static UseCustomRequestHeaders: boolean;
  93760. /**
  93761. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93762. * i.e. when loading files, where the server/service expects an Authorization header
  93763. */
  93764. static CustomRequestHeaders: {
  93765. [key: string]: string;
  93766. };
  93767. /**
  93768. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93769. */
  93770. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93771. /**
  93772. * Default behaviour for cors in the application.
  93773. * It can be a string if the expected behavior is identical in the entire app.
  93774. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93775. */
  93776. static CorsBehavior: string | ((url: string | string[]) => string);
  93777. /**
  93778. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93779. * @ignorenaming
  93780. */
  93781. static UseFallbackTexture: boolean;
  93782. /**
  93783. * Use this object to register external classes like custom textures or material
  93784. * to allow the laoders to instantiate them
  93785. */
  93786. static RegisteredExternalClasses: {
  93787. [key: string]: Object;
  93788. };
  93789. /**
  93790. * Texture content used if a texture cannot loaded
  93791. * @ignorenaming
  93792. */
  93793. static fallbackTexture: string;
  93794. /**
  93795. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93796. * @param u defines the coordinate on X axis
  93797. * @param v defines the coordinate on Y axis
  93798. * @param width defines the width of the source data
  93799. * @param height defines the height of the source data
  93800. * @param pixels defines the source byte array
  93801. * @param color defines the output color
  93802. */
  93803. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93804. /**
  93805. * Interpolates between a and b via alpha
  93806. * @param a The lower value (returned when alpha = 0)
  93807. * @param b The upper value (returned when alpha = 1)
  93808. * @param alpha The interpolation-factor
  93809. * @return The mixed value
  93810. */
  93811. static Mix(a: number, b: number, alpha: number): number;
  93812. /**
  93813. * Tries to instantiate a new object from a given class name
  93814. * @param className defines the class name to instantiate
  93815. * @returns the new object or null if the system was not able to do the instantiation
  93816. */
  93817. static Instantiate(className: string): any;
  93818. /**
  93819. * Provides a slice function that will work even on IE
  93820. * @param data defines the array to slice
  93821. * @param start defines the start of the data (optional)
  93822. * @param end defines the end of the data (optional)
  93823. * @returns the new sliced array
  93824. */
  93825. static Slice<T>(data: T, start?: number, end?: number): T;
  93826. /**
  93827. * Polyfill for setImmediate
  93828. * @param action defines the action to execute after the current execution block
  93829. */
  93830. static SetImmediate(action: () => void): void;
  93831. /**
  93832. * Function indicating if a number is an exponent of 2
  93833. * @param value defines the value to test
  93834. * @returns true if the value is an exponent of 2
  93835. */
  93836. static IsExponentOfTwo(value: number): boolean;
  93837. private static _tmpFloatArray;
  93838. /**
  93839. * Returns the nearest 32-bit single precision float representation of a Number
  93840. * @param value A Number. If the parameter is of a different type, it will get converted
  93841. * to a number or to NaN if it cannot be converted
  93842. * @returns number
  93843. */
  93844. static FloatRound(value: number): number;
  93845. /**
  93846. * Find the next highest power of two.
  93847. * @param x Number to start search from.
  93848. * @return Next highest power of two.
  93849. */
  93850. static CeilingPOT(x: number): number;
  93851. /**
  93852. * Find the next lowest power of two.
  93853. * @param x Number to start search from.
  93854. * @return Next lowest power of two.
  93855. */
  93856. static FloorPOT(x: number): number;
  93857. /**
  93858. * Find the nearest power of two.
  93859. * @param x Number to start search from.
  93860. * @return Next nearest power of two.
  93861. */
  93862. static NearestPOT(x: number): number;
  93863. /**
  93864. * Get the closest exponent of two
  93865. * @param value defines the value to approximate
  93866. * @param max defines the maximum value to return
  93867. * @param mode defines how to define the closest value
  93868. * @returns closest exponent of two of the given value
  93869. */
  93870. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93871. /**
  93872. * Extracts the filename from a path
  93873. * @param path defines the path to use
  93874. * @returns the filename
  93875. */
  93876. static GetFilename(path: string): string;
  93877. /**
  93878. * Extracts the "folder" part of a path (everything before the filename).
  93879. * @param uri The URI to extract the info from
  93880. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93881. * @returns The "folder" part of the path
  93882. */
  93883. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93884. /**
  93885. * Extracts text content from a DOM element hierarchy
  93886. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93887. */
  93888. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93889. /**
  93890. * Convert an angle in radians to degrees
  93891. * @param angle defines the angle to convert
  93892. * @returns the angle in degrees
  93893. */
  93894. static ToDegrees(angle: number): number;
  93895. /**
  93896. * Convert an angle in degrees to radians
  93897. * @param angle defines the angle to convert
  93898. * @returns the angle in radians
  93899. */
  93900. static ToRadians(angle: number): number;
  93901. /**
  93902. * Encode a buffer to a base64 string
  93903. * @param buffer defines the buffer to encode
  93904. * @returns the encoded string
  93905. */
  93906. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93907. /**
  93908. * Extracts minimum and maximum values from a list of indexed positions
  93909. * @param positions defines the positions to use
  93910. * @param indices defines the indices to the positions
  93911. * @param indexStart defines the start index
  93912. * @param indexCount defines the end index
  93913. * @param bias defines bias value to add to the result
  93914. * @return minimum and maximum values
  93915. */
  93916. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93917. minimum: Vector3;
  93918. maximum: Vector3;
  93919. };
  93920. /**
  93921. * Extracts minimum and maximum values from a list of positions
  93922. * @param positions defines the positions to use
  93923. * @param start defines the start index in the positions array
  93924. * @param count defines the number of positions to handle
  93925. * @param bias defines bias value to add to the result
  93926. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93927. * @return minimum and maximum values
  93928. */
  93929. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93930. minimum: Vector3;
  93931. maximum: Vector3;
  93932. };
  93933. /**
  93934. * Returns an array if obj is not an array
  93935. * @param obj defines the object to evaluate as an array
  93936. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93937. * @returns either obj directly if obj is an array or a new array containing obj
  93938. */
  93939. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93940. /**
  93941. * Gets the pointer prefix to use
  93942. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93943. */
  93944. static GetPointerPrefix(): string;
  93945. /**
  93946. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93947. * @param func - the function to be called
  93948. * @param requester - the object that will request the next frame. Falls back to window.
  93949. * @returns frame number
  93950. */
  93951. static QueueNewFrame(func: () => void, requester?: any): number;
  93952. /**
  93953. * Ask the browser to promote the current element to fullscreen rendering mode
  93954. * @param element defines the DOM element to promote
  93955. */
  93956. static RequestFullscreen(element: HTMLElement): void;
  93957. /**
  93958. * Asks the browser to exit fullscreen mode
  93959. */
  93960. static ExitFullscreen(): void;
  93961. /**
  93962. * Ask the browser to promote the current element to pointerlock mode
  93963. * @param element defines the DOM element to promote
  93964. */
  93965. static RequestPointerlock(element: HTMLElement): void;
  93966. /**
  93967. * Asks the browser to exit pointerlock mode
  93968. */
  93969. static ExitPointerlock(): void;
  93970. /**
  93971. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93972. * @param url define the url we are trying
  93973. * @param element define the dom element where to configure the cors policy
  93974. */
  93975. static SetCorsBehavior(url: string | string[], element: {
  93976. crossOrigin: string | null;
  93977. }): void;
  93978. /**
  93979. * Removes unwanted characters from an url
  93980. * @param url defines the url to clean
  93981. * @returns the cleaned url
  93982. */
  93983. static CleanUrl(url: string): string;
  93984. /**
  93985. * Gets or sets a function used to pre-process url before using them to load assets
  93986. */
  93987. static PreprocessUrl: (url: string) => string;
  93988. /**
  93989. * Loads an image as an HTMLImageElement.
  93990. * @param input url string, ArrayBuffer, or Blob to load
  93991. * @param onLoad callback called when the image successfully loads
  93992. * @param onError callback called when the image fails to load
  93993. * @param offlineProvider offline provider for caching
  93994. * @returns the HTMLImageElement of the loaded image
  93995. */
  93996. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93997. /**
  93998. * Loads a file
  93999. * @param url url string, ArrayBuffer, or Blob to load
  94000. * @param onSuccess callback called when the file successfully loads
  94001. * @param onProgress callback called while file is loading (if the server supports this mode)
  94002. * @param offlineProvider defines the offline provider for caching
  94003. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  94004. * @param onError callback called when the file fails to load
  94005. * @returns a file request object
  94006. */
  94007. 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;
  94008. /**
  94009. * Loads a file from a url
  94010. * @param url the file url to load
  94011. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  94012. */
  94013. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  94014. /**
  94015. * Load a script (identified by an url). When the url returns, the
  94016. * content of this file is added into a new script element, attached to the DOM (body element)
  94017. * @param scriptUrl defines the url of the script to laod
  94018. * @param onSuccess defines the callback called when the script is loaded
  94019. * @param onError defines the callback to call if an error occurs
  94020. * @param scriptId defines the id of the script element
  94021. */
  94022. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  94023. /**
  94024. * Load an asynchronous script (identified by an url). When the url returns, the
  94025. * content of this file is added into a new script element, attached to the DOM (body element)
  94026. * @param scriptUrl defines the url of the script to laod
  94027. * @param scriptId defines the id of the script element
  94028. * @returns a promise request object
  94029. */
  94030. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  94031. /**
  94032. * Loads a file from a blob
  94033. * @param fileToLoad defines the blob to use
  94034. * @param callback defines the callback to call when data is loaded
  94035. * @param progressCallback defines the callback to call during loading process
  94036. * @returns a file request object
  94037. */
  94038. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  94039. /**
  94040. * Loads a file
  94041. * @param fileToLoad defines the file to load
  94042. * @param callback defines the callback to call when data is loaded
  94043. * @param progressCallBack defines the callback to call during loading process
  94044. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94045. * @returns a file request object
  94046. */
  94047. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94048. /**
  94049. * Creates a data url from a given string content
  94050. * @param content defines the content to convert
  94051. * @returns the new data url link
  94052. */
  94053. static FileAsURL(content: string): string;
  94054. /**
  94055. * Format the given number to a specific decimal format
  94056. * @param value defines the number to format
  94057. * @param decimals defines the number of decimals to use
  94058. * @returns the formatted string
  94059. */
  94060. static Format(value: number, decimals?: number): string;
  94061. /**
  94062. * Checks if a given vector is inside a specific range
  94063. * @param v defines the vector to test
  94064. * @param min defines the minimum range
  94065. * @param max defines the maximum range
  94066. */
  94067. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94068. /**
  94069. * Tries to copy an object by duplicating every property
  94070. * @param source defines the source object
  94071. * @param destination defines the target object
  94072. * @param doNotCopyList defines a list of properties to avoid
  94073. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94074. */
  94075. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94076. /**
  94077. * Gets a boolean indicating if the given object has no own property
  94078. * @param obj defines the object to test
  94079. * @returns true if object has no own property
  94080. */
  94081. static IsEmpty(obj: any): boolean;
  94082. /**
  94083. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94084. * @param str Source string
  94085. * @param suffix Suffix to search for in the source string
  94086. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94087. */
  94088. static EndsWith(str: string, suffix: string): boolean;
  94089. /**
  94090. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94091. * @param str Source string
  94092. * @param suffix Suffix to search for in the source string
  94093. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94094. */
  94095. static StartsWith(str: string, suffix: string): boolean;
  94096. /**
  94097. * Function used to register events at window level
  94098. * @param events defines the events to register
  94099. */
  94100. static RegisterTopRootEvents(events: {
  94101. name: string;
  94102. handler: Nullable<(e: FocusEvent) => any>;
  94103. }[]): void;
  94104. /**
  94105. * Function used to unregister events from window level
  94106. * @param events defines the events to unregister
  94107. */
  94108. static UnregisterTopRootEvents(events: {
  94109. name: string;
  94110. handler: Nullable<(e: FocusEvent) => any>;
  94111. }[]): void;
  94112. /**
  94113. * @ignore
  94114. */
  94115. static _ScreenshotCanvas: HTMLCanvasElement;
  94116. /**
  94117. * Dumps the current bound framebuffer
  94118. * @param width defines the rendering width
  94119. * @param height defines the rendering height
  94120. * @param engine defines the hosting engine
  94121. * @param successCallback defines the callback triggered once the data are available
  94122. * @param mimeType defines the mime type of the result
  94123. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94124. */
  94125. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94126. /**
  94127. * Converts the canvas data to blob.
  94128. * This acts as a polyfill for browsers not supporting the to blob function.
  94129. * @param canvas Defines the canvas to extract the data from
  94130. * @param successCallback Defines the callback triggered once the data are available
  94131. * @param mimeType Defines the mime type of the result
  94132. */
  94133. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94134. /**
  94135. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94136. * @param successCallback defines the callback triggered once the data are available
  94137. * @param mimeType defines the mime type of the result
  94138. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94139. */
  94140. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94141. /**
  94142. * Downloads a blob in the browser
  94143. * @param blob defines the blob to download
  94144. * @param fileName defines the name of the downloaded file
  94145. */
  94146. static Download(blob: Blob, fileName: string): void;
  94147. /**
  94148. * Captures a screenshot of the current rendering
  94149. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94150. * @param engine defines the rendering engine
  94151. * @param camera defines the source camera
  94152. * @param size This parameter can be set to a single number or to an object with the
  94153. * following (optional) properties: precision, width, height. If a single number is passed,
  94154. * it will be used for both width and height. If an object is passed, the screenshot size
  94155. * will be derived from the parameters. The precision property is a multiplier allowing
  94156. * rendering at a higher or lower resolution
  94157. * @param successCallback defines the callback receives a single parameter which contains the
  94158. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94159. * src parameter of an <img> to display it
  94160. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94161. * Check your browser for supported MIME types
  94162. */
  94163. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94164. /**
  94165. * Generates an image screenshot from the specified camera.
  94166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94167. * @param engine The engine to use for rendering
  94168. * @param camera The camera to use for rendering
  94169. * @param size This parameter can be set to a single number or to an object with the
  94170. * following (optional) properties: precision, width, height. If a single number is passed,
  94171. * it will be used for both width and height. If an object is passed, the screenshot size
  94172. * will be derived from the parameters. The precision property is a multiplier allowing
  94173. * rendering at a higher or lower resolution
  94174. * @param successCallback The callback receives a single parameter which contains the
  94175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94176. * src parameter of an <img> to display it
  94177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94178. * Check your browser for supported MIME types
  94179. * @param samples Texture samples (default: 1)
  94180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94181. * @param fileName A name for for the downloaded file.
  94182. */
  94183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94184. /**
  94185. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94186. * Be aware Math.random() could cause collisions, but:
  94187. * "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"
  94188. * @returns a pseudo random id
  94189. */
  94190. static RandomId(): string;
  94191. /**
  94192. * Test if the given uri is a base64 string
  94193. * @param uri The uri to test
  94194. * @return True if the uri is a base64 string or false otherwise
  94195. */
  94196. static IsBase64(uri: string): boolean;
  94197. /**
  94198. * Decode the given base64 uri.
  94199. * @param uri The uri to decode
  94200. * @return The decoded base64 data.
  94201. */
  94202. static DecodeBase64(uri: string): ArrayBuffer;
  94203. /**
  94204. * Gets the absolute url.
  94205. * @param url the input url
  94206. * @return the absolute url
  94207. */
  94208. static GetAbsoluteUrl(url: string): string;
  94209. /**
  94210. * No log
  94211. */
  94212. static readonly NoneLogLevel: number;
  94213. /**
  94214. * Only message logs
  94215. */
  94216. static readonly MessageLogLevel: number;
  94217. /**
  94218. * Only warning logs
  94219. */
  94220. static readonly WarningLogLevel: number;
  94221. /**
  94222. * Only error logs
  94223. */
  94224. static readonly ErrorLogLevel: number;
  94225. /**
  94226. * All logs
  94227. */
  94228. static readonly AllLogLevel: number;
  94229. /**
  94230. * Gets a value indicating the number of loading errors
  94231. * @ignorenaming
  94232. */
  94233. static readonly errorsCount: number;
  94234. /**
  94235. * Callback called when a new log is added
  94236. */
  94237. static OnNewCacheEntry: (entry: string) => void;
  94238. /**
  94239. * Log a message to the console
  94240. * @param message defines the message to log
  94241. */
  94242. static Log(message: string): void;
  94243. /**
  94244. * Write a warning message to the console
  94245. * @param message defines the message to log
  94246. */
  94247. static Warn(message: string): void;
  94248. /**
  94249. * Write an error message to the console
  94250. * @param message defines the message to log
  94251. */
  94252. static Error(message: string): void;
  94253. /**
  94254. * Gets current log cache (list of logs)
  94255. */
  94256. static readonly LogCache: string;
  94257. /**
  94258. * Clears the log cache
  94259. */
  94260. static ClearLogCache(): void;
  94261. /**
  94262. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94263. */
  94264. static LogLevels: number;
  94265. /**
  94266. * Checks if the loaded document was accessed via `file:`-Protocol.
  94267. * @returns boolean
  94268. */
  94269. static IsFileURL(): boolean;
  94270. /**
  94271. * Checks if the window object exists
  94272. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94273. */
  94274. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94275. /**
  94276. * No performance log
  94277. */
  94278. static readonly PerformanceNoneLogLevel: number;
  94279. /**
  94280. * Use user marks to log performance
  94281. */
  94282. static readonly PerformanceUserMarkLogLevel: number;
  94283. /**
  94284. * Log performance to the console
  94285. */
  94286. static readonly PerformanceConsoleLogLevel: number;
  94287. private static _performance;
  94288. /**
  94289. * Sets the current performance log level
  94290. */
  94291. static PerformanceLogLevel: number;
  94292. private static _StartPerformanceCounterDisabled;
  94293. private static _EndPerformanceCounterDisabled;
  94294. private static _StartUserMark;
  94295. private static _EndUserMark;
  94296. private static _StartPerformanceConsole;
  94297. private static _EndPerformanceConsole;
  94298. /**
  94299. * Starts a performance counter
  94300. */
  94301. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94302. /**
  94303. * Ends a specific performance coutner
  94304. */
  94305. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94306. /**
  94307. * Gets either window.performance.now() if supported or Date.now() else
  94308. */
  94309. static readonly Now: number;
  94310. /**
  94311. * This method will return the name of the class used to create the instance of the given object.
  94312. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94313. * @param object the object to get the class name from
  94314. * @param isType defines if the object is actually a type
  94315. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94316. */
  94317. static GetClassName(object: any, isType?: boolean): string;
  94318. /**
  94319. * Gets the first element of an array satisfying a given predicate
  94320. * @param array defines the array to browse
  94321. * @param predicate defines the predicate to use
  94322. * @returns null if not found or the element
  94323. */
  94324. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94325. /**
  94326. * This method will return the name of the full name of the class, including its owning module (if any).
  94327. * 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).
  94328. * @param object the object to get the class name from
  94329. * @param isType defines if the object is actually a type
  94330. * @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.
  94331. * @ignorenaming
  94332. */
  94333. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94334. /**
  94335. * Returns a promise that resolves after the given amount of time.
  94336. * @param delay Number of milliseconds to delay
  94337. * @returns Promise that resolves after the given amount of time
  94338. */
  94339. static DelayAsync(delay: number): Promise<void>;
  94340. /**
  94341. * Gets the current gradient from an array of IValueGradient
  94342. * @param ratio defines the current ratio to get
  94343. * @param gradients defines the array of IValueGradient
  94344. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94345. */
  94346. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94347. }
  94348. /**
  94349. * This class is used to track a performance counter which is number based.
  94350. * The user has access to many properties which give statistics of different nature.
  94351. *
  94352. * The implementer can track two kinds of Performance Counter: time and count.
  94353. * 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.
  94354. * 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.
  94355. */
  94356. export class PerfCounter {
  94357. /**
  94358. * Gets or sets a global boolean to turn on and off all the counters
  94359. */
  94360. static Enabled: boolean;
  94361. /**
  94362. * Returns the smallest value ever
  94363. */
  94364. readonly min: number;
  94365. /**
  94366. * Returns the biggest value ever
  94367. */
  94368. readonly max: number;
  94369. /**
  94370. * Returns the average value since the performance counter is running
  94371. */
  94372. readonly average: number;
  94373. /**
  94374. * Returns the average value of the last second the counter was monitored
  94375. */
  94376. readonly lastSecAverage: number;
  94377. /**
  94378. * Returns the current value
  94379. */
  94380. readonly current: number;
  94381. /**
  94382. * Gets the accumulated total
  94383. */
  94384. readonly total: number;
  94385. /**
  94386. * Gets the total value count
  94387. */
  94388. readonly count: number;
  94389. /**
  94390. * Creates a new counter
  94391. */
  94392. constructor();
  94393. /**
  94394. * Call this method to start monitoring a new frame.
  94395. * 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.
  94396. */
  94397. fetchNewFrame(): void;
  94398. /**
  94399. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94400. * @param newCount the count value to add to the monitored count
  94401. * @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.
  94402. */
  94403. addCount(newCount: number, fetchResult: boolean): void;
  94404. /**
  94405. * Start monitoring this performance counter
  94406. */
  94407. beginMonitoring(): void;
  94408. /**
  94409. * Compute the time lapsed since the previous beginMonitoring() call.
  94410. * @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
  94411. */
  94412. endMonitoring(newFrame?: boolean): void;
  94413. private _fetchResult;
  94414. private _startMonitoringTime;
  94415. private _min;
  94416. private _max;
  94417. private _average;
  94418. private _current;
  94419. private _totalValueCount;
  94420. private _totalAccumulated;
  94421. private _lastSecAverage;
  94422. private _lastSecAccumulated;
  94423. private _lastSecTime;
  94424. private _lastSecValueCount;
  94425. }
  94426. /**
  94427. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94428. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94429. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94430. * @param name The name of the class, case should be preserved
  94431. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94432. */
  94433. export function className(name: string, module?: string): (target: Object) => void;
  94434. /**
  94435. * An implementation of a loop for asynchronous functions.
  94436. */
  94437. export class AsyncLoop {
  94438. /**
  94439. * Defines the number of iterations for the loop
  94440. */
  94441. iterations: number;
  94442. /**
  94443. * Defines the current index of the loop.
  94444. */
  94445. index: number;
  94446. private _done;
  94447. private _fn;
  94448. private _successCallback;
  94449. /**
  94450. * Constructor.
  94451. * @param iterations the number of iterations.
  94452. * @param func the function to run each iteration
  94453. * @param successCallback the callback that will be called upon succesful execution
  94454. * @param offset starting offset.
  94455. */
  94456. constructor(
  94457. /**
  94458. * Defines the number of iterations for the loop
  94459. */
  94460. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94461. /**
  94462. * Execute the next iteration. Must be called after the last iteration was finished.
  94463. */
  94464. executeNext(): void;
  94465. /**
  94466. * Break the loop and run the success callback.
  94467. */
  94468. breakLoop(): void;
  94469. /**
  94470. * Create and run an async loop.
  94471. * @param iterations the number of iterations.
  94472. * @param fn the function to run each iteration
  94473. * @param successCallback the callback that will be called upon succesful execution
  94474. * @param offset starting offset.
  94475. * @returns the created async loop object
  94476. */
  94477. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94478. /**
  94479. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94480. * @param iterations total number of iterations
  94481. * @param syncedIterations number of synchronous iterations in each async iteration.
  94482. * @param fn the function to call each iteration.
  94483. * @param callback a success call back that will be called when iterating stops.
  94484. * @param breakFunction a break condition (optional)
  94485. * @param timeout timeout settings for the setTimeout function. default - 0.
  94486. * @returns the created async loop object
  94487. */
  94488. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94489. }
  94490. }
  94491. declare module BABYLON {
  94492. /** @hidden */
  94493. export interface ICollisionCoordinator {
  94494. createCollider(): Collider;
  94495. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94496. init(scene: Scene): void;
  94497. }
  94498. /** @hidden */
  94499. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94500. private _scene;
  94501. private _scaledPosition;
  94502. private _scaledVelocity;
  94503. private _finalPosition;
  94504. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94505. createCollider(): Collider;
  94506. init(scene: Scene): void;
  94507. private _collideWithWorld;
  94508. }
  94509. }
  94510. declare module BABYLON {
  94511. /**
  94512. * Class used to manage all inputs for the scene.
  94513. */
  94514. export class InputManager {
  94515. /** The distance in pixel that you have to move to prevent some events */
  94516. static DragMovementThreshold: number;
  94517. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94518. static LongPressDelay: number;
  94519. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94520. static DoubleClickDelay: number;
  94521. /** If you need to check double click without raising a single click at first click, enable this flag */
  94522. static ExclusiveDoubleClickMode: boolean;
  94523. private _wheelEventName;
  94524. private _onPointerMove;
  94525. private _onPointerDown;
  94526. private _onPointerUp;
  94527. private _initClickEvent;
  94528. private _initActionManager;
  94529. private _delayedSimpleClick;
  94530. private _delayedSimpleClickTimeout;
  94531. private _previousDelayedSimpleClickTimeout;
  94532. private _meshPickProceed;
  94533. private _previousButtonPressed;
  94534. private _currentPickResult;
  94535. private _previousPickResult;
  94536. private _totalPointersPressed;
  94537. private _doubleClickOccured;
  94538. private _pointerOverMesh;
  94539. private _pickedDownMesh;
  94540. private _pickedUpMesh;
  94541. private _pointerX;
  94542. private _pointerY;
  94543. private _unTranslatedPointerX;
  94544. private _unTranslatedPointerY;
  94545. private _startingPointerPosition;
  94546. private _previousStartingPointerPosition;
  94547. private _startingPointerTime;
  94548. private _previousStartingPointerTime;
  94549. private _pointerCaptures;
  94550. private _onKeyDown;
  94551. private _onKeyUp;
  94552. private _onCanvasFocusObserver;
  94553. private _onCanvasBlurObserver;
  94554. private _scene;
  94555. /**
  94556. * Creates a new InputManager
  94557. * @param scene defines the hosting scene
  94558. */
  94559. constructor(scene: Scene);
  94560. /**
  94561. * Gets the mesh that is currently under the pointer
  94562. */
  94563. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94564. /**
  94565. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94566. */
  94567. readonly unTranslatedPointer: Vector2;
  94568. /**
  94569. * Gets or sets the current on-screen X position of the pointer
  94570. */
  94571. pointerX: number;
  94572. /**
  94573. * Gets or sets the current on-screen Y position of the pointer
  94574. */
  94575. pointerY: number;
  94576. private _updatePointerPosition;
  94577. private _processPointerMove;
  94578. private _setRayOnPointerInfo;
  94579. private _checkPrePointerObservable;
  94580. /**
  94581. * Use this method to simulate a pointer move on a mesh
  94582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94585. */
  94586. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94587. /**
  94588. * Use this method to simulate a pointer down on a mesh
  94589. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94590. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94591. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94592. */
  94593. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94594. private _processPointerDown;
  94595. /** @hidden */
  94596. _isPointerSwiping(): boolean;
  94597. /**
  94598. * Use this method to simulate a pointer up on a mesh
  94599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94602. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94603. */
  94604. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94605. private _processPointerUp;
  94606. /**
  94607. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94608. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94609. * @returns true if the pointer was captured
  94610. */
  94611. isPointerCaptured(pointerId?: number): boolean;
  94612. /**
  94613. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94614. * @param attachUp defines if you want to attach events to pointerup
  94615. * @param attachDown defines if you want to attach events to pointerdown
  94616. * @param attachMove defines if you want to attach events to pointermove
  94617. */
  94618. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94619. /**
  94620. * Detaches all event handlers
  94621. */
  94622. detachControl(): void;
  94623. /**
  94624. * Force the value of meshUnderPointer
  94625. * @param mesh defines the mesh to use
  94626. */
  94627. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94628. /**
  94629. * Gets the mesh under the pointer
  94630. * @returns a Mesh or null if no mesh is under the pointer
  94631. */
  94632. getPointerOverMesh(): Nullable<AbstractMesh>;
  94633. }
  94634. }
  94635. declare module BABYLON {
  94636. /**
  94637. * This class defines the direct association between an animation and a target
  94638. */
  94639. export class TargetedAnimation {
  94640. /**
  94641. * Animation to perform
  94642. */
  94643. animation: Animation;
  94644. /**
  94645. * Target to animate
  94646. */
  94647. target: any;
  94648. /**
  94649. * Serialize the object
  94650. * @returns the JSON object representing the current entity
  94651. */
  94652. serialize(): any;
  94653. }
  94654. /**
  94655. * Use this class to create coordinated animations on multiple targets
  94656. */
  94657. export class AnimationGroup implements IDisposable {
  94658. /** The name of the animation group */
  94659. name: string;
  94660. private _scene;
  94661. private _targetedAnimations;
  94662. private _animatables;
  94663. private _from;
  94664. private _to;
  94665. private _isStarted;
  94666. private _isPaused;
  94667. private _speedRatio;
  94668. private _loopAnimation;
  94669. /**
  94670. * Gets or sets the unique id of the node
  94671. */
  94672. uniqueId: number;
  94673. /**
  94674. * This observable will notify when one animation have ended
  94675. */
  94676. onAnimationEndObservable: Observable<TargetedAnimation>;
  94677. /**
  94678. * Observer raised when one animation loops
  94679. */
  94680. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94681. /**
  94682. * This observable will notify when all animations have ended.
  94683. */
  94684. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94685. /**
  94686. * This observable will notify when all animations have paused.
  94687. */
  94688. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94689. /**
  94690. * This observable will notify when all animations are playing.
  94691. */
  94692. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94693. /**
  94694. * Gets the first frame
  94695. */
  94696. readonly from: number;
  94697. /**
  94698. * Gets the last frame
  94699. */
  94700. readonly to: number;
  94701. /**
  94702. * Define if the animations are started
  94703. */
  94704. readonly isStarted: boolean;
  94705. /**
  94706. * Gets a value indicating that the current group is playing
  94707. */
  94708. readonly isPlaying: boolean;
  94709. /**
  94710. * Gets or sets the speed ratio to use for all animations
  94711. */
  94712. /**
  94713. * Gets or sets the speed ratio to use for all animations
  94714. */
  94715. speedRatio: number;
  94716. /**
  94717. * Gets or sets if all animations should loop or not
  94718. */
  94719. loopAnimation: boolean;
  94720. /**
  94721. * Gets the targeted animations for this animation group
  94722. */
  94723. readonly targetedAnimations: Array<TargetedAnimation>;
  94724. /**
  94725. * returning the list of animatables controlled by this animation group.
  94726. */
  94727. readonly animatables: Array<Animatable>;
  94728. /**
  94729. * Instantiates a new Animation Group.
  94730. * This helps managing several animations at once.
  94731. * @see http://doc.babylonjs.com/how_to/group
  94732. * @param name Defines the name of the group
  94733. * @param scene Defines the scene the group belongs to
  94734. */
  94735. constructor(
  94736. /** The name of the animation group */
  94737. name: string, scene?: Nullable<Scene>);
  94738. /**
  94739. * Add an animation (with its target) in the group
  94740. * @param animation defines the animation we want to add
  94741. * @param target defines the target of the animation
  94742. * @returns the TargetedAnimation object
  94743. */
  94744. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94745. /**
  94746. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94747. * It can add constant keys at begin or end
  94748. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94749. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94750. * @returns the animation group
  94751. */
  94752. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94753. /**
  94754. * Start all animations on given targets
  94755. * @param loop defines if animations must loop
  94756. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94757. * @param from defines the from key (optional)
  94758. * @param to defines the to key (optional)
  94759. * @returns the current animation group
  94760. */
  94761. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94762. /**
  94763. * Pause all animations
  94764. * @returns the animation group
  94765. */
  94766. pause(): AnimationGroup;
  94767. /**
  94768. * Play all animations to initial state
  94769. * This function will start() the animations if they were not started or will restart() them if they were paused
  94770. * @param loop defines if animations must loop
  94771. * @returns the animation group
  94772. */
  94773. play(loop?: boolean): AnimationGroup;
  94774. /**
  94775. * Reset all animations to initial state
  94776. * @returns the animation group
  94777. */
  94778. reset(): AnimationGroup;
  94779. /**
  94780. * Restart animations from key 0
  94781. * @returns the animation group
  94782. */
  94783. restart(): AnimationGroup;
  94784. /**
  94785. * Stop all animations
  94786. * @returns the animation group
  94787. */
  94788. stop(): AnimationGroup;
  94789. /**
  94790. * Set animation weight for all animatables
  94791. * @param weight defines the weight to use
  94792. * @return the animationGroup
  94793. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94794. */
  94795. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94796. /**
  94797. * Synchronize and normalize all animatables with a source animatable
  94798. * @param root defines the root animatable to synchronize with
  94799. * @return the animationGroup
  94800. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94801. */
  94802. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94803. /**
  94804. * Goes to a specific frame in this animation group
  94805. * @param frame the frame number to go to
  94806. * @return the animationGroup
  94807. */
  94808. goToFrame(frame: number): AnimationGroup;
  94809. /**
  94810. * Dispose all associated resources
  94811. */
  94812. dispose(): void;
  94813. private _checkAnimationGroupEnded;
  94814. /**
  94815. * Clone the current animation group and returns a copy
  94816. * @param newName defines the name of the new group
  94817. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94818. * @returns the new aniamtion group
  94819. */
  94820. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94821. /**
  94822. * Serializes the animationGroup to an object
  94823. * @returns Serialized object
  94824. */
  94825. serialize(): any;
  94826. /**
  94827. * Returns a new AnimationGroup object parsed from the source provided.
  94828. * @param parsedAnimationGroup defines the source
  94829. * @param scene defines the scene that will receive the animationGroup
  94830. * @returns a new AnimationGroup
  94831. */
  94832. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94833. /**
  94834. * Returns the string "AnimationGroup"
  94835. * @returns "AnimationGroup"
  94836. */
  94837. getClassName(): string;
  94838. /**
  94839. * Creates a detailled string about the object
  94840. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94841. * @returns a string representing the object
  94842. */
  94843. toString(fullDetails?: boolean): string;
  94844. }
  94845. }
  94846. declare module BABYLON {
  94847. /**
  94848. * Define an interface for all classes that will hold resources
  94849. */
  94850. export interface IDisposable {
  94851. /**
  94852. * Releases all held resources
  94853. */
  94854. dispose(): void;
  94855. }
  94856. /** Interface defining initialization parameters for Scene class */
  94857. export interface SceneOptions {
  94858. /**
  94859. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94860. * It will improve performance when the number of geometries becomes important.
  94861. */
  94862. useGeometryUniqueIdsMap?: boolean;
  94863. /**
  94864. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94865. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94866. */
  94867. useMaterialMeshMap?: boolean;
  94868. /**
  94869. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94870. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94871. */
  94872. useClonedMeshhMap?: boolean;
  94873. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94874. virtual?: boolean;
  94875. }
  94876. /**
  94877. * Represents a scene to be rendered by the engine.
  94878. * @see http://doc.babylonjs.com/features/scene
  94879. */
  94880. export class Scene extends AbstractScene implements IAnimatable {
  94881. private static _uniqueIdCounter;
  94882. /** The fog is deactivated */
  94883. static readonly FOGMODE_NONE: number;
  94884. /** The fog density is following an exponential function */
  94885. static readonly FOGMODE_EXP: number;
  94886. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94887. static readonly FOGMODE_EXP2: number;
  94888. /** The fog density is following a linear function. */
  94889. static readonly FOGMODE_LINEAR: number;
  94890. /**
  94891. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94893. */
  94894. static MinDeltaTime: number;
  94895. /**
  94896. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94898. */
  94899. static MaxDeltaTime: number;
  94900. /**
  94901. * Factory used to create the default material.
  94902. * @param name The name of the material to create
  94903. * @param scene The scene to create the material for
  94904. * @returns The default material
  94905. */
  94906. static DefaultMaterialFactory(scene: Scene): Material;
  94907. /**
  94908. * Factory used to create the a collision coordinator.
  94909. * @returns The collision coordinator
  94910. */
  94911. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94912. /** @hidden */
  94913. _inputManager: InputManager;
  94914. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94915. cameraToUseForPointers: Nullable<Camera>;
  94916. /** @hidden */
  94917. readonly _isScene: boolean;
  94918. /**
  94919. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94920. */
  94921. autoClear: boolean;
  94922. /**
  94923. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94924. */
  94925. autoClearDepthAndStencil: boolean;
  94926. /**
  94927. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94928. */
  94929. clearColor: Color4;
  94930. /**
  94931. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94932. */
  94933. ambientColor: Color3;
  94934. /**
  94935. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94936. * It should only be one of the following (if not the default embedded one):
  94937. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94938. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94939. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94940. * The material properties need to be setup according to the type of texture in use.
  94941. */
  94942. environmentBRDFTexture: BaseTexture;
  94943. /** @hidden */
  94944. protected _environmentTexture: Nullable<BaseTexture>;
  94945. /**
  94946. * Texture used in all pbr material as the reflection texture.
  94947. * As in the majority of the scene they are the same (exception for multi room and so on),
  94948. * this is easier to reference from here than from all the materials.
  94949. */
  94950. /**
  94951. * Texture used in all pbr material as the reflection texture.
  94952. * As in the majority of the scene they are the same (exception for multi room and so on),
  94953. * this is easier to set here than in all the materials.
  94954. */
  94955. environmentTexture: Nullable<BaseTexture>;
  94956. /** @hidden */
  94957. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94958. /**
  94959. * Default image processing configuration used either in the rendering
  94960. * Forward main pass or through the imageProcessingPostProcess if present.
  94961. * As in the majority of the scene they are the same (exception for multi camera),
  94962. * this is easier to reference from here than from all the materials and post process.
  94963. *
  94964. * No setter as we it is a shared configuration, you can set the values instead.
  94965. */
  94966. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94967. private _forceWireframe;
  94968. /**
  94969. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94970. */
  94971. forceWireframe: boolean;
  94972. private _forcePointsCloud;
  94973. /**
  94974. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94975. */
  94976. forcePointsCloud: boolean;
  94977. /**
  94978. * Gets or sets the active clipplane 1
  94979. */
  94980. clipPlane: Nullable<Plane>;
  94981. /**
  94982. * Gets or sets the active clipplane 2
  94983. */
  94984. clipPlane2: Nullable<Plane>;
  94985. /**
  94986. * Gets or sets the active clipplane 3
  94987. */
  94988. clipPlane3: Nullable<Plane>;
  94989. /**
  94990. * Gets or sets the active clipplane 4
  94991. */
  94992. clipPlane4: Nullable<Plane>;
  94993. /**
  94994. * Gets or sets a boolean indicating if animations are enabled
  94995. */
  94996. animationsEnabled: boolean;
  94997. private _animationPropertiesOverride;
  94998. /**
  94999. * Gets or sets the animation properties override
  95000. */
  95001. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95002. /**
  95003. * Gets or sets a boolean indicating if a constant deltatime has to be used
  95004. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  95005. */
  95006. useConstantAnimationDeltaTime: boolean;
  95007. /**
  95008. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  95009. * Please note that it requires to run a ray cast through the scene on every frame
  95010. */
  95011. constantlyUpdateMeshUnderPointer: boolean;
  95012. /**
  95013. * Defines the HTML cursor to use when hovering over interactive elements
  95014. */
  95015. hoverCursor: string;
  95016. /**
  95017. * Defines the HTML default cursor to use (empty by default)
  95018. */
  95019. defaultCursor: string;
  95020. /**
  95021. * This is used to call preventDefault() on pointer down
  95022. * in order to block unwanted artifacts like system double clicks
  95023. */
  95024. preventDefaultOnPointerDown: boolean;
  95025. /**
  95026. * This is used to call preventDefault() on pointer up
  95027. * in order to block unwanted artifacts like system double clicks
  95028. */
  95029. preventDefaultOnPointerUp: boolean;
  95030. /**
  95031. * Gets or sets user defined metadata
  95032. */
  95033. metadata: any;
  95034. /**
  95035. * For internal use only. Please do not use.
  95036. */
  95037. reservedDataStore: any;
  95038. /**
  95039. * Gets the name of the plugin used to load this scene (null by default)
  95040. */
  95041. loadingPluginName: string;
  95042. /**
  95043. * Use this array to add regular expressions used to disable offline support for specific urls
  95044. */
  95045. disableOfflineSupportExceptionRules: RegExp[];
  95046. /**
  95047. * An event triggered when the scene is disposed.
  95048. */
  95049. onDisposeObservable: Observable<Scene>;
  95050. private _onDisposeObserver;
  95051. /** Sets a function to be executed when this scene is disposed. */
  95052. onDispose: () => void;
  95053. /**
  95054. * An event triggered before rendering the scene (right after animations and physics)
  95055. */
  95056. onBeforeRenderObservable: Observable<Scene>;
  95057. private _onBeforeRenderObserver;
  95058. /** Sets a function to be executed before rendering this scene */
  95059. beforeRender: Nullable<() => void>;
  95060. /**
  95061. * An event triggered after rendering the scene
  95062. */
  95063. onAfterRenderObservable: Observable<Scene>;
  95064. /**
  95065. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95066. */
  95067. onAfterRenderCameraObservable: Observable<Camera>;
  95068. private _onAfterRenderObserver;
  95069. /** Sets a function to be executed after rendering this scene */
  95070. afterRender: Nullable<() => void>;
  95071. /**
  95072. * An event triggered before animating the scene
  95073. */
  95074. onBeforeAnimationsObservable: Observable<Scene>;
  95075. /**
  95076. * An event triggered after animations processing
  95077. */
  95078. onAfterAnimationsObservable: Observable<Scene>;
  95079. /**
  95080. * An event triggered before draw calls are ready to be sent
  95081. */
  95082. onBeforeDrawPhaseObservable: Observable<Scene>;
  95083. /**
  95084. * An event triggered after draw calls have been sent
  95085. */
  95086. onAfterDrawPhaseObservable: Observable<Scene>;
  95087. /**
  95088. * An event triggered when the scene is ready
  95089. */
  95090. onReadyObservable: Observable<Scene>;
  95091. /**
  95092. * An event triggered before rendering a camera
  95093. */
  95094. onBeforeCameraRenderObservable: Observable<Camera>;
  95095. private _onBeforeCameraRenderObserver;
  95096. /** Sets a function to be executed before rendering a camera*/
  95097. beforeCameraRender: () => void;
  95098. /**
  95099. * An event triggered after rendering a camera
  95100. */
  95101. onAfterCameraRenderObservable: Observable<Camera>;
  95102. private _onAfterCameraRenderObserver;
  95103. /** Sets a function to be executed after rendering a camera*/
  95104. afterCameraRender: () => void;
  95105. /**
  95106. * An event triggered when active meshes evaluation is about to start
  95107. */
  95108. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95109. /**
  95110. * An event triggered when active meshes evaluation is done
  95111. */
  95112. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95113. /**
  95114. * An event triggered when particles rendering is about to start
  95115. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95116. */
  95117. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95118. /**
  95119. * An event triggered when particles rendering is done
  95120. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95121. */
  95122. onAfterParticlesRenderingObservable: Observable<Scene>;
  95123. /**
  95124. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95125. */
  95126. onDataLoadedObservable: Observable<Scene>;
  95127. /**
  95128. * An event triggered when a camera is created
  95129. */
  95130. onNewCameraAddedObservable: Observable<Camera>;
  95131. /**
  95132. * An event triggered when a camera is removed
  95133. */
  95134. onCameraRemovedObservable: Observable<Camera>;
  95135. /**
  95136. * An event triggered when a light is created
  95137. */
  95138. onNewLightAddedObservable: Observable<Light>;
  95139. /**
  95140. * An event triggered when a light is removed
  95141. */
  95142. onLightRemovedObservable: Observable<Light>;
  95143. /**
  95144. * An event triggered when a geometry is created
  95145. */
  95146. onNewGeometryAddedObservable: Observable<Geometry>;
  95147. /**
  95148. * An event triggered when a geometry is removed
  95149. */
  95150. onGeometryRemovedObservable: Observable<Geometry>;
  95151. /**
  95152. * An event triggered when a transform node is created
  95153. */
  95154. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95155. /**
  95156. * An event triggered when a transform node is removed
  95157. */
  95158. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95159. /**
  95160. * An event triggered when a mesh is created
  95161. */
  95162. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95163. /**
  95164. * An event triggered when a mesh is removed
  95165. */
  95166. onMeshRemovedObservable: Observable<AbstractMesh>;
  95167. /**
  95168. * An event triggered when a skeleton is created
  95169. */
  95170. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95171. /**
  95172. * An event triggered when a skeleton is removed
  95173. */
  95174. onSkeletonRemovedObservable: Observable<Skeleton>;
  95175. /**
  95176. * An event triggered when a material is created
  95177. */
  95178. onNewMaterialAddedObservable: Observable<Material>;
  95179. /**
  95180. * An event triggered when a material is removed
  95181. */
  95182. onMaterialRemovedObservable: Observable<Material>;
  95183. /**
  95184. * An event triggered when a texture is created
  95185. */
  95186. onNewTextureAddedObservable: Observable<BaseTexture>;
  95187. /**
  95188. * An event triggered when a texture is removed
  95189. */
  95190. onTextureRemovedObservable: Observable<BaseTexture>;
  95191. /**
  95192. * An event triggered when render targets are about to be rendered
  95193. * Can happen multiple times per frame.
  95194. */
  95195. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95196. /**
  95197. * An event triggered when render targets were rendered.
  95198. * Can happen multiple times per frame.
  95199. */
  95200. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95201. /**
  95202. * An event triggered before calculating deterministic simulation step
  95203. */
  95204. onBeforeStepObservable: Observable<Scene>;
  95205. /**
  95206. * An event triggered after calculating deterministic simulation step
  95207. */
  95208. onAfterStepObservable: Observable<Scene>;
  95209. /**
  95210. * An event triggered when the activeCamera property is updated
  95211. */
  95212. onActiveCameraChanged: Observable<Scene>;
  95213. /**
  95214. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95215. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95216. * 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)
  95217. */
  95218. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95219. /**
  95220. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95221. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95222. * 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)
  95223. */
  95224. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95225. /**
  95226. * This Observable will when a mesh has been imported into the scene.
  95227. */
  95228. onMeshImportedObservable: Observable<AbstractMesh>;
  95229. /**
  95230. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95231. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95232. */
  95233. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95234. /** @hidden */
  95235. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95236. /**
  95237. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95238. */
  95239. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95240. /**
  95241. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95242. */
  95243. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95244. /**
  95245. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95246. */
  95247. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95248. /** Callback called when a pointer move is detected */
  95249. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95250. /** Callback called when a pointer down is detected */
  95251. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95252. /** Callback called when a pointer up is detected */
  95253. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95254. /** Callback called when a pointer pick is detected */
  95255. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95256. /**
  95257. * 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).
  95258. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95259. */
  95260. onPrePointerObservable: Observable<PointerInfoPre>;
  95261. /**
  95262. * Observable event triggered each time an input event is received from the rendering canvas
  95263. */
  95264. onPointerObservable: Observable<PointerInfo>;
  95265. /**
  95266. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95267. */
  95268. readonly unTranslatedPointer: Vector2;
  95269. /**
  95270. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95271. */
  95272. static DragMovementThreshold: number;
  95273. /**
  95274. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95275. */
  95276. static LongPressDelay: number;
  95277. /**
  95278. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95279. */
  95280. static DoubleClickDelay: number;
  95281. /** If you need to check double click without raising a single click at first click, enable this flag */
  95282. static ExclusiveDoubleClickMode: boolean;
  95283. /** @hidden */
  95284. _mirroredCameraPosition: Nullable<Vector3>;
  95285. /**
  95286. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95287. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95288. */
  95289. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95290. /**
  95291. * Observable event triggered each time an keyboard event is received from the hosting window
  95292. */
  95293. onKeyboardObservable: Observable<KeyboardInfo>;
  95294. private _useRightHandedSystem;
  95295. /**
  95296. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95297. */
  95298. useRightHandedSystem: boolean;
  95299. private _timeAccumulator;
  95300. private _currentStepId;
  95301. private _currentInternalStep;
  95302. /**
  95303. * Sets the step Id used by deterministic lock step
  95304. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95305. * @param newStepId defines the step Id
  95306. */
  95307. setStepId(newStepId: number): void;
  95308. /**
  95309. * Gets the step Id used by deterministic lock step
  95310. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95311. * @returns the step Id
  95312. */
  95313. getStepId(): number;
  95314. /**
  95315. * Gets the internal step used by deterministic lock step
  95316. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95317. * @returns the internal step
  95318. */
  95319. getInternalStep(): number;
  95320. private _fogEnabled;
  95321. /**
  95322. * Gets or sets a boolean indicating if fog is enabled on this scene
  95323. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95324. * (Default is true)
  95325. */
  95326. fogEnabled: boolean;
  95327. private _fogMode;
  95328. /**
  95329. * Gets or sets the fog mode to use
  95330. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95331. * | mode | value |
  95332. * | --- | --- |
  95333. * | FOGMODE_NONE | 0 |
  95334. * | FOGMODE_EXP | 1 |
  95335. * | FOGMODE_EXP2 | 2 |
  95336. * | FOGMODE_LINEAR | 3 |
  95337. */
  95338. fogMode: number;
  95339. /**
  95340. * Gets or sets the fog color to use
  95341. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95342. * (Default is Color3(0.2, 0.2, 0.3))
  95343. */
  95344. fogColor: Color3;
  95345. /**
  95346. * Gets or sets the fog density to use
  95347. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95348. * (Default is 0.1)
  95349. */
  95350. fogDensity: number;
  95351. /**
  95352. * Gets or sets the fog start distance to use
  95353. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95354. * (Default is 0)
  95355. */
  95356. fogStart: number;
  95357. /**
  95358. * Gets or sets the fog end distance to use
  95359. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95360. * (Default is 1000)
  95361. */
  95362. fogEnd: number;
  95363. private _shadowsEnabled;
  95364. /**
  95365. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95366. */
  95367. shadowsEnabled: boolean;
  95368. private _lightsEnabled;
  95369. /**
  95370. * Gets or sets a boolean indicating if lights are enabled on this scene
  95371. */
  95372. lightsEnabled: boolean;
  95373. /** All of the active cameras added to this scene. */
  95374. activeCameras: Camera[];
  95375. /** @hidden */
  95376. _activeCamera: Nullable<Camera>;
  95377. /** Gets or sets the current active camera */
  95378. activeCamera: Nullable<Camera>;
  95379. private _defaultMaterial;
  95380. /** The default material used on meshes when no material is affected */
  95381. /** The default material used on meshes when no material is affected */
  95382. defaultMaterial: Material;
  95383. private _texturesEnabled;
  95384. /**
  95385. * Gets or sets a boolean indicating if textures are enabled on this scene
  95386. */
  95387. texturesEnabled: boolean;
  95388. /**
  95389. * Gets or sets a boolean indicating if particles are enabled on this scene
  95390. */
  95391. particlesEnabled: boolean;
  95392. /**
  95393. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95394. */
  95395. spritesEnabled: boolean;
  95396. private _skeletonsEnabled;
  95397. /**
  95398. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95399. */
  95400. skeletonsEnabled: boolean;
  95401. /**
  95402. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95403. */
  95404. lensFlaresEnabled: boolean;
  95405. /**
  95406. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95408. */
  95409. collisionsEnabled: boolean;
  95410. private _collisionCoordinator;
  95411. /** @hidden */
  95412. readonly collisionCoordinator: ICollisionCoordinator;
  95413. /**
  95414. * Defines the gravity applied to this scene (used only for collisions)
  95415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95416. */
  95417. gravity: Vector3;
  95418. /**
  95419. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95420. */
  95421. postProcessesEnabled: boolean;
  95422. /**
  95423. * The list of postprocesses added to the scene
  95424. */
  95425. postProcesses: PostProcess[];
  95426. /**
  95427. * Gets the current postprocess manager
  95428. */
  95429. postProcessManager: PostProcessManager;
  95430. /**
  95431. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95432. */
  95433. renderTargetsEnabled: boolean;
  95434. /**
  95435. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95436. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95437. */
  95438. dumpNextRenderTargets: boolean;
  95439. /**
  95440. * The list of user defined render targets added to the scene
  95441. */
  95442. customRenderTargets: RenderTargetTexture[];
  95443. /**
  95444. * Defines if texture loading must be delayed
  95445. * If true, textures will only be loaded when they need to be rendered
  95446. */
  95447. useDelayedTextureLoading: boolean;
  95448. /**
  95449. * Gets the list of meshes imported to the scene through SceneLoader
  95450. */
  95451. importedMeshesFiles: String[];
  95452. /**
  95453. * Gets or sets a boolean indicating if probes are enabled on this scene
  95454. */
  95455. probesEnabled: boolean;
  95456. /**
  95457. * Gets or sets the current offline provider to use to store scene data
  95458. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95459. */
  95460. offlineProvider: IOfflineProvider;
  95461. /**
  95462. * Gets or sets the action manager associated with the scene
  95463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95464. */
  95465. actionManager: AbstractActionManager;
  95466. private _meshesForIntersections;
  95467. /**
  95468. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95469. */
  95470. proceduralTexturesEnabled: boolean;
  95471. private _engine;
  95472. private _totalVertices;
  95473. /** @hidden */
  95474. _activeIndices: PerfCounter;
  95475. /** @hidden */
  95476. _activeParticles: PerfCounter;
  95477. /** @hidden */
  95478. _activeBones: PerfCounter;
  95479. private _animationRatio;
  95480. /** @hidden */
  95481. _animationTimeLast: number;
  95482. /** @hidden */
  95483. _animationTime: number;
  95484. /**
  95485. * Gets or sets a general scale for animation speed
  95486. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95487. */
  95488. animationTimeScale: number;
  95489. /** @hidden */
  95490. _cachedMaterial: Nullable<Material>;
  95491. /** @hidden */
  95492. _cachedEffect: Nullable<Effect>;
  95493. /** @hidden */
  95494. _cachedVisibility: Nullable<number>;
  95495. private _renderId;
  95496. private _frameId;
  95497. private _executeWhenReadyTimeoutId;
  95498. private _intermediateRendering;
  95499. private _viewUpdateFlag;
  95500. private _projectionUpdateFlag;
  95501. /** @hidden */
  95502. _toBeDisposed: Nullable<IDisposable>[];
  95503. private _activeRequests;
  95504. /** @hidden */
  95505. _pendingData: any[];
  95506. private _isDisposed;
  95507. /**
  95508. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95509. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95510. */
  95511. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95512. private _activeMeshes;
  95513. private _processedMaterials;
  95514. private _renderTargets;
  95515. /** @hidden */
  95516. _activeParticleSystems: SmartArray<IParticleSystem>;
  95517. private _activeSkeletons;
  95518. private _softwareSkinnedMeshes;
  95519. private _renderingManager;
  95520. /** @hidden */
  95521. _activeAnimatables: Animatable[];
  95522. private _transformMatrix;
  95523. private _sceneUbo;
  95524. /** @hidden */
  95525. _viewMatrix: Matrix;
  95526. private _projectionMatrix;
  95527. /** @hidden */
  95528. _forcedViewPosition: Nullable<Vector3>;
  95529. /** @hidden */
  95530. _frustumPlanes: Plane[];
  95531. /**
  95532. * Gets the list of frustum planes (built from the active camera)
  95533. */
  95534. readonly frustumPlanes: Plane[];
  95535. /**
  95536. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95537. * This is useful if there are more lights that the maximum simulteanous authorized
  95538. */
  95539. requireLightSorting: boolean;
  95540. /** @hidden */
  95541. readonly useMaterialMeshMap: boolean;
  95542. /** @hidden */
  95543. readonly useClonedMeshhMap: boolean;
  95544. private _externalData;
  95545. private _uid;
  95546. /**
  95547. * @hidden
  95548. * Backing store of defined scene components.
  95549. */
  95550. _components: ISceneComponent[];
  95551. /**
  95552. * @hidden
  95553. * Backing store of defined scene components.
  95554. */
  95555. _serializableComponents: ISceneSerializableComponent[];
  95556. /**
  95557. * List of components to register on the next registration step.
  95558. */
  95559. private _transientComponents;
  95560. /**
  95561. * Registers the transient components if needed.
  95562. */
  95563. private _registerTransientComponents;
  95564. /**
  95565. * @hidden
  95566. * Add a component to the scene.
  95567. * Note that the ccomponent could be registered on th next frame if this is called after
  95568. * the register component stage.
  95569. * @param component Defines the component to add to the scene
  95570. */
  95571. _addComponent(component: ISceneComponent): void;
  95572. /**
  95573. * @hidden
  95574. * Gets a component from the scene.
  95575. * @param name defines the name of the component to retrieve
  95576. * @returns the component or null if not present
  95577. */
  95578. _getComponent(name: string): Nullable<ISceneComponent>;
  95579. /**
  95580. * @hidden
  95581. * Defines the actions happening before camera updates.
  95582. */
  95583. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95584. /**
  95585. * @hidden
  95586. * Defines the actions happening before clear the canvas.
  95587. */
  95588. _beforeClearStage: Stage<SimpleStageAction>;
  95589. /**
  95590. * @hidden
  95591. * Defines the actions when collecting render targets for the frame.
  95592. */
  95593. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95594. /**
  95595. * @hidden
  95596. * Defines the actions happening for one camera in the frame.
  95597. */
  95598. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95599. /**
  95600. * @hidden
  95601. * Defines the actions happening during the per mesh ready checks.
  95602. */
  95603. _isReadyForMeshStage: Stage<MeshStageAction>;
  95604. /**
  95605. * @hidden
  95606. * Defines the actions happening before evaluate active mesh checks.
  95607. */
  95608. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95609. /**
  95610. * @hidden
  95611. * Defines the actions happening during the evaluate sub mesh checks.
  95612. */
  95613. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95614. /**
  95615. * @hidden
  95616. * Defines the actions happening during the active mesh stage.
  95617. */
  95618. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95619. /**
  95620. * @hidden
  95621. * Defines the actions happening during the per camera render target step.
  95622. */
  95623. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95624. /**
  95625. * @hidden
  95626. * Defines the actions happening just before the active camera is drawing.
  95627. */
  95628. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95629. /**
  95630. * @hidden
  95631. * Defines the actions happening just before a render target is drawing.
  95632. */
  95633. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95634. /**
  95635. * @hidden
  95636. * Defines the actions happening just before a rendering group is drawing.
  95637. */
  95638. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95639. /**
  95640. * @hidden
  95641. * Defines the actions happening just before a mesh is drawing.
  95642. */
  95643. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95644. /**
  95645. * @hidden
  95646. * Defines the actions happening just after a mesh has been drawn.
  95647. */
  95648. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95649. /**
  95650. * @hidden
  95651. * Defines the actions happening just after a rendering group has been drawn.
  95652. */
  95653. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95654. /**
  95655. * @hidden
  95656. * Defines the actions happening just after the active camera has been drawn.
  95657. */
  95658. _afterCameraDrawStage: Stage<CameraStageAction>;
  95659. /**
  95660. * @hidden
  95661. * Defines the actions happening just after a render target has been drawn.
  95662. */
  95663. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95664. /**
  95665. * @hidden
  95666. * Defines the actions happening just after rendering all cameras and computing intersections.
  95667. */
  95668. _afterRenderStage: Stage<SimpleStageAction>;
  95669. /**
  95670. * @hidden
  95671. * Defines the actions happening when a pointer move event happens.
  95672. */
  95673. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95674. /**
  95675. * @hidden
  95676. * Defines the actions happening when a pointer down event happens.
  95677. */
  95678. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95679. /**
  95680. * @hidden
  95681. * Defines the actions happening when a pointer up event happens.
  95682. */
  95683. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95684. /**
  95685. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95686. */
  95687. private geometriesByUniqueId;
  95688. /**
  95689. * Creates a new Scene
  95690. * @param engine defines the engine to use to render this scene
  95691. * @param options defines the scene options
  95692. */
  95693. constructor(engine: Engine, options?: SceneOptions);
  95694. /**
  95695. * Gets a string idenfifying the name of the class
  95696. * @returns "Scene" string
  95697. */
  95698. getClassName(): string;
  95699. private _defaultMeshCandidates;
  95700. /**
  95701. * @hidden
  95702. */
  95703. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95704. private _defaultSubMeshCandidates;
  95705. /**
  95706. * @hidden
  95707. */
  95708. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95709. /**
  95710. * Sets the default candidate providers for the scene.
  95711. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95712. * and getCollidingSubMeshCandidates to their default function
  95713. */
  95714. setDefaultCandidateProviders(): void;
  95715. /**
  95716. * Gets the mesh that is currently under the pointer
  95717. */
  95718. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95719. /**
  95720. * Gets or sets the current on-screen X position of the pointer
  95721. */
  95722. pointerX: number;
  95723. /**
  95724. * Gets or sets the current on-screen Y position of the pointer
  95725. */
  95726. pointerY: number;
  95727. /**
  95728. * Gets the cached material (ie. the latest rendered one)
  95729. * @returns the cached material
  95730. */
  95731. getCachedMaterial(): Nullable<Material>;
  95732. /**
  95733. * Gets the cached effect (ie. the latest rendered one)
  95734. * @returns the cached effect
  95735. */
  95736. getCachedEffect(): Nullable<Effect>;
  95737. /**
  95738. * Gets the cached visibility state (ie. the latest rendered one)
  95739. * @returns the cached visibility state
  95740. */
  95741. getCachedVisibility(): Nullable<number>;
  95742. /**
  95743. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95744. * @param material defines the current material
  95745. * @param effect defines the current effect
  95746. * @param visibility defines the current visibility state
  95747. * @returns true if one parameter is not cached
  95748. */
  95749. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95750. /**
  95751. * Gets the engine associated with the scene
  95752. * @returns an Engine
  95753. */
  95754. getEngine(): Engine;
  95755. /**
  95756. * Gets the total number of vertices rendered per frame
  95757. * @returns the total number of vertices rendered per frame
  95758. */
  95759. getTotalVertices(): number;
  95760. /**
  95761. * Gets the performance counter for total vertices
  95762. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95763. */
  95764. readonly totalVerticesPerfCounter: PerfCounter;
  95765. /**
  95766. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95767. * @returns the total number of active indices rendered per frame
  95768. */
  95769. getActiveIndices(): number;
  95770. /**
  95771. * Gets the performance counter for active indices
  95772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95773. */
  95774. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95775. /**
  95776. * Gets the total number of active particles rendered per frame
  95777. * @returns the total number of active particles rendered per frame
  95778. */
  95779. getActiveParticles(): number;
  95780. /**
  95781. * Gets the performance counter for active particles
  95782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95783. */
  95784. readonly activeParticlesPerfCounter: PerfCounter;
  95785. /**
  95786. * Gets the total number of active bones rendered per frame
  95787. * @returns the total number of active bones rendered per frame
  95788. */
  95789. getActiveBones(): number;
  95790. /**
  95791. * Gets the performance counter for active bones
  95792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95793. */
  95794. readonly activeBonesPerfCounter: PerfCounter;
  95795. /**
  95796. * Gets the array of active meshes
  95797. * @returns an array of AbstractMesh
  95798. */
  95799. getActiveMeshes(): SmartArray<AbstractMesh>;
  95800. /**
  95801. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95802. * @returns a number
  95803. */
  95804. getAnimationRatio(): number;
  95805. /**
  95806. * Gets an unique Id for the current render phase
  95807. * @returns a number
  95808. */
  95809. getRenderId(): number;
  95810. /**
  95811. * Gets an unique Id for the current frame
  95812. * @returns a number
  95813. */
  95814. getFrameId(): number;
  95815. /** Call this function if you want to manually increment the render Id*/
  95816. incrementRenderId(): void;
  95817. private _createUbo;
  95818. /**
  95819. * Use this method to simulate a pointer move on a mesh
  95820. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95821. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95822. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95823. * @returns the current scene
  95824. */
  95825. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95826. /**
  95827. * Use this method to simulate a pointer down on a mesh
  95828. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95829. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95830. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95831. * @returns the current scene
  95832. */
  95833. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95834. /**
  95835. * Use this method to simulate a pointer up on a mesh
  95836. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95837. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95838. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95839. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95840. * @returns the current scene
  95841. */
  95842. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95843. /**
  95844. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95845. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95846. * @returns true if the pointer was captured
  95847. */
  95848. isPointerCaptured(pointerId?: number): boolean;
  95849. /**
  95850. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95851. * @param attachUp defines if you want to attach events to pointerup
  95852. * @param attachDown defines if you want to attach events to pointerdown
  95853. * @param attachMove defines if you want to attach events to pointermove
  95854. */
  95855. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95856. /** Detaches all event handlers*/
  95857. detachControl(): void;
  95858. /**
  95859. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95860. * Delay loaded resources are not taking in account
  95861. * @return true if all required resources are ready
  95862. */
  95863. isReady(): boolean;
  95864. /** Resets all cached information relative to material (including effect and visibility) */
  95865. resetCachedMaterial(): void;
  95866. /**
  95867. * Registers a function to be called before every frame render
  95868. * @param func defines the function to register
  95869. */
  95870. registerBeforeRender(func: () => void): void;
  95871. /**
  95872. * Unregisters a function called before every frame render
  95873. * @param func defines the function to unregister
  95874. */
  95875. unregisterBeforeRender(func: () => void): void;
  95876. /**
  95877. * Registers a function to be called after every frame render
  95878. * @param func defines the function to register
  95879. */
  95880. registerAfterRender(func: () => void): void;
  95881. /**
  95882. * Unregisters a function called after every frame render
  95883. * @param func defines the function to unregister
  95884. */
  95885. unregisterAfterRender(func: () => void): void;
  95886. private _executeOnceBeforeRender;
  95887. /**
  95888. * The provided function will run before render once and will be disposed afterwards.
  95889. * A timeout delay can be provided so that the function will be executed in N ms.
  95890. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95891. * @param func The function to be executed.
  95892. * @param timeout optional delay in ms
  95893. */
  95894. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95895. /** @hidden */
  95896. _addPendingData(data: any): void;
  95897. /** @hidden */
  95898. _removePendingData(data: any): void;
  95899. /**
  95900. * Returns the number of items waiting to be loaded
  95901. * @returns the number of items waiting to be loaded
  95902. */
  95903. getWaitingItemsCount(): number;
  95904. /**
  95905. * Returns a boolean indicating if the scene is still loading data
  95906. */
  95907. readonly isLoading: boolean;
  95908. /**
  95909. * Registers a function to be executed when the scene is ready
  95910. * @param {Function} func - the function to be executed
  95911. */
  95912. executeWhenReady(func: () => void): void;
  95913. /**
  95914. * Returns a promise that resolves when the scene is ready
  95915. * @returns A promise that resolves when the scene is ready
  95916. */
  95917. whenReadyAsync(): Promise<void>;
  95918. /** @hidden */
  95919. _checkIsReady(): void;
  95920. /**
  95921. * Gets all animatable attached to the scene
  95922. */
  95923. readonly animatables: Animatable[];
  95924. /**
  95925. * Resets the last animation time frame.
  95926. * Useful to override when animations start running when loading a scene for the first time.
  95927. */
  95928. resetLastAnimationTimeFrame(): void;
  95929. /**
  95930. * Gets the current view matrix
  95931. * @returns a Matrix
  95932. */
  95933. getViewMatrix(): Matrix;
  95934. /**
  95935. * Gets the current projection matrix
  95936. * @returns a Matrix
  95937. */
  95938. getProjectionMatrix(): Matrix;
  95939. /**
  95940. * Gets the current transform matrix
  95941. * @returns a Matrix made of View * Projection
  95942. */
  95943. getTransformMatrix(): Matrix;
  95944. /**
  95945. * Sets the current transform matrix
  95946. * @param viewL defines the View matrix to use
  95947. * @param projectionL defines the Projection matrix to use
  95948. * @param viewR defines the right View matrix to use (if provided)
  95949. * @param projectionR defines the right Projection matrix to use (if provided)
  95950. */
  95951. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95952. /**
  95953. * Gets the uniform buffer used to store scene data
  95954. * @returns a UniformBuffer
  95955. */
  95956. getSceneUniformBuffer(): UniformBuffer;
  95957. /**
  95958. * Gets an unique (relatively to the current scene) Id
  95959. * @returns an unique number for the scene
  95960. */
  95961. getUniqueId(): number;
  95962. /**
  95963. * Add a mesh to the list of scene's meshes
  95964. * @param newMesh defines the mesh to add
  95965. * @param recursive if all child meshes should also be added to the scene
  95966. */
  95967. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95968. /**
  95969. * Remove a mesh for the list of scene's meshes
  95970. * @param toRemove defines the mesh to remove
  95971. * @param recursive if all child meshes should also be removed from the scene
  95972. * @returns the index where the mesh was in the mesh list
  95973. */
  95974. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95975. /**
  95976. * Add a transform node to the list of scene's transform nodes
  95977. * @param newTransformNode defines the transform node to add
  95978. */
  95979. addTransformNode(newTransformNode: TransformNode): void;
  95980. /**
  95981. * Remove a transform node for the list of scene's transform nodes
  95982. * @param toRemove defines the transform node to remove
  95983. * @returns the index where the transform node was in the transform node list
  95984. */
  95985. removeTransformNode(toRemove: TransformNode): number;
  95986. /**
  95987. * Remove a skeleton for the list of scene's skeletons
  95988. * @param toRemove defines the skeleton to remove
  95989. * @returns the index where the skeleton was in the skeleton list
  95990. */
  95991. removeSkeleton(toRemove: Skeleton): number;
  95992. /**
  95993. * Remove a morph target for the list of scene's morph targets
  95994. * @param toRemove defines the morph target to remove
  95995. * @returns the index where the morph target was in the morph target list
  95996. */
  95997. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95998. /**
  95999. * Remove a light for the list of scene's lights
  96000. * @param toRemove defines the light to remove
  96001. * @returns the index where the light was in the light list
  96002. */
  96003. removeLight(toRemove: Light): number;
  96004. /**
  96005. * Remove a camera for the list of scene's cameras
  96006. * @param toRemove defines the camera to remove
  96007. * @returns the index where the camera was in the camera list
  96008. */
  96009. removeCamera(toRemove: Camera): number;
  96010. /**
  96011. * Remove a particle system for the list of scene's particle systems
  96012. * @param toRemove defines the particle system to remove
  96013. * @returns the index where the particle system was in the particle system list
  96014. */
  96015. removeParticleSystem(toRemove: IParticleSystem): number;
  96016. /**
  96017. * Remove a animation for the list of scene's animations
  96018. * @param toRemove defines the animation to remove
  96019. * @returns the index where the animation was in the animation list
  96020. */
  96021. removeAnimation(toRemove: Animation): number;
  96022. /**
  96023. * Will stop the animation of the given target
  96024. * @param target - the target
  96025. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  96026. * @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)
  96027. */
  96028. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  96029. /**
  96030. * Removes the given animation group from this scene.
  96031. * @param toRemove The animation group to remove
  96032. * @returns The index of the removed animation group
  96033. */
  96034. removeAnimationGroup(toRemove: AnimationGroup): number;
  96035. /**
  96036. * Removes the given multi-material from this scene.
  96037. * @param toRemove The multi-material to remove
  96038. * @returns The index of the removed multi-material
  96039. */
  96040. removeMultiMaterial(toRemove: MultiMaterial): number;
  96041. /**
  96042. * Removes the given material from this scene.
  96043. * @param toRemove The material to remove
  96044. * @returns The index of the removed material
  96045. */
  96046. removeMaterial(toRemove: Material): number;
  96047. /**
  96048. * Removes the given action manager from this scene.
  96049. * @param toRemove The action manager to remove
  96050. * @returns The index of the removed action manager
  96051. */
  96052. removeActionManager(toRemove: AbstractActionManager): number;
  96053. /**
  96054. * Removes the given texture from this scene.
  96055. * @param toRemove The texture to remove
  96056. * @returns The index of the removed texture
  96057. */
  96058. removeTexture(toRemove: BaseTexture): number;
  96059. /**
  96060. * Adds the given light to this scene
  96061. * @param newLight The light to add
  96062. */
  96063. addLight(newLight: Light): void;
  96064. /**
  96065. * Sorts the list list based on light priorities
  96066. */
  96067. sortLightsByPriority(): void;
  96068. /**
  96069. * Adds the given camera to this scene
  96070. * @param newCamera The camera to add
  96071. */
  96072. addCamera(newCamera: Camera): void;
  96073. /**
  96074. * Adds the given skeleton to this scene
  96075. * @param newSkeleton The skeleton to add
  96076. */
  96077. addSkeleton(newSkeleton: Skeleton): void;
  96078. /**
  96079. * Adds the given particle system to this scene
  96080. * @param newParticleSystem The particle system to add
  96081. */
  96082. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96083. /**
  96084. * Adds the given animation to this scene
  96085. * @param newAnimation The animation to add
  96086. */
  96087. addAnimation(newAnimation: Animation): void;
  96088. /**
  96089. * Adds the given animation group to this scene.
  96090. * @param newAnimationGroup The animation group to add
  96091. */
  96092. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96093. /**
  96094. * Adds the given multi-material to this scene
  96095. * @param newMultiMaterial The multi-material to add
  96096. */
  96097. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96098. /**
  96099. * Adds the given material to this scene
  96100. * @param newMaterial The material to add
  96101. */
  96102. addMaterial(newMaterial: Material): void;
  96103. /**
  96104. * Adds the given morph target to this scene
  96105. * @param newMorphTargetManager The morph target to add
  96106. */
  96107. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96108. /**
  96109. * Adds the given geometry to this scene
  96110. * @param newGeometry The geometry to add
  96111. */
  96112. addGeometry(newGeometry: Geometry): void;
  96113. /**
  96114. * Adds the given action manager to this scene
  96115. * @param newActionManager The action manager to add
  96116. */
  96117. addActionManager(newActionManager: AbstractActionManager): void;
  96118. /**
  96119. * Adds the given texture to this scene.
  96120. * @param newTexture The texture to add
  96121. */
  96122. addTexture(newTexture: BaseTexture): void;
  96123. /**
  96124. * Switch active camera
  96125. * @param newCamera defines the new active camera
  96126. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96127. */
  96128. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96129. /**
  96130. * sets the active camera of the scene using its ID
  96131. * @param id defines the camera's ID
  96132. * @return the new active camera or null if none found.
  96133. */
  96134. setActiveCameraByID(id: string): Nullable<Camera>;
  96135. /**
  96136. * sets the active camera of the scene using its name
  96137. * @param name defines the camera's name
  96138. * @returns the new active camera or null if none found.
  96139. */
  96140. setActiveCameraByName(name: string): Nullable<Camera>;
  96141. /**
  96142. * get an animation group using its name
  96143. * @param name defines the material's name
  96144. * @return the animation group or null if none found.
  96145. */
  96146. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96147. /**
  96148. * Get a material using its unique id
  96149. * @param uniqueId defines the material's unique id
  96150. * @return the material or null if none found.
  96151. */
  96152. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96153. /**
  96154. * get a material using its id
  96155. * @param id defines the material's ID
  96156. * @return the material or null if none found.
  96157. */
  96158. getMaterialByID(id: string): Nullable<Material>;
  96159. /**
  96160. * Gets a the last added material using a given id
  96161. * @param id defines the material's ID
  96162. * @return the last material with the given id or null if none found.
  96163. */
  96164. getLastMaterialByID(id: string): Nullable<Material>;
  96165. /**
  96166. * Gets a material using its name
  96167. * @param name defines the material's name
  96168. * @return the material or null if none found.
  96169. */
  96170. getMaterialByName(name: string): Nullable<Material>;
  96171. /**
  96172. * Gets a camera using its id
  96173. * @param id defines the id to look for
  96174. * @returns the camera or null if not found
  96175. */
  96176. getCameraByID(id: string): Nullable<Camera>;
  96177. /**
  96178. * Gets a camera using its unique id
  96179. * @param uniqueId defines the unique id to look for
  96180. * @returns the camera or null if not found
  96181. */
  96182. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96183. /**
  96184. * Gets a camera using its name
  96185. * @param name defines the camera's name
  96186. * @return the camera or null if none found.
  96187. */
  96188. getCameraByName(name: string): Nullable<Camera>;
  96189. /**
  96190. * Gets a bone using its id
  96191. * @param id defines the bone's id
  96192. * @return the bone or null if not found
  96193. */
  96194. getBoneByID(id: string): Nullable<Bone>;
  96195. /**
  96196. * Gets a bone using its id
  96197. * @param name defines the bone's name
  96198. * @return the bone or null if not found
  96199. */
  96200. getBoneByName(name: string): Nullable<Bone>;
  96201. /**
  96202. * Gets a light node using its name
  96203. * @param name defines the the light's name
  96204. * @return the light or null if none found.
  96205. */
  96206. getLightByName(name: string): Nullable<Light>;
  96207. /**
  96208. * Gets a light node using its id
  96209. * @param id defines the light's id
  96210. * @return the light or null if none found.
  96211. */
  96212. getLightByID(id: string): Nullable<Light>;
  96213. /**
  96214. * Gets a light node using its scene-generated unique ID
  96215. * @param uniqueId defines the light's unique id
  96216. * @return the light or null if none found.
  96217. */
  96218. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96219. /**
  96220. * Gets a particle system by id
  96221. * @param id defines the particle system id
  96222. * @return the corresponding system or null if none found
  96223. */
  96224. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96225. /**
  96226. * Gets a geometry using its ID
  96227. * @param id defines the geometry's id
  96228. * @return the geometry or null if none found.
  96229. */
  96230. getGeometryByID(id: string): Nullable<Geometry>;
  96231. private _getGeometryByUniqueID;
  96232. /**
  96233. * Add a new geometry to this scene
  96234. * @param geometry defines the geometry to be added to the scene.
  96235. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96236. * @return a boolean defining if the geometry was added or not
  96237. */
  96238. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96239. /**
  96240. * Removes an existing geometry
  96241. * @param geometry defines the geometry to be removed from the scene
  96242. * @return a boolean defining if the geometry was removed or not
  96243. */
  96244. removeGeometry(geometry: Geometry): boolean;
  96245. /**
  96246. * Gets the list of geometries attached to the scene
  96247. * @returns an array of Geometry
  96248. */
  96249. getGeometries(): Geometry[];
  96250. /**
  96251. * Gets the first added mesh found of a given ID
  96252. * @param id defines the id to search for
  96253. * @return the mesh found or null if not found at all
  96254. */
  96255. getMeshByID(id: string): Nullable<AbstractMesh>;
  96256. /**
  96257. * Gets a list of meshes using their id
  96258. * @param id defines the id to search for
  96259. * @returns a list of meshes
  96260. */
  96261. getMeshesByID(id: string): Array<AbstractMesh>;
  96262. /**
  96263. * Gets the first added transform node found of a given ID
  96264. * @param id defines the id to search for
  96265. * @return the found transform node or null if not found at all.
  96266. */
  96267. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96268. /**
  96269. * Gets a transform node with its auto-generated unique id
  96270. * @param uniqueId efines the unique id to search for
  96271. * @return the found transform node or null if not found at all.
  96272. */
  96273. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96274. /**
  96275. * Gets a list of transform nodes using their id
  96276. * @param id defines the id to search for
  96277. * @returns a list of transform nodes
  96278. */
  96279. getTransformNodesByID(id: string): Array<TransformNode>;
  96280. /**
  96281. * Gets a mesh with its auto-generated unique id
  96282. * @param uniqueId defines the unique id to search for
  96283. * @return the found mesh or null if not found at all.
  96284. */
  96285. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96286. /**
  96287. * Gets a the last added mesh using a given id
  96288. * @param id defines the id to search for
  96289. * @return the found mesh or null if not found at all.
  96290. */
  96291. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96292. /**
  96293. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96294. * @param id defines the id to search for
  96295. * @return the found node or null if not found at all
  96296. */
  96297. getLastEntryByID(id: string): Nullable<Node>;
  96298. /**
  96299. * Gets a node (Mesh, Camera, Light) using a given id
  96300. * @param id defines the id to search for
  96301. * @return the found node or null if not found at all
  96302. */
  96303. getNodeByID(id: string): Nullable<Node>;
  96304. /**
  96305. * Gets a node (Mesh, Camera, Light) using a given name
  96306. * @param name defines the name to search for
  96307. * @return the found node or null if not found at all.
  96308. */
  96309. getNodeByName(name: string): Nullable<Node>;
  96310. /**
  96311. * Gets a mesh using a given name
  96312. * @param name defines the name to search for
  96313. * @return the found mesh or null if not found at all.
  96314. */
  96315. getMeshByName(name: string): Nullable<AbstractMesh>;
  96316. /**
  96317. * Gets a transform node using a given name
  96318. * @param name defines the name to search for
  96319. * @return the found transform node or null if not found at all.
  96320. */
  96321. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96322. /**
  96323. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96324. * @param id defines the id to search for
  96325. * @return the found skeleton or null if not found at all.
  96326. */
  96327. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96328. /**
  96329. * Gets a skeleton using a given auto generated unique id
  96330. * @param uniqueId defines the unique id to search for
  96331. * @return the found skeleton or null if not found at all.
  96332. */
  96333. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96334. /**
  96335. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96336. * @param id defines the id to search for
  96337. * @return the found skeleton or null if not found at all.
  96338. */
  96339. getSkeletonById(id: string): Nullable<Skeleton>;
  96340. /**
  96341. * Gets a skeleton using a given name
  96342. * @param name defines the name to search for
  96343. * @return the found skeleton or null if not found at all.
  96344. */
  96345. getSkeletonByName(name: string): Nullable<Skeleton>;
  96346. /**
  96347. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96348. * @param id defines the id to search for
  96349. * @return the found morph target manager or null if not found at all.
  96350. */
  96351. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96352. /**
  96353. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96354. * @param id defines the id to search for
  96355. * @return the found morph target or null if not found at all.
  96356. */
  96357. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96358. /**
  96359. * Gets a boolean indicating if the given mesh is active
  96360. * @param mesh defines the mesh to look for
  96361. * @returns true if the mesh is in the active list
  96362. */
  96363. isActiveMesh(mesh: AbstractMesh): boolean;
  96364. /**
  96365. * Return a unique id as a string which can serve as an identifier for the scene
  96366. */
  96367. readonly uid: string;
  96368. /**
  96369. * Add an externaly attached data from its key.
  96370. * This method call will fail and return false, if such key already exists.
  96371. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96372. * @param key the unique key that identifies the data
  96373. * @param data the data object to associate to the key for this Engine instance
  96374. * @return true if no such key were already present and the data was added successfully, false otherwise
  96375. */
  96376. addExternalData<T>(key: string, data: T): boolean;
  96377. /**
  96378. * Get an externaly attached data from its key
  96379. * @param key the unique key that identifies the data
  96380. * @return the associated data, if present (can be null), or undefined if not present
  96381. */
  96382. getExternalData<T>(key: string): Nullable<T>;
  96383. /**
  96384. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96385. * @param key the unique key that identifies the data
  96386. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96387. * @return the associated data, can be null if the factory returned null.
  96388. */
  96389. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96390. /**
  96391. * Remove an externaly attached data from the Engine instance
  96392. * @param key the unique key that identifies the data
  96393. * @return true if the data was successfully removed, false if it doesn't exist
  96394. */
  96395. removeExternalData(key: string): boolean;
  96396. private _evaluateSubMesh;
  96397. /**
  96398. * Clear the processed materials smart array preventing retention point in material dispose.
  96399. */
  96400. freeProcessedMaterials(): void;
  96401. private _preventFreeActiveMeshesAndRenderingGroups;
  96402. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96403. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96404. * when disposing several meshes in a row or a hierarchy of meshes.
  96405. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96406. */
  96407. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96408. /**
  96409. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96410. */
  96411. freeActiveMeshes(): void;
  96412. /**
  96413. * Clear the info related to rendering groups preventing retention points during dispose.
  96414. */
  96415. freeRenderingGroups(): void;
  96416. /** @hidden */
  96417. _isInIntermediateRendering(): boolean;
  96418. /**
  96419. * Lambda returning the list of potentially active meshes.
  96420. */
  96421. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96422. /**
  96423. * Lambda returning the list of potentially active sub meshes.
  96424. */
  96425. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96426. /**
  96427. * Lambda returning the list of potentially intersecting sub meshes.
  96428. */
  96429. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96430. /**
  96431. * Lambda returning the list of potentially colliding sub meshes.
  96432. */
  96433. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96434. private _activeMeshesFrozen;
  96435. /**
  96436. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96437. * @returns the current scene
  96438. */
  96439. freezeActiveMeshes(): Scene;
  96440. /**
  96441. * Use this function to restart evaluating active meshes on every frame
  96442. * @returns the current scene
  96443. */
  96444. unfreezeActiveMeshes(): Scene;
  96445. private _evaluateActiveMeshes;
  96446. private _activeMesh;
  96447. /**
  96448. * Update the transform matrix to update from the current active camera
  96449. * @param force defines a boolean used to force the update even if cache is up to date
  96450. */
  96451. updateTransformMatrix(force?: boolean): void;
  96452. private _bindFrameBuffer;
  96453. /** @hidden */
  96454. _allowPostProcessClearColor: boolean;
  96455. /** @hidden */
  96456. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96457. private _processSubCameras;
  96458. private _checkIntersections;
  96459. /** @hidden */
  96460. _advancePhysicsEngineStep(step: number): void;
  96461. /**
  96462. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96463. */
  96464. getDeterministicFrameTime: () => number;
  96465. /** @hidden */
  96466. _animate(): void;
  96467. /** Execute all animations (for a frame) */
  96468. animate(): void;
  96469. /**
  96470. * Render the scene
  96471. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96472. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96473. */
  96474. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96475. /**
  96476. * Freeze all materials
  96477. * A frozen material will not be updatable but should be faster to render
  96478. */
  96479. freezeMaterials(): void;
  96480. /**
  96481. * Unfreeze all materials
  96482. * A frozen material will not be updatable but should be faster to render
  96483. */
  96484. unfreezeMaterials(): void;
  96485. /**
  96486. * Releases all held ressources
  96487. */
  96488. dispose(): void;
  96489. /**
  96490. * Gets if the scene is already disposed
  96491. */
  96492. readonly isDisposed: boolean;
  96493. /**
  96494. * Call this function to reduce memory footprint of the scene.
  96495. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96496. */
  96497. clearCachedVertexData(): void;
  96498. /**
  96499. * This function will remove the local cached buffer data from texture.
  96500. * It will save memory but will prevent the texture from being rebuilt
  96501. */
  96502. cleanCachedTextureBuffer(): void;
  96503. /**
  96504. * Get the world extend vectors with an optional filter
  96505. *
  96506. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96507. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96508. */
  96509. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96510. min: Vector3;
  96511. max: Vector3;
  96512. };
  96513. /**
  96514. * Creates a ray that can be used to pick in the scene
  96515. * @param x defines the x coordinate of the origin (on-screen)
  96516. * @param y defines the y coordinate of the origin (on-screen)
  96517. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96518. * @param camera defines the camera to use for the picking
  96519. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96520. * @returns a Ray
  96521. */
  96522. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96523. /**
  96524. * Creates a ray that can be used to pick in the scene
  96525. * @param x defines the x coordinate of the origin (on-screen)
  96526. * @param y defines the y coordinate of the origin (on-screen)
  96527. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96528. * @param result defines the ray where to store the picking ray
  96529. * @param camera defines the camera to use for the picking
  96530. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96531. * @returns the current scene
  96532. */
  96533. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96534. /**
  96535. * Creates a ray that can be used to pick in the scene
  96536. * @param x defines the x coordinate of the origin (on-screen)
  96537. * @param y defines the y coordinate of the origin (on-screen)
  96538. * @param camera defines the camera to use for the picking
  96539. * @returns a Ray
  96540. */
  96541. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96542. /**
  96543. * Creates a ray that can be used to pick in the scene
  96544. * @param x defines the x coordinate of the origin (on-screen)
  96545. * @param y defines the y coordinate of the origin (on-screen)
  96546. * @param result defines the ray where to store the picking ray
  96547. * @param camera defines the camera to use for the picking
  96548. * @returns the current scene
  96549. */
  96550. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96551. /** Launch a ray to try to pick a mesh in the scene
  96552. * @param x position on screen
  96553. * @param y position on screen
  96554. * @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
  96555. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96556. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96557. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96558. * @returns a PickingInfo
  96559. */
  96560. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96561. /** Use the given ray to pick a mesh in the scene
  96562. * @param ray The ray to use to pick meshes
  96563. * @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
  96564. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96565. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96566. * @returns a PickingInfo
  96567. */
  96568. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96569. /**
  96570. * Launch a ray to try to pick a mesh in the scene
  96571. * @param x X position on screen
  96572. * @param y Y position on screen
  96573. * @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
  96574. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96575. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96576. * @returns an array of PickingInfo
  96577. */
  96578. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96579. /**
  96580. * Launch a ray to try to pick a mesh in the scene
  96581. * @param ray Ray to use
  96582. * @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
  96583. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96584. * @returns an array of PickingInfo
  96585. */
  96586. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96587. /**
  96588. * Force the value of meshUnderPointer
  96589. * @param mesh defines the mesh to use
  96590. */
  96591. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96592. /**
  96593. * Gets the mesh under the pointer
  96594. * @returns a Mesh or null if no mesh is under the pointer
  96595. */
  96596. getPointerOverMesh(): Nullable<AbstractMesh>;
  96597. /** @hidden */
  96598. _rebuildGeometries(): void;
  96599. /** @hidden */
  96600. _rebuildTextures(): void;
  96601. private _getByTags;
  96602. /**
  96603. * Get a list of meshes by tags
  96604. * @param tagsQuery defines the tags query to use
  96605. * @param forEach defines a predicate used to filter results
  96606. * @returns an array of Mesh
  96607. */
  96608. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96609. /**
  96610. * Get a list of cameras by tags
  96611. * @param tagsQuery defines the tags query to use
  96612. * @param forEach defines a predicate used to filter results
  96613. * @returns an array of Camera
  96614. */
  96615. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96616. /**
  96617. * Get a list of lights by tags
  96618. * @param tagsQuery defines the tags query to use
  96619. * @param forEach defines a predicate used to filter results
  96620. * @returns an array of Light
  96621. */
  96622. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96623. /**
  96624. * Get a list of materials by tags
  96625. * @param tagsQuery defines the tags query to use
  96626. * @param forEach defines a predicate used to filter results
  96627. * @returns an array of Material
  96628. */
  96629. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96630. /**
  96631. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96632. * This allowed control for front to back rendering or reversly depending of the special needs.
  96633. *
  96634. * @param renderingGroupId The rendering group id corresponding to its index
  96635. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96636. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96637. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96638. */
  96639. 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;
  96640. /**
  96641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96642. *
  96643. * @param renderingGroupId The rendering group id corresponding to its index
  96644. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96645. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96646. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96647. */
  96648. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96649. /**
  96650. * Gets the current auto clear configuration for one rendering group of the rendering
  96651. * manager.
  96652. * @param index the rendering group index to get the information for
  96653. * @returns The auto clear setup for the requested rendering group
  96654. */
  96655. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96656. private _blockMaterialDirtyMechanism;
  96657. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96658. blockMaterialDirtyMechanism: boolean;
  96659. /**
  96660. * Will flag all materials as dirty to trigger new shader compilation
  96661. * @param flag defines the flag used to specify which material part must be marked as dirty
  96662. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96663. */
  96664. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96665. /** @hidden */
  96666. _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;
  96667. /** @hidden */
  96668. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96669. }
  96670. }
  96671. declare module BABYLON {
  96672. /**
  96673. * Set of assets to keep when moving a scene into an asset container.
  96674. */
  96675. export class KeepAssets extends AbstractScene {
  96676. }
  96677. /**
  96678. * Container with a set of assets that can be added or removed from a scene.
  96679. */
  96680. export class AssetContainer extends AbstractScene {
  96681. /**
  96682. * The scene the AssetContainer belongs to.
  96683. */
  96684. scene: Scene;
  96685. /**
  96686. * Instantiates an AssetContainer.
  96687. * @param scene The scene the AssetContainer belongs to.
  96688. */
  96689. constructor(scene: Scene);
  96690. /**
  96691. * Adds all the assets from the container to the scene.
  96692. */
  96693. addAllToScene(): void;
  96694. /**
  96695. * Removes all the assets in the container from the scene
  96696. */
  96697. removeAllFromScene(): void;
  96698. /**
  96699. * Disposes all the assets in the container
  96700. */
  96701. dispose(): void;
  96702. private _moveAssets;
  96703. /**
  96704. * Removes all the assets contained in the scene and adds them to the container.
  96705. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96706. */
  96707. moveAllFromScene(keepAssets?: KeepAssets): void;
  96708. /**
  96709. * 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.
  96710. * @returns the root mesh
  96711. */
  96712. createRootMesh(): Mesh;
  96713. }
  96714. }
  96715. declare module BABYLON {
  96716. /**
  96717. * Defines how the parser contract is defined.
  96718. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96719. */
  96720. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96721. /**
  96722. * Defines how the individual parser contract is defined.
  96723. * These parser can parse an individual asset
  96724. */
  96725. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96726. /**
  96727. * Base class of the scene acting as a container for the different elements composing a scene.
  96728. * This class is dynamically extended by the different components of the scene increasing
  96729. * flexibility and reducing coupling
  96730. */
  96731. export abstract class AbstractScene {
  96732. /**
  96733. * Stores the list of available parsers in the application.
  96734. */
  96735. private static _BabylonFileParsers;
  96736. /**
  96737. * Stores the list of available individual parsers in the application.
  96738. */
  96739. private static _IndividualBabylonFileParsers;
  96740. /**
  96741. * Adds a parser in the list of available ones
  96742. * @param name Defines the name of the parser
  96743. * @param parser Defines the parser to add
  96744. */
  96745. static AddParser(name: string, parser: BabylonFileParser): void;
  96746. /**
  96747. * Gets a general parser from the list of avaialble ones
  96748. * @param name Defines the name of the parser
  96749. * @returns the requested parser or null
  96750. */
  96751. static GetParser(name: string): Nullable<BabylonFileParser>;
  96752. /**
  96753. * Adds n individual parser in the list of available ones
  96754. * @param name Defines the name of the parser
  96755. * @param parser Defines the parser to add
  96756. */
  96757. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96758. /**
  96759. * Gets an individual parser from the list of avaialble ones
  96760. * @param name Defines the name of the parser
  96761. * @returns the requested parser or null
  96762. */
  96763. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96764. /**
  96765. * Parser json data and populate both a scene and its associated container object
  96766. * @param jsonData Defines the data to parse
  96767. * @param scene Defines the scene to parse the data for
  96768. * @param container Defines the container attached to the parsing sequence
  96769. * @param rootUrl Defines the root url of the data
  96770. */
  96771. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96772. /**
  96773. * Gets the list of root nodes (ie. nodes with no parent)
  96774. */
  96775. rootNodes: Node[];
  96776. /** All of the cameras added to this scene
  96777. * @see http://doc.babylonjs.com/babylon101/cameras
  96778. */
  96779. cameras: Camera[];
  96780. /**
  96781. * All of the lights added to this scene
  96782. * @see http://doc.babylonjs.com/babylon101/lights
  96783. */
  96784. lights: Light[];
  96785. /**
  96786. * All of the (abstract) meshes added to this scene
  96787. */
  96788. meshes: AbstractMesh[];
  96789. /**
  96790. * The list of skeletons added to the scene
  96791. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96792. */
  96793. skeletons: Skeleton[];
  96794. /**
  96795. * All of the particle systems added to this scene
  96796. * @see http://doc.babylonjs.com/babylon101/particles
  96797. */
  96798. particleSystems: IParticleSystem[];
  96799. /**
  96800. * Gets a list of Animations associated with the scene
  96801. */
  96802. animations: Animation[];
  96803. /**
  96804. * All of the animation groups added to this scene
  96805. * @see http://doc.babylonjs.com/how_to/group
  96806. */
  96807. animationGroups: AnimationGroup[];
  96808. /**
  96809. * All of the multi-materials added to this scene
  96810. * @see http://doc.babylonjs.com/how_to/multi_materials
  96811. */
  96812. multiMaterials: MultiMaterial[];
  96813. /**
  96814. * All of the materials added to this scene
  96815. * In the context of a Scene, it is not supposed to be modified manually.
  96816. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96817. * Note also that the order of the Material wihin the array is not significant and might change.
  96818. * @see http://doc.babylonjs.com/babylon101/materials
  96819. */
  96820. materials: Material[];
  96821. /**
  96822. * The list of morph target managers added to the scene
  96823. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96824. */
  96825. morphTargetManagers: MorphTargetManager[];
  96826. /**
  96827. * The list of geometries used in the scene.
  96828. */
  96829. geometries: Geometry[];
  96830. /**
  96831. * All of the tranform nodes added to this scene
  96832. * In the context of a Scene, it is not supposed to be modified manually.
  96833. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96834. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96835. * @see http://doc.babylonjs.com/how_to/transformnode
  96836. */
  96837. transformNodes: TransformNode[];
  96838. /**
  96839. * ActionManagers available on the scene.
  96840. */
  96841. actionManagers: AbstractActionManager[];
  96842. /**
  96843. * Textures to keep.
  96844. */
  96845. textures: BaseTexture[];
  96846. /**
  96847. * Environment texture for the scene
  96848. */
  96849. environmentTexture: Nullable<BaseTexture>;
  96850. }
  96851. }
  96852. declare module BABYLON {
  96853. /**
  96854. * Interface used to define options for Sound class
  96855. */
  96856. export interface ISoundOptions {
  96857. /**
  96858. * Does the sound autoplay once loaded.
  96859. */
  96860. autoplay?: boolean;
  96861. /**
  96862. * Does the sound loop after it finishes playing once.
  96863. */
  96864. loop?: boolean;
  96865. /**
  96866. * Sound's volume
  96867. */
  96868. volume?: number;
  96869. /**
  96870. * Is it a spatial sound?
  96871. */
  96872. spatialSound?: boolean;
  96873. /**
  96874. * Maximum distance to hear that sound
  96875. */
  96876. maxDistance?: number;
  96877. /**
  96878. * Uses user defined attenuation function
  96879. */
  96880. useCustomAttenuation?: boolean;
  96881. /**
  96882. * Define the roll off factor of spatial sounds.
  96883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96884. */
  96885. rolloffFactor?: number;
  96886. /**
  96887. * Define the reference distance the sound should be heard perfectly.
  96888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96889. */
  96890. refDistance?: number;
  96891. /**
  96892. * Define the distance attenuation model the sound will follow.
  96893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96894. */
  96895. distanceModel?: string;
  96896. /**
  96897. * Defines the playback speed (1 by default)
  96898. */
  96899. playbackRate?: number;
  96900. /**
  96901. * Defines if the sound is from a streaming source
  96902. */
  96903. streaming?: boolean;
  96904. /**
  96905. * Defines an optional length (in seconds) inside the sound file
  96906. */
  96907. length?: number;
  96908. /**
  96909. * Defines an optional offset (in seconds) inside the sound file
  96910. */
  96911. offset?: number;
  96912. /**
  96913. * If true, URLs will not be required to state the audio file codec to use.
  96914. */
  96915. skipCodecCheck?: boolean;
  96916. }
  96917. /**
  96918. * Defines a sound that can be played in the application.
  96919. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96921. */
  96922. export class Sound {
  96923. /**
  96924. * The name of the sound in the scene.
  96925. */
  96926. name: string;
  96927. /**
  96928. * Does the sound autoplay once loaded.
  96929. */
  96930. autoplay: boolean;
  96931. /**
  96932. * Does the sound loop after it finishes playing once.
  96933. */
  96934. loop: boolean;
  96935. /**
  96936. * Does the sound use a custom attenuation curve to simulate the falloff
  96937. * happening when the source gets further away from the camera.
  96938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96939. */
  96940. useCustomAttenuation: boolean;
  96941. /**
  96942. * The sound track id this sound belongs to.
  96943. */
  96944. soundTrackId: number;
  96945. /**
  96946. * Is this sound currently played.
  96947. */
  96948. isPlaying: boolean;
  96949. /**
  96950. * Is this sound currently paused.
  96951. */
  96952. isPaused: boolean;
  96953. /**
  96954. * Does this sound enables spatial sound.
  96955. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96956. */
  96957. spatialSound: boolean;
  96958. /**
  96959. * Define the reference distance the sound should be heard perfectly.
  96960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96961. */
  96962. refDistance: number;
  96963. /**
  96964. * Define the roll off factor of spatial sounds.
  96965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96966. */
  96967. rolloffFactor: number;
  96968. /**
  96969. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96971. */
  96972. maxDistance: number;
  96973. /**
  96974. * Define the distance attenuation model the sound will follow.
  96975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96976. */
  96977. distanceModel: string;
  96978. /**
  96979. * @hidden
  96980. * Back Compat
  96981. **/
  96982. onended: () => any;
  96983. /**
  96984. * Observable event when the current playing sound finishes.
  96985. */
  96986. onEndedObservable: Observable<Sound>;
  96987. private _panningModel;
  96988. private _playbackRate;
  96989. private _streaming;
  96990. private _startTime;
  96991. private _startOffset;
  96992. private _position;
  96993. /** @hidden */
  96994. _positionInEmitterSpace: boolean;
  96995. private _localDirection;
  96996. private _volume;
  96997. private _isReadyToPlay;
  96998. private _isDirectional;
  96999. private _readyToPlayCallback;
  97000. private _audioBuffer;
  97001. private _soundSource;
  97002. private _streamingSource;
  97003. private _soundPanner;
  97004. private _soundGain;
  97005. private _inputAudioNode;
  97006. private _outputAudioNode;
  97007. private _coneInnerAngle;
  97008. private _coneOuterAngle;
  97009. private _coneOuterGain;
  97010. private _scene;
  97011. private _connectedTransformNode;
  97012. private _customAttenuationFunction;
  97013. private _registerFunc;
  97014. private _isOutputConnected;
  97015. private _htmlAudioElement;
  97016. private _urlType;
  97017. private _length?;
  97018. private _offset?;
  97019. /** @hidden */
  97020. static _SceneComponentInitialization: (scene: Scene) => void;
  97021. /**
  97022. * Create a sound and attach it to a scene
  97023. * @param name Name of your sound
  97024. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  97025. * @param scene defines the scene the sound belongs to
  97026. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  97027. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  97028. */
  97029. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  97030. /**
  97031. * Release the sound and its associated resources
  97032. */
  97033. dispose(): void;
  97034. /**
  97035. * Gets if the sounds is ready to be played or not.
  97036. * @returns true if ready, otherwise false
  97037. */
  97038. isReady(): boolean;
  97039. private _soundLoaded;
  97040. /**
  97041. * Sets the data of the sound from an audiobuffer
  97042. * @param audioBuffer The audioBuffer containing the data
  97043. */
  97044. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97045. /**
  97046. * Updates the current sounds options such as maxdistance, loop...
  97047. * @param options A JSON object containing values named as the object properties
  97048. */
  97049. updateOptions(options: ISoundOptions): void;
  97050. private _createSpatialParameters;
  97051. private _updateSpatialParameters;
  97052. /**
  97053. * Switch the panning model to HRTF:
  97054. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97056. */
  97057. switchPanningModelToHRTF(): void;
  97058. /**
  97059. * Switch the panning model to Equal Power:
  97060. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97062. */
  97063. switchPanningModelToEqualPower(): void;
  97064. private _switchPanningModel;
  97065. /**
  97066. * Connect this sound to a sound track audio node like gain...
  97067. * @param soundTrackAudioNode the sound track audio node to connect to
  97068. */
  97069. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97070. /**
  97071. * Transform this sound into a directional source
  97072. * @param coneInnerAngle Size of the inner cone in degree
  97073. * @param coneOuterAngle Size of the outer cone in degree
  97074. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97075. */
  97076. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97077. /**
  97078. * Gets or sets the inner angle for the directional cone.
  97079. */
  97080. /**
  97081. * Gets or sets the inner angle for the directional cone.
  97082. */
  97083. directionalConeInnerAngle: number;
  97084. /**
  97085. * Gets or sets the outer angle for the directional cone.
  97086. */
  97087. /**
  97088. * Gets or sets the outer angle for the directional cone.
  97089. */
  97090. directionalConeOuterAngle: number;
  97091. /**
  97092. * Sets the position of the emitter if spatial sound is enabled
  97093. * @param newPosition Defines the new posisiton
  97094. */
  97095. setPosition(newPosition: Vector3): void;
  97096. /**
  97097. * Sets the local direction of the emitter if spatial sound is enabled
  97098. * @param newLocalDirection Defines the new local direction
  97099. */
  97100. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97101. private _updateDirection;
  97102. /** @hidden */
  97103. updateDistanceFromListener(): void;
  97104. /**
  97105. * Sets a new custom attenuation function for the sound.
  97106. * @param callback Defines the function used for the attenuation
  97107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97108. */
  97109. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97110. /**
  97111. * Play the sound
  97112. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97113. * @param offset (optional) Start the sound at a specific time in seconds
  97114. * @param length (optional) Sound duration (in seconds)
  97115. */
  97116. play(time?: number, offset?: number, length?: number): void;
  97117. private _onended;
  97118. /**
  97119. * Stop the sound
  97120. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97121. */
  97122. stop(time?: number): void;
  97123. /**
  97124. * Put the sound in pause
  97125. */
  97126. pause(): void;
  97127. /**
  97128. * Sets a dedicated volume for this sounds
  97129. * @param newVolume Define the new volume of the sound
  97130. * @param time Define time for gradual change to new volume
  97131. */
  97132. setVolume(newVolume: number, time?: number): void;
  97133. /**
  97134. * Set the sound play back rate
  97135. * @param newPlaybackRate Define the playback rate the sound should be played at
  97136. */
  97137. setPlaybackRate(newPlaybackRate: number): void;
  97138. /**
  97139. * Gets the volume of the sound.
  97140. * @returns the volume of the sound
  97141. */
  97142. getVolume(): number;
  97143. /**
  97144. * Attach the sound to a dedicated mesh
  97145. * @param transformNode The transform node to connect the sound with
  97146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97147. */
  97148. attachToMesh(transformNode: TransformNode): void;
  97149. /**
  97150. * Detach the sound from the previously attached mesh
  97151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97152. */
  97153. detachFromMesh(): void;
  97154. private _onRegisterAfterWorldMatrixUpdate;
  97155. /**
  97156. * Clone the current sound in the scene.
  97157. * @returns the new sound clone
  97158. */
  97159. clone(): Nullable<Sound>;
  97160. /**
  97161. * Gets the current underlying audio buffer containing the data
  97162. * @returns the audio buffer
  97163. */
  97164. getAudioBuffer(): Nullable<AudioBuffer>;
  97165. /**
  97166. * Serializes the Sound in a JSON representation
  97167. * @returns the JSON representation of the sound
  97168. */
  97169. serialize(): any;
  97170. /**
  97171. * Parse a JSON representation of a sound to innstantiate in a given scene
  97172. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97173. * @param scene Define the scene the new parsed sound should be created in
  97174. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97175. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97176. * @returns the newly parsed sound
  97177. */
  97178. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97179. }
  97180. }
  97181. declare module BABYLON {
  97182. /**
  97183. * This defines an action helpful to play a defined sound on a triggered action.
  97184. */
  97185. export class PlaySoundAction extends Action {
  97186. private _sound;
  97187. /**
  97188. * Instantiate the action
  97189. * @param triggerOptions defines the trigger options
  97190. * @param sound defines the sound to play
  97191. * @param condition defines the trigger related conditions
  97192. */
  97193. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97194. /** @hidden */
  97195. _prepare(): void;
  97196. /**
  97197. * Execute the action and play the sound.
  97198. */
  97199. execute(): void;
  97200. /**
  97201. * Serializes the actions and its related information.
  97202. * @param parent defines the object to serialize in
  97203. * @returns the serialized object
  97204. */
  97205. serialize(parent: any): any;
  97206. }
  97207. /**
  97208. * This defines an action helpful to stop a defined sound on a triggered action.
  97209. */
  97210. export class StopSoundAction extends Action {
  97211. private _sound;
  97212. /**
  97213. * Instantiate the action
  97214. * @param triggerOptions defines the trigger options
  97215. * @param sound defines the sound to stop
  97216. * @param condition defines the trigger related conditions
  97217. */
  97218. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97219. /** @hidden */
  97220. _prepare(): void;
  97221. /**
  97222. * Execute the action and stop the sound.
  97223. */
  97224. execute(): void;
  97225. /**
  97226. * Serializes the actions and its related information.
  97227. * @param parent defines the object to serialize in
  97228. * @returns the serialized object
  97229. */
  97230. serialize(parent: any): any;
  97231. }
  97232. }
  97233. declare module BABYLON {
  97234. /**
  97235. * This defines an action responsible to change the value of a property
  97236. * by interpolating between its current value and the newly set one once triggered.
  97237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97238. */
  97239. export class InterpolateValueAction extends Action {
  97240. /**
  97241. * Defines the path of the property where the value should be interpolated
  97242. */
  97243. propertyPath: string;
  97244. /**
  97245. * Defines the target value at the end of the interpolation.
  97246. */
  97247. value: any;
  97248. /**
  97249. * Defines the time it will take for the property to interpolate to the value.
  97250. */
  97251. duration: number;
  97252. /**
  97253. * Defines if the other scene animations should be stopped when the action has been triggered
  97254. */
  97255. stopOtherAnimations?: boolean;
  97256. /**
  97257. * Defines a callback raised once the interpolation animation has been done.
  97258. */
  97259. onInterpolationDone?: () => void;
  97260. /**
  97261. * Observable triggered once the interpolation animation has been done.
  97262. */
  97263. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97264. private _target;
  97265. private _effectiveTarget;
  97266. private _property;
  97267. /**
  97268. * Instantiate the action
  97269. * @param triggerOptions defines the trigger options
  97270. * @param target defines the object containing the value to interpolate
  97271. * @param propertyPath defines the path to the property in the target object
  97272. * @param value defines the target value at the end of the interpolation
  97273. * @param duration deines the time it will take for the property to interpolate to the value.
  97274. * @param condition defines the trigger related conditions
  97275. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97276. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97277. */
  97278. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97279. /** @hidden */
  97280. _prepare(): void;
  97281. /**
  97282. * Execute the action starts the value interpolation.
  97283. */
  97284. execute(): void;
  97285. /**
  97286. * Serializes the actions and its related information.
  97287. * @param parent defines the object to serialize in
  97288. * @returns the serialized object
  97289. */
  97290. serialize(parent: any): any;
  97291. }
  97292. }
  97293. declare module BABYLON {
  97294. /**
  97295. * Options allowed during the creation of a sound track.
  97296. */
  97297. export interface ISoundTrackOptions {
  97298. /**
  97299. * The volume the sound track should take during creation
  97300. */
  97301. volume?: number;
  97302. /**
  97303. * Define if the sound track is the main sound track of the scene
  97304. */
  97305. mainTrack?: boolean;
  97306. }
  97307. /**
  97308. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97309. * It will be also used in a future release to apply effects on a specific track.
  97310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97311. */
  97312. export class SoundTrack {
  97313. /**
  97314. * The unique identifier of the sound track in the scene.
  97315. */
  97316. id: number;
  97317. /**
  97318. * The list of sounds included in the sound track.
  97319. */
  97320. soundCollection: Array<Sound>;
  97321. private _outputAudioNode;
  97322. private _scene;
  97323. private _isMainTrack;
  97324. private _connectedAnalyser;
  97325. private _options;
  97326. private _isInitialized;
  97327. /**
  97328. * Creates a new sound track.
  97329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97330. * @param scene Define the scene the sound track belongs to
  97331. * @param options
  97332. */
  97333. constructor(scene: Scene, options?: ISoundTrackOptions);
  97334. private _initializeSoundTrackAudioGraph;
  97335. /**
  97336. * Release the sound track and its associated resources
  97337. */
  97338. dispose(): void;
  97339. /**
  97340. * Adds a sound to this sound track
  97341. * @param sound define the cound to add
  97342. * @ignoreNaming
  97343. */
  97344. AddSound(sound: Sound): void;
  97345. /**
  97346. * Removes a sound to this sound track
  97347. * @param sound define the cound to remove
  97348. * @ignoreNaming
  97349. */
  97350. RemoveSound(sound: Sound): void;
  97351. /**
  97352. * Set a global volume for the full sound track.
  97353. * @param newVolume Define the new volume of the sound track
  97354. */
  97355. setVolume(newVolume: number): void;
  97356. /**
  97357. * Switch the panning model to HRTF:
  97358. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97360. */
  97361. switchPanningModelToHRTF(): void;
  97362. /**
  97363. * Switch the panning model to Equal Power:
  97364. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97366. */
  97367. switchPanningModelToEqualPower(): void;
  97368. /**
  97369. * Connect the sound track to an audio analyser allowing some amazing
  97370. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97372. * @param analyser The analyser to connect to the engine
  97373. */
  97374. connectToAnalyser(analyser: Analyser): void;
  97375. }
  97376. }
  97377. declare module BABYLON {
  97378. interface AbstractScene {
  97379. /**
  97380. * The list of sounds used in the scene.
  97381. */
  97382. sounds: Nullable<Array<Sound>>;
  97383. }
  97384. interface Scene {
  97385. /**
  97386. * @hidden
  97387. * Backing field
  97388. */
  97389. _mainSoundTrack: SoundTrack;
  97390. /**
  97391. * The main sound track played by the scene.
  97392. * It cotains your primary collection of sounds.
  97393. */
  97394. mainSoundTrack: SoundTrack;
  97395. /**
  97396. * The list of sound tracks added to the scene
  97397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97398. */
  97399. soundTracks: Nullable<Array<SoundTrack>>;
  97400. /**
  97401. * Gets a sound using a given name
  97402. * @param name defines the name to search for
  97403. * @return the found sound or null if not found at all.
  97404. */
  97405. getSoundByName(name: string): Nullable<Sound>;
  97406. /**
  97407. * Gets or sets if audio support is enabled
  97408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97409. */
  97410. audioEnabled: boolean;
  97411. /**
  97412. * Gets or sets if audio will be output to headphones
  97413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97414. */
  97415. headphone: boolean;
  97416. }
  97417. /**
  97418. * Defines the sound scene component responsible to manage any sounds
  97419. * in a given scene.
  97420. */
  97421. export class AudioSceneComponent implements ISceneSerializableComponent {
  97422. /**
  97423. * The component name helpfull to identify the component in the list of scene components.
  97424. */
  97425. readonly name: string;
  97426. /**
  97427. * The scene the component belongs to.
  97428. */
  97429. scene: Scene;
  97430. private _audioEnabled;
  97431. /**
  97432. * Gets whether audio is enabled or not.
  97433. * Please use related enable/disable method to switch state.
  97434. */
  97435. readonly audioEnabled: boolean;
  97436. private _headphone;
  97437. /**
  97438. * Gets whether audio is outputing to headphone or not.
  97439. * Please use the according Switch methods to change output.
  97440. */
  97441. readonly headphone: boolean;
  97442. /**
  97443. * Creates a new instance of the component for the given scene
  97444. * @param scene Defines the scene to register the component in
  97445. */
  97446. constructor(scene: Scene);
  97447. /**
  97448. * Registers the component in a given scene
  97449. */
  97450. register(): void;
  97451. /**
  97452. * Rebuilds the elements related to this component in case of
  97453. * context lost for instance.
  97454. */
  97455. rebuild(): void;
  97456. /**
  97457. * Serializes the component data to the specified json object
  97458. * @param serializationObject The object to serialize to
  97459. */
  97460. serialize(serializationObject: any): void;
  97461. /**
  97462. * Adds all the elements from the container to the scene
  97463. * @param container the container holding the elements
  97464. */
  97465. addFromContainer(container: AbstractScene): void;
  97466. /**
  97467. * Removes all the elements in the container from the scene
  97468. * @param container contains the elements to remove
  97469. * @param dispose if the removed element should be disposed (default: false)
  97470. */
  97471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97472. /**
  97473. * Disposes the component and the associated ressources.
  97474. */
  97475. dispose(): void;
  97476. /**
  97477. * Disables audio in the associated scene.
  97478. */
  97479. disableAudio(): void;
  97480. /**
  97481. * Enables audio in the associated scene.
  97482. */
  97483. enableAudio(): void;
  97484. /**
  97485. * Switch audio to headphone output.
  97486. */
  97487. switchAudioModeForHeadphones(): void;
  97488. /**
  97489. * Switch audio to normal speakers.
  97490. */
  97491. switchAudioModeForNormalSpeakers(): void;
  97492. private _afterRender;
  97493. }
  97494. }
  97495. declare module BABYLON {
  97496. /**
  97497. * Wraps one or more Sound objects and selects one with random weight for playback.
  97498. */
  97499. export class WeightedSound {
  97500. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97501. loop: boolean;
  97502. private _coneInnerAngle;
  97503. private _coneOuterAngle;
  97504. private _volume;
  97505. /** A Sound is currently playing. */
  97506. isPlaying: boolean;
  97507. /** A Sound is currently paused. */
  97508. isPaused: boolean;
  97509. private _sounds;
  97510. private _weights;
  97511. private _currentIndex?;
  97512. /**
  97513. * Creates a new WeightedSound from the list of sounds given.
  97514. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97515. * @param sounds Array of Sounds that will be selected from.
  97516. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97517. */
  97518. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97519. /**
  97520. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97521. */
  97522. /**
  97523. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97524. */
  97525. directionalConeInnerAngle: number;
  97526. /**
  97527. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97528. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97529. */
  97530. /**
  97531. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97532. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97533. */
  97534. directionalConeOuterAngle: number;
  97535. /**
  97536. * Playback volume.
  97537. */
  97538. /**
  97539. * Playback volume.
  97540. */
  97541. volume: number;
  97542. private _onended;
  97543. /**
  97544. * Suspend playback
  97545. */
  97546. pause(): void;
  97547. /**
  97548. * Stop playback
  97549. */
  97550. stop(): void;
  97551. /**
  97552. * Start playback.
  97553. * @param startOffset Position the clip head at a specific time in seconds.
  97554. */
  97555. play(startOffset?: number): void;
  97556. }
  97557. }
  97558. declare module BABYLON {
  97559. /**
  97560. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97561. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97562. */
  97563. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97564. /**
  97565. * Gets the name of the behavior.
  97566. */
  97567. readonly name: string;
  97568. /**
  97569. * The easing function used by animations
  97570. */
  97571. static EasingFunction: BackEase;
  97572. /**
  97573. * The easing mode used by animations
  97574. */
  97575. static EasingMode: number;
  97576. /**
  97577. * The duration of the animation, in milliseconds
  97578. */
  97579. transitionDuration: number;
  97580. /**
  97581. * Length of the distance animated by the transition when lower radius is reached
  97582. */
  97583. lowerRadiusTransitionRange: number;
  97584. /**
  97585. * Length of the distance animated by the transition when upper radius is reached
  97586. */
  97587. upperRadiusTransitionRange: number;
  97588. private _autoTransitionRange;
  97589. /**
  97590. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97591. */
  97592. /**
  97593. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97594. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97595. */
  97596. autoTransitionRange: boolean;
  97597. private _attachedCamera;
  97598. private _onAfterCheckInputsObserver;
  97599. private _onMeshTargetChangedObserver;
  97600. /**
  97601. * Initializes the behavior.
  97602. */
  97603. init(): void;
  97604. /**
  97605. * Attaches the behavior to its arc rotate camera.
  97606. * @param camera Defines the camera to attach the behavior to
  97607. */
  97608. attach(camera: ArcRotateCamera): void;
  97609. /**
  97610. * Detaches the behavior from its current arc rotate camera.
  97611. */
  97612. detach(): void;
  97613. private _radiusIsAnimating;
  97614. private _radiusBounceTransition;
  97615. private _animatables;
  97616. private _cachedWheelPrecision;
  97617. /**
  97618. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97619. * @param radiusLimit The limit to check against.
  97620. * @return Bool to indicate if at limit.
  97621. */
  97622. private _isRadiusAtLimit;
  97623. /**
  97624. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97625. * @param radiusDelta The delta by which to animate to. Can be negative.
  97626. */
  97627. private _applyBoundRadiusAnimation;
  97628. /**
  97629. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97630. */
  97631. protected _clearAnimationLocks(): void;
  97632. /**
  97633. * Stops and removes all animations that have been applied to the camera
  97634. */
  97635. stopAllAnimations(): void;
  97636. }
  97637. }
  97638. declare module BABYLON {
  97639. /**
  97640. * 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.
  97641. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97642. */
  97643. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97644. /**
  97645. * Gets the name of the behavior.
  97646. */
  97647. readonly name: string;
  97648. private _mode;
  97649. private _radiusScale;
  97650. private _positionScale;
  97651. private _defaultElevation;
  97652. private _elevationReturnTime;
  97653. private _elevationReturnWaitTime;
  97654. private _zoomStopsAnimation;
  97655. private _framingTime;
  97656. /**
  97657. * The easing function used by animations
  97658. */
  97659. static EasingFunction: ExponentialEase;
  97660. /**
  97661. * The easing mode used by animations
  97662. */
  97663. static EasingMode: number;
  97664. /**
  97665. * Sets the current mode used by the behavior
  97666. */
  97667. /**
  97668. * Gets current mode used by the behavior.
  97669. */
  97670. mode: number;
  97671. /**
  97672. * Sets the scale applied to the radius (1 by default)
  97673. */
  97674. /**
  97675. * Gets the scale applied to the radius
  97676. */
  97677. radiusScale: number;
  97678. /**
  97679. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97680. */
  97681. /**
  97682. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97683. */
  97684. positionScale: number;
  97685. /**
  97686. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97687. * behaviour is triggered, in radians.
  97688. */
  97689. /**
  97690. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97691. * behaviour is triggered, in radians.
  97692. */
  97693. defaultElevation: number;
  97694. /**
  97695. * Sets the time (in milliseconds) taken to return to the default beta position.
  97696. * Negative value indicates camera should not return to default.
  97697. */
  97698. /**
  97699. * Gets the time (in milliseconds) taken to return to the default beta position.
  97700. * Negative value indicates camera should not return to default.
  97701. */
  97702. elevationReturnTime: number;
  97703. /**
  97704. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97705. */
  97706. /**
  97707. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97708. */
  97709. elevationReturnWaitTime: number;
  97710. /**
  97711. * Sets the flag that indicates if user zooming should stop animation.
  97712. */
  97713. /**
  97714. * Gets the flag that indicates if user zooming should stop animation.
  97715. */
  97716. zoomStopsAnimation: boolean;
  97717. /**
  97718. * Sets the transition time when framing the mesh, in milliseconds
  97719. */
  97720. /**
  97721. * Gets the transition time when framing the mesh, in milliseconds
  97722. */
  97723. framingTime: number;
  97724. /**
  97725. * Define if the behavior should automatically change the configured
  97726. * camera limits and sensibilities.
  97727. */
  97728. autoCorrectCameraLimitsAndSensibility: boolean;
  97729. private _onPrePointerObservableObserver;
  97730. private _onAfterCheckInputsObserver;
  97731. private _onMeshTargetChangedObserver;
  97732. private _attachedCamera;
  97733. private _isPointerDown;
  97734. private _lastInteractionTime;
  97735. /**
  97736. * Initializes the behavior.
  97737. */
  97738. init(): void;
  97739. /**
  97740. * Attaches the behavior to its arc rotate camera.
  97741. * @param camera Defines the camera to attach the behavior to
  97742. */
  97743. attach(camera: ArcRotateCamera): void;
  97744. /**
  97745. * Detaches the behavior from its current arc rotate camera.
  97746. */
  97747. detach(): void;
  97748. private _animatables;
  97749. private _betaIsAnimating;
  97750. private _betaTransition;
  97751. private _radiusTransition;
  97752. private _vectorTransition;
  97753. /**
  97754. * Targets the given mesh and updates zoom level accordingly.
  97755. * @param mesh The mesh to target.
  97756. * @param radius Optional. If a cached radius position already exists, overrides default.
  97757. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97758. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97759. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97760. */
  97761. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97762. /**
  97763. * Targets the given mesh with its children and updates zoom level accordingly.
  97764. * @param mesh The mesh to target.
  97765. * @param radius Optional. If a cached radius position already exists, overrides default.
  97766. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97767. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97768. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97769. */
  97770. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97771. /**
  97772. * Targets the given meshes with their children and updates zoom level accordingly.
  97773. * @param meshes The mesh to target.
  97774. * @param radius Optional. If a cached radius position already exists, overrides default.
  97775. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97776. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97777. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97778. */
  97779. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97780. /**
  97781. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97782. * @param minimumWorld Determines the smaller position of the bounding box extend
  97783. * @param maximumWorld Determines the bigger position of the bounding box extend
  97784. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97785. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97786. */
  97787. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97788. /**
  97789. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97790. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97791. * frustum width.
  97792. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97793. * to fully enclose the mesh in the viewing frustum.
  97794. */
  97795. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97796. /**
  97797. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97798. * is automatically returned to its default position (expected to be above ground plane).
  97799. */
  97800. private _maintainCameraAboveGround;
  97801. /**
  97802. * Returns the frustum slope based on the canvas ratio and camera FOV
  97803. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97804. */
  97805. private _getFrustumSlope;
  97806. /**
  97807. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97808. */
  97809. private _clearAnimationLocks;
  97810. /**
  97811. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97812. */
  97813. private _applyUserInteraction;
  97814. /**
  97815. * Stops and removes all animations that have been applied to the camera
  97816. */
  97817. stopAllAnimations(): void;
  97818. /**
  97819. * Gets a value indicating if the user is moving the camera
  97820. */
  97821. readonly isUserIsMoving: boolean;
  97822. /**
  97823. * The camera can move all the way towards the mesh.
  97824. */
  97825. static IgnoreBoundsSizeMode: number;
  97826. /**
  97827. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97828. */
  97829. static FitFrustumSidesMode: number;
  97830. }
  97831. }
  97832. declare module BABYLON {
  97833. /**
  97834. * Base class for Camera Pointer Inputs.
  97835. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97836. * for example usage.
  97837. */
  97838. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97839. /**
  97840. * Defines the camera the input is attached to.
  97841. */
  97842. abstract camera: Camera;
  97843. /**
  97844. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97845. */
  97846. protected _altKey: boolean;
  97847. protected _ctrlKey: boolean;
  97848. protected _metaKey: boolean;
  97849. protected _shiftKey: boolean;
  97850. /**
  97851. * Which mouse buttons were pressed at time of last mouse event.
  97852. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97853. */
  97854. protected _buttonsPressed: number;
  97855. /**
  97856. * Defines the buttons associated with the input to handle camera move.
  97857. */
  97858. buttons: number[];
  97859. /**
  97860. * Attach the input controls to a specific dom element to get the input from.
  97861. * @param element Defines the element the controls should be listened from
  97862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97863. */
  97864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97865. /**
  97866. * Detach the current controls from the specified dom element.
  97867. * @param element Defines the element to stop listening the inputs from
  97868. */
  97869. detachControl(element: Nullable<HTMLElement>): void;
  97870. /**
  97871. * Gets the class name of the current input.
  97872. * @returns the class name
  97873. */
  97874. getClassName(): string;
  97875. /**
  97876. * Get the friendly name associated with the input class.
  97877. * @returns the input friendly name
  97878. */
  97879. getSimpleName(): string;
  97880. /**
  97881. * Called on pointer POINTERDOUBLETAP event.
  97882. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97883. */
  97884. protected onDoubleTap(type: string): void;
  97885. /**
  97886. * Called on pointer POINTERMOVE event if only a single touch is active.
  97887. * Override this method to provide functionality.
  97888. */
  97889. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97890. /**
  97891. * Called on pointer POINTERMOVE event if multiple touches are active.
  97892. * Override this method to provide functionality.
  97893. */
  97894. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97895. /**
  97896. * Called on JS contextmenu event.
  97897. * Override this method to provide functionality.
  97898. */
  97899. protected onContextMenu(evt: PointerEvent): void;
  97900. /**
  97901. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97902. * press.
  97903. * Override this method to provide functionality.
  97904. */
  97905. protected onButtonDown(evt: PointerEvent): void;
  97906. /**
  97907. * Called each time a new POINTERUP event occurs. Ie, for each button
  97908. * release.
  97909. * Override this method to provide functionality.
  97910. */
  97911. protected onButtonUp(evt: PointerEvent): void;
  97912. /**
  97913. * Called when window becomes inactive.
  97914. * Override this method to provide functionality.
  97915. */
  97916. protected onLostFocus(): void;
  97917. private _pointerInput;
  97918. private _observer;
  97919. private _onLostFocus;
  97920. private pointA;
  97921. private pointB;
  97922. }
  97923. }
  97924. declare module BABYLON {
  97925. /**
  97926. * Manage the pointers inputs to control an arc rotate camera.
  97927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97928. */
  97929. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97930. /**
  97931. * Defines the camera the input is attached to.
  97932. */
  97933. camera: ArcRotateCamera;
  97934. /**
  97935. * Gets the class name of the current input.
  97936. * @returns the class name
  97937. */
  97938. getClassName(): string;
  97939. /**
  97940. * Defines the buttons associated with the input to handle camera move.
  97941. */
  97942. buttons: number[];
  97943. /**
  97944. * Defines the pointer angular sensibility along the X axis or how fast is
  97945. * the camera rotating.
  97946. */
  97947. angularSensibilityX: number;
  97948. /**
  97949. * Defines the pointer angular sensibility along the Y axis or how fast is
  97950. * the camera rotating.
  97951. */
  97952. angularSensibilityY: number;
  97953. /**
  97954. * Defines the pointer pinch precision or how fast is the camera zooming.
  97955. */
  97956. pinchPrecision: number;
  97957. /**
  97958. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97959. * from 0.
  97960. * It defines the percentage of current camera.radius to use as delta when
  97961. * pinch zoom is used.
  97962. */
  97963. pinchDeltaPercentage: number;
  97964. /**
  97965. * Defines the pointer panning sensibility or how fast is the camera moving.
  97966. */
  97967. panningSensibility: number;
  97968. /**
  97969. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97970. */
  97971. multiTouchPanning: boolean;
  97972. /**
  97973. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97974. * zoom (pinch) through multitouch.
  97975. */
  97976. multiTouchPanAndZoom: boolean;
  97977. /**
  97978. * Revers pinch action direction.
  97979. */
  97980. pinchInwards: boolean;
  97981. private _isPanClick;
  97982. private _twoFingerActivityCount;
  97983. private _isPinching;
  97984. /**
  97985. * Called on pointer POINTERMOVE event if only a single touch is active.
  97986. */
  97987. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97988. /**
  97989. * Called on pointer POINTERDOUBLETAP event.
  97990. */
  97991. protected onDoubleTap(type: string): void;
  97992. /**
  97993. * Called on pointer POINTERMOVE event if multiple touches are active.
  97994. */
  97995. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97996. /**
  97997. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97998. * press.
  97999. */
  98000. protected onButtonDown(evt: PointerEvent): void;
  98001. /**
  98002. * Called each time a new POINTERUP event occurs. Ie, for each button
  98003. * release.
  98004. */
  98005. protected onButtonUp(evt: PointerEvent): void;
  98006. /**
  98007. * Called when window becomes inactive.
  98008. */
  98009. protected onLostFocus(): void;
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  98015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98016. */
  98017. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  98018. /**
  98019. * Defines the camera the input is attached to.
  98020. */
  98021. camera: ArcRotateCamera;
  98022. /**
  98023. * Defines the list of key codes associated with the up action (increase alpha)
  98024. */
  98025. keysUp: number[];
  98026. /**
  98027. * Defines the list of key codes associated with the down action (decrease alpha)
  98028. */
  98029. keysDown: number[];
  98030. /**
  98031. * Defines the list of key codes associated with the left action (increase beta)
  98032. */
  98033. keysLeft: number[];
  98034. /**
  98035. * Defines the list of key codes associated with the right action (decrease beta)
  98036. */
  98037. keysRight: number[];
  98038. /**
  98039. * Defines the list of key codes associated with the reset action.
  98040. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  98041. */
  98042. keysReset: number[];
  98043. /**
  98044. * Defines the panning sensibility of the inputs.
  98045. * (How fast is the camera paning)
  98046. */
  98047. panningSensibility: number;
  98048. /**
  98049. * Defines the zooming sensibility of the inputs.
  98050. * (How fast is the camera zooming)
  98051. */
  98052. zoomingSensibility: number;
  98053. /**
  98054. * Defines wether maintaining the alt key down switch the movement mode from
  98055. * orientation to zoom.
  98056. */
  98057. useAltToZoom: boolean;
  98058. /**
  98059. * Rotation speed of the camera
  98060. */
  98061. angularSpeed: number;
  98062. private _keys;
  98063. private _ctrlPressed;
  98064. private _altPressed;
  98065. private _onCanvasBlurObserver;
  98066. private _onKeyboardObserver;
  98067. private _engine;
  98068. private _scene;
  98069. /**
  98070. * Attach the input controls to a specific dom element to get the input from.
  98071. * @param element Defines the element the controls should be listened from
  98072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98073. */
  98074. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98075. /**
  98076. * Detach the current controls from the specified dom element.
  98077. * @param element Defines the element to stop listening the inputs from
  98078. */
  98079. detachControl(element: Nullable<HTMLElement>): void;
  98080. /**
  98081. * Update the current camera state depending on the inputs that have been used this frame.
  98082. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98083. */
  98084. checkInputs(): void;
  98085. /**
  98086. * Gets the class name of the current intput.
  98087. * @returns the class name
  98088. */
  98089. getClassName(): string;
  98090. /**
  98091. * Get the friendly name associated with the input class.
  98092. * @returns the input friendly name
  98093. */
  98094. getSimpleName(): string;
  98095. }
  98096. }
  98097. declare module BABYLON {
  98098. /**
  98099. * Manage the mouse wheel inputs to control an arc rotate camera.
  98100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98101. */
  98102. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98103. /**
  98104. * Defines the camera the input is attached to.
  98105. */
  98106. camera: ArcRotateCamera;
  98107. /**
  98108. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98109. */
  98110. wheelPrecision: number;
  98111. /**
  98112. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98113. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98114. */
  98115. wheelDeltaPercentage: number;
  98116. private _wheel;
  98117. private _observer;
  98118. private computeDeltaFromMouseWheelLegacyEvent;
  98119. /**
  98120. * Attach the input controls to a specific dom element to get the input from.
  98121. * @param element Defines the element the controls should be listened from
  98122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98123. */
  98124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98125. /**
  98126. * Detach the current controls from the specified dom element.
  98127. * @param element Defines the element to stop listening the inputs from
  98128. */
  98129. detachControl(element: Nullable<HTMLElement>): void;
  98130. /**
  98131. * Gets the class name of the current intput.
  98132. * @returns the class name
  98133. */
  98134. getClassName(): string;
  98135. /**
  98136. * Get the friendly name associated with the input class.
  98137. * @returns the input friendly name
  98138. */
  98139. getSimpleName(): string;
  98140. }
  98141. }
  98142. declare module BABYLON {
  98143. /**
  98144. * Default Inputs manager for the ArcRotateCamera.
  98145. * It groups all the default supported inputs for ease of use.
  98146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98147. */
  98148. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98149. /**
  98150. * Instantiates a new ArcRotateCameraInputsManager.
  98151. * @param camera Defines the camera the inputs belong to
  98152. */
  98153. constructor(camera: ArcRotateCamera);
  98154. /**
  98155. * Add mouse wheel input support to the input manager.
  98156. * @returns the current input manager
  98157. */
  98158. addMouseWheel(): ArcRotateCameraInputsManager;
  98159. /**
  98160. * Add pointers input support to the input manager.
  98161. * @returns the current input manager
  98162. */
  98163. addPointers(): ArcRotateCameraInputsManager;
  98164. /**
  98165. * Add keyboard input support to the input manager.
  98166. * @returns the current input manager
  98167. */
  98168. addKeyboard(): ArcRotateCameraInputsManager;
  98169. }
  98170. }
  98171. declare module BABYLON {
  98172. /**
  98173. * This represents an orbital type of camera.
  98174. *
  98175. * 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.
  98176. * 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.
  98177. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98178. */
  98179. export class ArcRotateCamera extends TargetCamera {
  98180. /**
  98181. * Defines the rotation angle of the camera along the longitudinal axis.
  98182. */
  98183. alpha: number;
  98184. /**
  98185. * Defines the rotation angle of the camera along the latitudinal axis.
  98186. */
  98187. beta: number;
  98188. /**
  98189. * Defines the radius of the camera from it s target point.
  98190. */
  98191. radius: number;
  98192. protected _target: Vector3;
  98193. protected _targetHost: Nullable<AbstractMesh>;
  98194. /**
  98195. * Defines the target point of the camera.
  98196. * The camera looks towards it form the radius distance.
  98197. */
  98198. target: Vector3;
  98199. /**
  98200. * Define the current local position of the camera in the scene
  98201. */
  98202. position: Vector3;
  98203. protected _upVector: Vector3;
  98204. protected _upToYMatrix: Matrix;
  98205. protected _YToUpMatrix: Matrix;
  98206. /**
  98207. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98208. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98209. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98210. */
  98211. upVector: Vector3;
  98212. /**
  98213. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98214. */
  98215. setMatUp(): void;
  98216. /**
  98217. * Current inertia value on the longitudinal axis.
  98218. * The bigger this number the longer it will take for the camera to stop.
  98219. */
  98220. inertialAlphaOffset: number;
  98221. /**
  98222. * Current inertia value on the latitudinal axis.
  98223. * The bigger this number the longer it will take for the camera to stop.
  98224. */
  98225. inertialBetaOffset: number;
  98226. /**
  98227. * Current inertia value on the radius axis.
  98228. * The bigger this number the longer it will take for the camera to stop.
  98229. */
  98230. inertialRadiusOffset: number;
  98231. /**
  98232. * Minimum allowed angle on the longitudinal axis.
  98233. * This can help limiting how the Camera is able to move in the scene.
  98234. */
  98235. lowerAlphaLimit: Nullable<number>;
  98236. /**
  98237. * Maximum allowed angle on the longitudinal axis.
  98238. * This can help limiting how the Camera is able to move in the scene.
  98239. */
  98240. upperAlphaLimit: Nullable<number>;
  98241. /**
  98242. * Minimum allowed angle on the latitudinal axis.
  98243. * This can help limiting how the Camera is able to move in the scene.
  98244. */
  98245. lowerBetaLimit: number;
  98246. /**
  98247. * Maximum allowed angle on the latitudinal axis.
  98248. * This can help limiting how the Camera is able to move in the scene.
  98249. */
  98250. upperBetaLimit: number;
  98251. /**
  98252. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98253. * This can help limiting how the Camera is able to move in the scene.
  98254. */
  98255. lowerRadiusLimit: Nullable<number>;
  98256. /**
  98257. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98258. * This can help limiting how the Camera is able to move in the scene.
  98259. */
  98260. upperRadiusLimit: Nullable<number>;
  98261. /**
  98262. * Defines the current inertia value used during panning of the camera along the X axis.
  98263. */
  98264. inertialPanningX: number;
  98265. /**
  98266. * Defines the current inertia value used during panning of the camera along the Y axis.
  98267. */
  98268. inertialPanningY: number;
  98269. /**
  98270. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98271. * Basically if your fingers moves away from more than this distance you will be considered
  98272. * in pinch mode.
  98273. */
  98274. pinchToPanMaxDistance: number;
  98275. /**
  98276. * Defines the maximum distance the camera can pan.
  98277. * This could help keeping the cammera always in your scene.
  98278. */
  98279. panningDistanceLimit: Nullable<number>;
  98280. /**
  98281. * Defines the target of the camera before paning.
  98282. */
  98283. panningOriginTarget: Vector3;
  98284. /**
  98285. * Defines the value of the inertia used during panning.
  98286. * 0 would mean stop inertia and one would mean no decelleration at all.
  98287. */
  98288. panningInertia: number;
  98289. /**
  98290. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98291. */
  98292. angularSensibilityX: number;
  98293. /**
  98294. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98295. */
  98296. angularSensibilityY: number;
  98297. /**
  98298. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98299. */
  98300. pinchPrecision: number;
  98301. /**
  98302. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98303. * It will be used instead of pinchDeltaPrecision if different from 0.
  98304. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98305. */
  98306. pinchDeltaPercentage: number;
  98307. /**
  98308. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98309. */
  98310. panningSensibility: number;
  98311. /**
  98312. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98313. */
  98314. keysUp: number[];
  98315. /**
  98316. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98317. */
  98318. keysDown: number[];
  98319. /**
  98320. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98321. */
  98322. keysLeft: number[];
  98323. /**
  98324. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98325. */
  98326. keysRight: number[];
  98327. /**
  98328. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98329. */
  98330. wheelPrecision: number;
  98331. /**
  98332. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98333. * It will be used instead of pinchDeltaPrecision if different from 0.
  98334. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98335. */
  98336. wheelDeltaPercentage: number;
  98337. /**
  98338. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98339. */
  98340. zoomOnFactor: number;
  98341. /**
  98342. * Defines a screen offset for the camera position.
  98343. */
  98344. targetScreenOffset: Vector2;
  98345. /**
  98346. * Allows the camera to be completely reversed.
  98347. * If false the camera can not arrive upside down.
  98348. */
  98349. allowUpsideDown: boolean;
  98350. /**
  98351. * Define if double tap/click is used to restore the previously saved state of the camera.
  98352. */
  98353. useInputToRestoreState: boolean;
  98354. /** @hidden */
  98355. _viewMatrix: Matrix;
  98356. /** @hidden */
  98357. _useCtrlForPanning: boolean;
  98358. /** @hidden */
  98359. _panningMouseButton: number;
  98360. /**
  98361. * Defines the input associated to the camera.
  98362. */
  98363. inputs: ArcRotateCameraInputsManager;
  98364. /** @hidden */
  98365. _reset: () => void;
  98366. /**
  98367. * Defines the allowed panning axis.
  98368. */
  98369. panningAxis: Vector3;
  98370. protected _localDirection: Vector3;
  98371. protected _transformedDirection: Vector3;
  98372. private _bouncingBehavior;
  98373. /**
  98374. * Gets the bouncing behavior of the camera if it has been enabled.
  98375. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98376. */
  98377. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98378. /**
  98379. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98380. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98381. */
  98382. useBouncingBehavior: boolean;
  98383. private _framingBehavior;
  98384. /**
  98385. * Gets the framing behavior of the camera if it has been enabled.
  98386. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98387. */
  98388. readonly framingBehavior: Nullable<FramingBehavior>;
  98389. /**
  98390. * Defines if the framing behavior of the camera is enabled on the camera.
  98391. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98392. */
  98393. useFramingBehavior: boolean;
  98394. private _autoRotationBehavior;
  98395. /**
  98396. * Gets the auto rotation behavior of the camera if it has been enabled.
  98397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98398. */
  98399. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98400. /**
  98401. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98403. */
  98404. useAutoRotationBehavior: boolean;
  98405. /**
  98406. * Observable triggered when the mesh target has been changed on the camera.
  98407. */
  98408. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98409. /**
  98410. * Event raised when the camera is colliding with a mesh.
  98411. */
  98412. onCollide: (collidedMesh: AbstractMesh) => void;
  98413. /**
  98414. * Defines whether the camera should check collision with the objects oh the scene.
  98415. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98416. */
  98417. checkCollisions: boolean;
  98418. /**
  98419. * Defines the collision radius of the camera.
  98420. * This simulates a sphere around the camera.
  98421. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98422. */
  98423. collisionRadius: Vector3;
  98424. protected _collider: Collider;
  98425. protected _previousPosition: Vector3;
  98426. protected _collisionVelocity: Vector3;
  98427. protected _newPosition: Vector3;
  98428. protected _previousAlpha: number;
  98429. protected _previousBeta: number;
  98430. protected _previousRadius: number;
  98431. protected _collisionTriggered: boolean;
  98432. protected _targetBoundingCenter: Nullable<Vector3>;
  98433. private _computationVector;
  98434. /**
  98435. * Instantiates a new ArcRotateCamera in a given scene
  98436. * @param name Defines the name of the camera
  98437. * @param alpha Defines the camera rotation along the logitudinal axis
  98438. * @param beta Defines the camera rotation along the latitudinal axis
  98439. * @param radius Defines the camera distance from its target
  98440. * @param target Defines the camera target
  98441. * @param scene Defines the scene the camera belongs to
  98442. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98443. */
  98444. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98445. /** @hidden */
  98446. _initCache(): void;
  98447. /** @hidden */
  98448. _updateCache(ignoreParentClass?: boolean): void;
  98449. protected _getTargetPosition(): Vector3;
  98450. private _storedAlpha;
  98451. private _storedBeta;
  98452. private _storedRadius;
  98453. private _storedTarget;
  98454. /**
  98455. * Stores the current state of the camera (alpha, beta, radius and target)
  98456. * @returns the camera itself
  98457. */
  98458. storeState(): Camera;
  98459. /**
  98460. * @hidden
  98461. * Restored camera state. You must call storeState() first
  98462. */
  98463. _restoreStateValues(): boolean;
  98464. /** @hidden */
  98465. _isSynchronizedViewMatrix(): boolean;
  98466. /**
  98467. * Attached controls to the current camera.
  98468. * @param element Defines the element the controls should be listened from
  98469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98470. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98471. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98472. */
  98473. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98474. /**
  98475. * Detach the current controls from the camera.
  98476. * The camera will stop reacting to inputs.
  98477. * @param element Defines the element to stop listening the inputs from
  98478. */
  98479. detachControl(element: HTMLElement): void;
  98480. /** @hidden */
  98481. _checkInputs(): void;
  98482. protected _checkLimits(): void;
  98483. /**
  98484. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98485. */
  98486. rebuildAnglesAndRadius(): void;
  98487. /**
  98488. * Use a position to define the current camera related information like aplha, beta and radius
  98489. * @param position Defines the position to set the camera at
  98490. */
  98491. setPosition(position: Vector3): void;
  98492. /**
  98493. * Defines the target the camera should look at.
  98494. * This will automatically adapt alpha beta and radius to fit within the new target.
  98495. * @param target Defines the new target as a Vector or a mesh
  98496. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98497. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98498. */
  98499. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98500. /** @hidden */
  98501. _getViewMatrix(): Matrix;
  98502. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98503. /**
  98504. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98505. * @param meshes Defines the mesh to zoom on
  98506. * @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)
  98507. */
  98508. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98509. /**
  98510. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98511. * The target will be changed but the radius
  98512. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98513. * @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)
  98514. */
  98515. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98516. min: Vector3;
  98517. max: Vector3;
  98518. distance: number;
  98519. }, doNotUpdateMaxZ?: boolean): void;
  98520. /**
  98521. * @override
  98522. * Override Camera.createRigCamera
  98523. */
  98524. createRigCamera(name: string, cameraIndex: number): Camera;
  98525. /**
  98526. * @hidden
  98527. * @override
  98528. * Override Camera._updateRigCameras
  98529. */
  98530. _updateRigCameras(): void;
  98531. /**
  98532. * Destroy the camera and release the current resources hold by it.
  98533. */
  98534. dispose(): void;
  98535. /**
  98536. * Gets the current object class name.
  98537. * @return the class name
  98538. */
  98539. getClassName(): string;
  98540. }
  98541. }
  98542. declare module BABYLON {
  98543. /**
  98544. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98545. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98546. */
  98547. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98548. /**
  98549. * Gets the name of the behavior.
  98550. */
  98551. readonly name: string;
  98552. private _zoomStopsAnimation;
  98553. private _idleRotationSpeed;
  98554. private _idleRotationWaitTime;
  98555. private _idleRotationSpinupTime;
  98556. /**
  98557. * Sets the flag that indicates if user zooming should stop animation.
  98558. */
  98559. /**
  98560. * Gets the flag that indicates if user zooming should stop animation.
  98561. */
  98562. zoomStopsAnimation: boolean;
  98563. /**
  98564. * Sets the default speed at which the camera rotates around the model.
  98565. */
  98566. /**
  98567. * Gets the default speed at which the camera rotates around the model.
  98568. */
  98569. idleRotationSpeed: number;
  98570. /**
  98571. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98572. */
  98573. /**
  98574. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98575. */
  98576. idleRotationWaitTime: number;
  98577. /**
  98578. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98579. */
  98580. /**
  98581. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98582. */
  98583. idleRotationSpinupTime: number;
  98584. /**
  98585. * Gets a value indicating if the camera is currently rotating because of this behavior
  98586. */
  98587. readonly rotationInProgress: boolean;
  98588. private _onPrePointerObservableObserver;
  98589. private _onAfterCheckInputsObserver;
  98590. private _attachedCamera;
  98591. private _isPointerDown;
  98592. private _lastFrameTime;
  98593. private _lastInteractionTime;
  98594. private _cameraRotationSpeed;
  98595. /**
  98596. * Initializes the behavior.
  98597. */
  98598. init(): void;
  98599. /**
  98600. * Attaches the behavior to its arc rotate camera.
  98601. * @param camera Defines the camera to attach the behavior to
  98602. */
  98603. attach(camera: ArcRotateCamera): void;
  98604. /**
  98605. * Detaches the behavior from its current arc rotate camera.
  98606. */
  98607. detach(): void;
  98608. /**
  98609. * Returns true if user is scrolling.
  98610. * @return true if user is scrolling.
  98611. */
  98612. private _userIsZooming;
  98613. private _lastFrameRadius;
  98614. private _shouldAnimationStopForInteraction;
  98615. /**
  98616. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98617. */
  98618. private _applyUserInteraction;
  98619. private _userIsMoving;
  98620. }
  98621. }
  98622. declare module BABYLON {
  98623. /**
  98624. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98625. */
  98626. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98627. private ui;
  98628. /**
  98629. * The name of the behavior
  98630. */
  98631. name: string;
  98632. /**
  98633. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98634. */
  98635. distanceAwayFromFace: number;
  98636. /**
  98637. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98638. */
  98639. distanceAwayFromBottomOfFace: number;
  98640. private _faceVectors;
  98641. private _target;
  98642. private _scene;
  98643. private _onRenderObserver;
  98644. private _tmpMatrix;
  98645. private _tmpVector;
  98646. /**
  98647. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98648. * @param ui The transform node that should be attched to the mesh
  98649. */
  98650. constructor(ui: TransformNode);
  98651. /**
  98652. * Initializes the behavior
  98653. */
  98654. init(): void;
  98655. private _closestFace;
  98656. private _zeroVector;
  98657. private _lookAtTmpMatrix;
  98658. private _lookAtToRef;
  98659. /**
  98660. * Attaches the AttachToBoxBehavior to the passed in mesh
  98661. * @param target The mesh that the specified node will be attached to
  98662. */
  98663. attach(target: Mesh): void;
  98664. /**
  98665. * Detaches the behavior from the mesh
  98666. */
  98667. detach(): void;
  98668. }
  98669. }
  98670. declare module BABYLON {
  98671. /**
  98672. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98673. */
  98674. export class FadeInOutBehavior implements Behavior<Mesh> {
  98675. /**
  98676. * Time in milliseconds to delay before fading in (Default: 0)
  98677. */
  98678. delay: number;
  98679. /**
  98680. * Time in milliseconds for the mesh to fade in (Default: 300)
  98681. */
  98682. fadeInTime: number;
  98683. private _millisecondsPerFrame;
  98684. private _hovered;
  98685. private _hoverValue;
  98686. private _ownerNode;
  98687. /**
  98688. * Instatiates the FadeInOutBehavior
  98689. */
  98690. constructor();
  98691. /**
  98692. * The name of the behavior
  98693. */
  98694. readonly name: string;
  98695. /**
  98696. * Initializes the behavior
  98697. */
  98698. init(): void;
  98699. /**
  98700. * Attaches the fade behavior on the passed in mesh
  98701. * @param ownerNode The mesh that will be faded in/out once attached
  98702. */
  98703. attach(ownerNode: Mesh): void;
  98704. /**
  98705. * Detaches the behavior from the mesh
  98706. */
  98707. detach(): void;
  98708. /**
  98709. * Triggers the mesh to begin fading in or out
  98710. * @param value if the object should fade in or out (true to fade in)
  98711. */
  98712. fadeIn(value: boolean): void;
  98713. private _update;
  98714. private _setAllVisibility;
  98715. }
  98716. }
  98717. declare module BABYLON {
  98718. /**
  98719. * Class containing a set of static utilities functions for managing Pivots
  98720. * @hidden
  98721. */
  98722. export class PivotTools {
  98723. private static _PivotCached;
  98724. private static _OldPivotPoint;
  98725. private static _PivotTranslation;
  98726. private static _PivotTmpVector;
  98727. /** @hidden */
  98728. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98729. /** @hidden */
  98730. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98731. }
  98732. }
  98733. declare module BABYLON {
  98734. /**
  98735. * Class containing static functions to help procedurally build meshes
  98736. */
  98737. export class PlaneBuilder {
  98738. /**
  98739. * Creates a plane mesh
  98740. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98741. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98742. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98746. * @param name defines the name of the mesh
  98747. * @param options defines the options used to create the mesh
  98748. * @param scene defines the hosting scene
  98749. * @returns the plane mesh
  98750. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98751. */
  98752. static CreatePlane(name: string, options: {
  98753. size?: number;
  98754. width?: number;
  98755. height?: number;
  98756. sideOrientation?: number;
  98757. frontUVs?: Vector4;
  98758. backUVs?: Vector4;
  98759. updatable?: boolean;
  98760. sourcePlane?: Plane;
  98761. }, scene?: Nullable<Scene>): Mesh;
  98762. }
  98763. }
  98764. declare module BABYLON {
  98765. /**
  98766. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98767. */
  98768. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98769. private static _AnyMouseID;
  98770. /**
  98771. * Abstract mesh the behavior is set on
  98772. */
  98773. attachedNode: AbstractMesh;
  98774. private _dragPlane;
  98775. private _scene;
  98776. private _pointerObserver;
  98777. private _beforeRenderObserver;
  98778. private static _planeScene;
  98779. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98780. /**
  98781. * 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)
  98782. */
  98783. maxDragAngle: number;
  98784. /**
  98785. * @hidden
  98786. */
  98787. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98788. /**
  98789. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98790. */
  98791. currentDraggingPointerID: number;
  98792. /**
  98793. * The last position where the pointer hit the drag plane in world space
  98794. */
  98795. lastDragPosition: Vector3;
  98796. /**
  98797. * If the behavior is currently in a dragging state
  98798. */
  98799. dragging: boolean;
  98800. /**
  98801. * 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)
  98802. */
  98803. dragDeltaRatio: number;
  98804. /**
  98805. * If the drag plane orientation should be updated during the dragging (Default: true)
  98806. */
  98807. updateDragPlane: boolean;
  98808. private _debugMode;
  98809. private _moving;
  98810. /**
  98811. * Fires each time the attached mesh is dragged with the pointer
  98812. * * delta between last drag position and current drag position in world space
  98813. * * dragDistance along the drag axis
  98814. * * dragPlaneNormal normal of the current drag plane used during the drag
  98815. * * dragPlanePoint in world space where the drag intersects the drag plane
  98816. */
  98817. onDragObservable: Observable<{
  98818. delta: Vector3;
  98819. dragPlanePoint: Vector3;
  98820. dragPlaneNormal: Vector3;
  98821. dragDistance: number;
  98822. pointerId: number;
  98823. }>;
  98824. /**
  98825. * Fires each time a drag begins (eg. mouse down on mesh)
  98826. */
  98827. onDragStartObservable: Observable<{
  98828. dragPlanePoint: Vector3;
  98829. pointerId: number;
  98830. }>;
  98831. /**
  98832. * Fires each time a drag ends (eg. mouse release after drag)
  98833. */
  98834. onDragEndObservable: Observable<{
  98835. dragPlanePoint: Vector3;
  98836. pointerId: number;
  98837. }>;
  98838. /**
  98839. * If the attached mesh should be moved when dragged
  98840. */
  98841. moveAttached: boolean;
  98842. /**
  98843. * If the drag behavior will react to drag events (Default: true)
  98844. */
  98845. enabled: boolean;
  98846. /**
  98847. * If pointer events should start and release the drag (Default: true)
  98848. */
  98849. startAndReleaseDragOnPointerEvents: boolean;
  98850. /**
  98851. * If camera controls should be detached during the drag
  98852. */
  98853. detachCameraControls: boolean;
  98854. /**
  98855. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98856. */
  98857. useObjectOrienationForDragging: boolean;
  98858. private _options;
  98859. /**
  98860. * Creates a pointer drag behavior that can be attached to a mesh
  98861. * @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)
  98862. */
  98863. constructor(options?: {
  98864. dragAxis?: Vector3;
  98865. dragPlaneNormal?: Vector3;
  98866. });
  98867. /**
  98868. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98869. */
  98870. validateDrag: (targetPosition: Vector3) => boolean;
  98871. /**
  98872. * The name of the behavior
  98873. */
  98874. readonly name: string;
  98875. /**
  98876. * Initializes the behavior
  98877. */
  98878. init(): void;
  98879. private _tmpVector;
  98880. private _alternatePickedPoint;
  98881. private _worldDragAxis;
  98882. private _targetPosition;
  98883. private _attachedElement;
  98884. /**
  98885. * Attaches the drag behavior the passed in mesh
  98886. * @param ownerNode The mesh that will be dragged around once attached
  98887. */
  98888. attach(ownerNode: AbstractMesh): void;
  98889. /**
  98890. * Force relase the drag action by code.
  98891. */
  98892. releaseDrag(): void;
  98893. private _startDragRay;
  98894. private _lastPointerRay;
  98895. /**
  98896. * Simulates the start of a pointer drag event on the behavior
  98897. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98898. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98899. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98900. */
  98901. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98902. private _startDrag;
  98903. private _dragDelta;
  98904. private _moveDrag;
  98905. private _pickWithRayOnDragPlane;
  98906. private _pointA;
  98907. private _pointB;
  98908. private _pointC;
  98909. private _lineA;
  98910. private _lineB;
  98911. private _localAxis;
  98912. private _lookAt;
  98913. private _updateDragPlanePosition;
  98914. /**
  98915. * Detaches the behavior from the mesh
  98916. */
  98917. detach(): void;
  98918. }
  98919. }
  98920. declare module BABYLON {
  98921. /**
  98922. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98923. */
  98924. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98925. private _dragBehaviorA;
  98926. private _dragBehaviorB;
  98927. private _startDistance;
  98928. private _initialScale;
  98929. private _targetScale;
  98930. private _ownerNode;
  98931. private _sceneRenderObserver;
  98932. /**
  98933. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98934. */
  98935. constructor();
  98936. /**
  98937. * The name of the behavior
  98938. */
  98939. readonly name: string;
  98940. /**
  98941. * Initializes the behavior
  98942. */
  98943. init(): void;
  98944. private _getCurrentDistance;
  98945. /**
  98946. * Attaches the scale behavior the passed in mesh
  98947. * @param ownerNode The mesh that will be scaled around once attached
  98948. */
  98949. attach(ownerNode: Mesh): void;
  98950. /**
  98951. * Detaches the behavior from the mesh
  98952. */
  98953. detach(): void;
  98954. }
  98955. }
  98956. declare module BABYLON {
  98957. /**
  98958. * 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
  98959. */
  98960. export class SixDofDragBehavior implements Behavior<Mesh> {
  98961. private static _virtualScene;
  98962. private _ownerNode;
  98963. private _sceneRenderObserver;
  98964. private _scene;
  98965. private _targetPosition;
  98966. private _virtualOriginMesh;
  98967. private _virtualDragMesh;
  98968. private _pointerObserver;
  98969. private _moving;
  98970. private _startingOrientation;
  98971. /**
  98972. * 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)
  98973. */
  98974. private zDragFactor;
  98975. /**
  98976. * If the object should rotate to face the drag origin
  98977. */
  98978. rotateDraggedObject: boolean;
  98979. /**
  98980. * If the behavior is currently in a dragging state
  98981. */
  98982. dragging: boolean;
  98983. /**
  98984. * 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)
  98985. */
  98986. dragDeltaRatio: number;
  98987. /**
  98988. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98989. */
  98990. currentDraggingPointerID: number;
  98991. /**
  98992. * If camera controls should be detached during the drag
  98993. */
  98994. detachCameraControls: boolean;
  98995. /**
  98996. * Fires each time a drag starts
  98997. */
  98998. onDragStartObservable: Observable<{}>;
  98999. /**
  99000. * Fires each time a drag ends (eg. mouse release after drag)
  99001. */
  99002. onDragEndObservable: Observable<{}>;
  99003. /**
  99004. * 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
  99005. */
  99006. constructor();
  99007. /**
  99008. * The name of the behavior
  99009. */
  99010. readonly name: string;
  99011. /**
  99012. * Initializes the behavior
  99013. */
  99014. init(): void;
  99015. /**
  99016. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  99017. */
  99018. private readonly _pointerCamera;
  99019. /**
  99020. * Attaches the scale behavior the passed in mesh
  99021. * @param ownerNode The mesh that will be scaled around once attached
  99022. */
  99023. attach(ownerNode: Mesh): void;
  99024. /**
  99025. * Detaches the behavior from the mesh
  99026. */
  99027. detach(): void;
  99028. }
  99029. }
  99030. declare module BABYLON {
  99031. /**
  99032. * Class used to apply inverse kinematics to bones
  99033. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  99034. */
  99035. export class BoneIKController {
  99036. private static _tmpVecs;
  99037. private static _tmpQuat;
  99038. private static _tmpMats;
  99039. /**
  99040. * Gets or sets the target mesh
  99041. */
  99042. targetMesh: AbstractMesh;
  99043. /** Gets or sets the mesh used as pole */
  99044. poleTargetMesh: AbstractMesh;
  99045. /**
  99046. * Gets or sets the bone used as pole
  99047. */
  99048. poleTargetBone: Nullable<Bone>;
  99049. /**
  99050. * Gets or sets the target position
  99051. */
  99052. targetPosition: Vector3;
  99053. /**
  99054. * Gets or sets the pole target position
  99055. */
  99056. poleTargetPosition: Vector3;
  99057. /**
  99058. * Gets or sets the pole target local offset
  99059. */
  99060. poleTargetLocalOffset: Vector3;
  99061. /**
  99062. * Gets or sets the pole angle
  99063. */
  99064. poleAngle: number;
  99065. /**
  99066. * Gets or sets the mesh associated with the controller
  99067. */
  99068. mesh: AbstractMesh;
  99069. /**
  99070. * 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)
  99071. */
  99072. slerpAmount: number;
  99073. private _bone1Quat;
  99074. private _bone1Mat;
  99075. private _bone2Ang;
  99076. private _bone1;
  99077. private _bone2;
  99078. private _bone1Length;
  99079. private _bone2Length;
  99080. private _maxAngle;
  99081. private _maxReach;
  99082. private _rightHandedSystem;
  99083. private _bendAxis;
  99084. private _slerping;
  99085. private _adjustRoll;
  99086. /**
  99087. * Gets or sets maximum allowed angle
  99088. */
  99089. maxAngle: number;
  99090. /**
  99091. * Creates a new BoneIKController
  99092. * @param mesh defines the mesh to control
  99093. * @param bone defines the bone to control
  99094. * @param options defines options to set up the controller
  99095. */
  99096. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99097. targetMesh?: AbstractMesh;
  99098. poleTargetMesh?: AbstractMesh;
  99099. poleTargetBone?: Bone;
  99100. poleTargetLocalOffset?: Vector3;
  99101. poleAngle?: number;
  99102. bendAxis?: Vector3;
  99103. maxAngle?: number;
  99104. slerpAmount?: number;
  99105. });
  99106. private _setMaxAngle;
  99107. /**
  99108. * Force the controller to update the bones
  99109. */
  99110. update(): void;
  99111. }
  99112. }
  99113. declare module BABYLON {
  99114. /**
  99115. * Class used to make a bone look toward a point in space
  99116. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99117. */
  99118. export class BoneLookController {
  99119. private static _tmpVecs;
  99120. private static _tmpQuat;
  99121. private static _tmpMats;
  99122. /**
  99123. * The target Vector3 that the bone will look at
  99124. */
  99125. target: Vector3;
  99126. /**
  99127. * The mesh that the bone is attached to
  99128. */
  99129. mesh: AbstractMesh;
  99130. /**
  99131. * The bone that will be looking to the target
  99132. */
  99133. bone: Bone;
  99134. /**
  99135. * The up axis of the coordinate system that is used when the bone is rotated
  99136. */
  99137. upAxis: Vector3;
  99138. /**
  99139. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99140. */
  99141. upAxisSpace: Space;
  99142. /**
  99143. * Used to make an adjustment to the yaw of the bone
  99144. */
  99145. adjustYaw: number;
  99146. /**
  99147. * Used to make an adjustment to the pitch of the bone
  99148. */
  99149. adjustPitch: number;
  99150. /**
  99151. * Used to make an adjustment to the roll of the bone
  99152. */
  99153. adjustRoll: number;
  99154. /**
  99155. * 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)
  99156. */
  99157. slerpAmount: number;
  99158. private _minYaw;
  99159. private _maxYaw;
  99160. private _minPitch;
  99161. private _maxPitch;
  99162. private _minYawSin;
  99163. private _minYawCos;
  99164. private _maxYawSin;
  99165. private _maxYawCos;
  99166. private _midYawConstraint;
  99167. private _minPitchTan;
  99168. private _maxPitchTan;
  99169. private _boneQuat;
  99170. private _slerping;
  99171. private _transformYawPitch;
  99172. private _transformYawPitchInv;
  99173. private _firstFrameSkipped;
  99174. private _yawRange;
  99175. private _fowardAxis;
  99176. /**
  99177. * Gets or sets the minimum yaw angle that the bone can look to
  99178. */
  99179. minYaw: number;
  99180. /**
  99181. * Gets or sets the maximum yaw angle that the bone can look to
  99182. */
  99183. maxYaw: number;
  99184. /**
  99185. * Gets or sets the minimum pitch angle that the bone can look to
  99186. */
  99187. minPitch: number;
  99188. /**
  99189. * Gets or sets the maximum pitch angle that the bone can look to
  99190. */
  99191. maxPitch: number;
  99192. /**
  99193. * Create a BoneLookController
  99194. * @param mesh the mesh that the bone belongs to
  99195. * @param bone the bone that will be looking to the target
  99196. * @param target the target Vector3 to look at
  99197. * @param options optional settings:
  99198. * * maxYaw: the maximum angle the bone will yaw to
  99199. * * minYaw: the minimum angle the bone will yaw to
  99200. * * maxPitch: the maximum angle the bone will pitch to
  99201. * * minPitch: the minimum angle the bone will yaw to
  99202. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99203. * * upAxis: the up axis of the coordinate system
  99204. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99205. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99206. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99207. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99208. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99209. * * adjustRoll: used to make an adjustment to the roll of the bone
  99210. **/
  99211. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99212. maxYaw?: number;
  99213. minYaw?: number;
  99214. maxPitch?: number;
  99215. minPitch?: number;
  99216. slerpAmount?: number;
  99217. upAxis?: Vector3;
  99218. upAxisSpace?: Space;
  99219. yawAxis?: Vector3;
  99220. pitchAxis?: Vector3;
  99221. adjustYaw?: number;
  99222. adjustPitch?: number;
  99223. adjustRoll?: number;
  99224. });
  99225. /**
  99226. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99227. */
  99228. update(): void;
  99229. private _getAngleDiff;
  99230. private _getAngleBetween;
  99231. private _isAngleBetween;
  99232. }
  99233. }
  99234. declare module BABYLON {
  99235. /**
  99236. * Manage the gamepad inputs to control an arc rotate camera.
  99237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99238. */
  99239. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99240. /**
  99241. * Defines the camera the input is attached to.
  99242. */
  99243. camera: ArcRotateCamera;
  99244. /**
  99245. * Defines the gamepad the input is gathering event from.
  99246. */
  99247. gamepad: Nullable<Gamepad>;
  99248. /**
  99249. * Defines the gamepad rotation sensiblity.
  99250. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99251. */
  99252. gamepadRotationSensibility: number;
  99253. /**
  99254. * Defines the gamepad move sensiblity.
  99255. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99256. */
  99257. gamepadMoveSensibility: number;
  99258. private _onGamepadConnectedObserver;
  99259. private _onGamepadDisconnectedObserver;
  99260. /**
  99261. * Attach the input controls to a specific dom element to get the input from.
  99262. * @param element Defines the element the controls should be listened from
  99263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99264. */
  99265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99266. /**
  99267. * Detach the current controls from the specified dom element.
  99268. * @param element Defines the element to stop listening the inputs from
  99269. */
  99270. detachControl(element: Nullable<HTMLElement>): void;
  99271. /**
  99272. * Update the current camera state depending on the inputs that have been used this frame.
  99273. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99274. */
  99275. checkInputs(): void;
  99276. /**
  99277. * Gets the class name of the current intput.
  99278. * @returns the class name
  99279. */
  99280. getClassName(): string;
  99281. /**
  99282. * Get the friendly name associated with the input class.
  99283. * @returns the input friendly name
  99284. */
  99285. getSimpleName(): string;
  99286. }
  99287. }
  99288. declare module BABYLON {
  99289. interface ArcRotateCameraInputsManager {
  99290. /**
  99291. * Add orientation input support to the input manager.
  99292. * @returns the current input manager
  99293. */
  99294. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99295. }
  99296. /**
  99297. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99299. */
  99300. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99301. /**
  99302. * Defines the camera the input is attached to.
  99303. */
  99304. camera: ArcRotateCamera;
  99305. /**
  99306. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99307. */
  99308. alphaCorrection: number;
  99309. /**
  99310. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99311. */
  99312. gammaCorrection: number;
  99313. private _alpha;
  99314. private _gamma;
  99315. private _dirty;
  99316. private _deviceOrientationHandler;
  99317. /**
  99318. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99319. */
  99320. constructor();
  99321. /**
  99322. * Attach the input controls to a specific dom element to get the input from.
  99323. * @param element Defines the element the controls should be listened from
  99324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99325. */
  99326. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99327. /** @hidden */
  99328. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99329. /**
  99330. * Update the current camera state depending on the inputs that have been used this frame.
  99331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99332. */
  99333. checkInputs(): void;
  99334. /**
  99335. * Detach the current controls from the specified dom element.
  99336. * @param element Defines the element to stop listening the inputs from
  99337. */
  99338. detachControl(element: Nullable<HTMLElement>): void;
  99339. /**
  99340. * Gets the class name of the current intput.
  99341. * @returns the class name
  99342. */
  99343. getClassName(): string;
  99344. /**
  99345. * Get the friendly name associated with the input class.
  99346. * @returns the input friendly name
  99347. */
  99348. getSimpleName(): string;
  99349. }
  99350. }
  99351. declare module BABYLON {
  99352. /**
  99353. * Listen to mouse events to control the camera.
  99354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99355. */
  99356. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99357. /**
  99358. * Defines the camera the input is attached to.
  99359. */
  99360. camera: FlyCamera;
  99361. /**
  99362. * Defines if touch is enabled. (Default is true.)
  99363. */
  99364. touchEnabled: boolean;
  99365. /**
  99366. * Defines the buttons associated with the input to handle camera rotation.
  99367. */
  99368. buttons: number[];
  99369. /**
  99370. * Assign buttons for Yaw control.
  99371. */
  99372. buttonsYaw: number[];
  99373. /**
  99374. * Assign buttons for Pitch control.
  99375. */
  99376. buttonsPitch: number[];
  99377. /**
  99378. * Assign buttons for Roll control.
  99379. */
  99380. buttonsRoll: number[];
  99381. /**
  99382. * Detect if any button is being pressed while mouse is moved.
  99383. * -1 = Mouse locked.
  99384. * 0 = Left button.
  99385. * 1 = Middle Button.
  99386. * 2 = Right Button.
  99387. */
  99388. activeButton: number;
  99389. /**
  99390. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99391. * Higher values reduce its sensitivity.
  99392. */
  99393. angularSensibility: number;
  99394. private _mousemoveCallback;
  99395. private _observer;
  99396. private _rollObserver;
  99397. private previousPosition;
  99398. private noPreventDefault;
  99399. private element;
  99400. /**
  99401. * Listen to mouse events to control the camera.
  99402. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99404. */
  99405. constructor(touchEnabled?: boolean);
  99406. /**
  99407. * Attach the mouse control to the HTML DOM element.
  99408. * @param element Defines the element that listens to the input events.
  99409. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99410. */
  99411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99412. /**
  99413. * Detach the current controls from the specified dom element.
  99414. * @param element Defines the element to stop listening the inputs from
  99415. */
  99416. detachControl(element: Nullable<HTMLElement>): void;
  99417. /**
  99418. * Gets the class name of the current input.
  99419. * @returns the class name.
  99420. */
  99421. getClassName(): string;
  99422. /**
  99423. * Get the friendly name associated with the input class.
  99424. * @returns the input's friendly name.
  99425. */
  99426. getSimpleName(): string;
  99427. private _pointerInput;
  99428. private _onMouseMove;
  99429. /**
  99430. * Rotate camera by mouse offset.
  99431. */
  99432. private rotateCamera;
  99433. }
  99434. }
  99435. declare module BABYLON {
  99436. /**
  99437. * Default Inputs manager for the FlyCamera.
  99438. * It groups all the default supported inputs for ease of use.
  99439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99440. */
  99441. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99442. /**
  99443. * Instantiates a new FlyCameraInputsManager.
  99444. * @param camera Defines the camera the inputs belong to.
  99445. */
  99446. constructor(camera: FlyCamera);
  99447. /**
  99448. * Add keyboard input support to the input manager.
  99449. * @returns the new FlyCameraKeyboardMoveInput().
  99450. */
  99451. addKeyboard(): FlyCameraInputsManager;
  99452. /**
  99453. * Add mouse input support to the input manager.
  99454. * @param touchEnabled Enable touch screen support.
  99455. * @returns the new FlyCameraMouseInput().
  99456. */
  99457. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99458. }
  99459. }
  99460. declare module BABYLON {
  99461. /**
  99462. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99463. * such as in a 3D Space Shooter or a Flight Simulator.
  99464. */
  99465. export class FlyCamera extends TargetCamera {
  99466. /**
  99467. * Define the collision ellipsoid of the camera.
  99468. * This is helpful for simulating a camera body, like a player's body.
  99469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99470. */
  99471. ellipsoid: Vector3;
  99472. /**
  99473. * Define an offset for the position of the ellipsoid around the camera.
  99474. * This can be helpful if the camera is attached away from the player's body center,
  99475. * such as at its head.
  99476. */
  99477. ellipsoidOffset: Vector3;
  99478. /**
  99479. * Enable or disable collisions of the camera with the rest of the scene objects.
  99480. */
  99481. checkCollisions: boolean;
  99482. /**
  99483. * Enable or disable gravity on the camera.
  99484. */
  99485. applyGravity: boolean;
  99486. /**
  99487. * Define the current direction the camera is moving to.
  99488. */
  99489. cameraDirection: Vector3;
  99490. /**
  99491. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99492. * This overrides and empties cameraRotation.
  99493. */
  99494. rotationQuaternion: Quaternion;
  99495. /**
  99496. * Track Roll to maintain the wanted Rolling when looking around.
  99497. */
  99498. _trackRoll: number;
  99499. /**
  99500. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99501. */
  99502. rollCorrect: number;
  99503. /**
  99504. * Mimic a banked turn, Rolling the camera when Yawing.
  99505. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99506. */
  99507. bankedTurn: boolean;
  99508. /**
  99509. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99510. */
  99511. bankedTurnLimit: number;
  99512. /**
  99513. * Value of 0 disables the banked Roll.
  99514. * Value of 1 is equal to the Yaw angle in radians.
  99515. */
  99516. bankedTurnMultiplier: number;
  99517. /**
  99518. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99519. */
  99520. inputs: FlyCameraInputsManager;
  99521. /**
  99522. * Gets the input sensibility for mouse input.
  99523. * Higher values reduce sensitivity.
  99524. */
  99525. /**
  99526. * Sets the input sensibility for a mouse input.
  99527. * Higher values reduce sensitivity.
  99528. */
  99529. angularSensibility: number;
  99530. /**
  99531. * Get the keys for camera movement forward.
  99532. */
  99533. /**
  99534. * Set the keys for camera movement forward.
  99535. */
  99536. keysForward: number[];
  99537. /**
  99538. * Get the keys for camera movement backward.
  99539. */
  99540. keysBackward: number[];
  99541. /**
  99542. * Get the keys for camera movement up.
  99543. */
  99544. /**
  99545. * Set the keys for camera movement up.
  99546. */
  99547. keysUp: number[];
  99548. /**
  99549. * Get the keys for camera movement down.
  99550. */
  99551. /**
  99552. * Set the keys for camera movement down.
  99553. */
  99554. keysDown: number[];
  99555. /**
  99556. * Get the keys for camera movement left.
  99557. */
  99558. /**
  99559. * Set the keys for camera movement left.
  99560. */
  99561. keysLeft: number[];
  99562. /**
  99563. * Set the keys for camera movement right.
  99564. */
  99565. /**
  99566. * Set the keys for camera movement right.
  99567. */
  99568. keysRight: number[];
  99569. /**
  99570. * Event raised when the camera collides with a mesh in the scene.
  99571. */
  99572. onCollide: (collidedMesh: AbstractMesh) => void;
  99573. private _collider;
  99574. private _needMoveForGravity;
  99575. private _oldPosition;
  99576. private _diffPosition;
  99577. private _newPosition;
  99578. /** @hidden */
  99579. _localDirection: Vector3;
  99580. /** @hidden */
  99581. _transformedDirection: Vector3;
  99582. /**
  99583. * Instantiates a FlyCamera.
  99584. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99585. * such as in a 3D Space Shooter or a Flight Simulator.
  99586. * @param name Define the name of the camera in the scene.
  99587. * @param position Define the starting position of the camera in the scene.
  99588. * @param scene Define the scene the camera belongs to.
  99589. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99590. */
  99591. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99592. /**
  99593. * Attach a control to the HTML DOM element.
  99594. * @param element Defines the element that listens to the input events.
  99595. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99596. */
  99597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99598. /**
  99599. * Detach a control from the HTML DOM element.
  99600. * The camera will stop reacting to that input.
  99601. * @param element Defines the element that listens to the input events.
  99602. */
  99603. detachControl(element: HTMLElement): void;
  99604. private _collisionMask;
  99605. /**
  99606. * Get the mask that the camera ignores in collision events.
  99607. */
  99608. /**
  99609. * Set the mask that the camera ignores in collision events.
  99610. */
  99611. collisionMask: number;
  99612. /** @hidden */
  99613. _collideWithWorld(displacement: Vector3): void;
  99614. /** @hidden */
  99615. private _onCollisionPositionChange;
  99616. /** @hidden */
  99617. _checkInputs(): void;
  99618. /** @hidden */
  99619. _decideIfNeedsToMove(): boolean;
  99620. /** @hidden */
  99621. _updatePosition(): void;
  99622. /**
  99623. * Restore the Roll to its target value at the rate specified.
  99624. * @param rate - Higher means slower restoring.
  99625. * @hidden
  99626. */
  99627. restoreRoll(rate: number): void;
  99628. /**
  99629. * Destroy the camera and release the current resources held by it.
  99630. */
  99631. dispose(): void;
  99632. /**
  99633. * Get the current object class name.
  99634. * @returns the class name.
  99635. */
  99636. getClassName(): string;
  99637. }
  99638. }
  99639. declare module BABYLON {
  99640. /**
  99641. * Listen to keyboard events to control the camera.
  99642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99643. */
  99644. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99645. /**
  99646. * Defines the camera the input is attached to.
  99647. */
  99648. camera: FlyCamera;
  99649. /**
  99650. * The list of keyboard keys used to control the forward move of the camera.
  99651. */
  99652. keysForward: number[];
  99653. /**
  99654. * The list of keyboard keys used to control the backward move of the camera.
  99655. */
  99656. keysBackward: number[];
  99657. /**
  99658. * The list of keyboard keys used to control the forward move of the camera.
  99659. */
  99660. keysUp: number[];
  99661. /**
  99662. * The list of keyboard keys used to control the backward move of the camera.
  99663. */
  99664. keysDown: number[];
  99665. /**
  99666. * The list of keyboard keys used to control the right strafe move of the camera.
  99667. */
  99668. keysRight: number[];
  99669. /**
  99670. * The list of keyboard keys used to control the left strafe move of the camera.
  99671. */
  99672. keysLeft: number[];
  99673. private _keys;
  99674. private _onCanvasBlurObserver;
  99675. private _onKeyboardObserver;
  99676. private _engine;
  99677. private _scene;
  99678. /**
  99679. * Attach the input controls to a specific dom element to get the input from.
  99680. * @param element Defines the element the controls should be listened from
  99681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99682. */
  99683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99684. /**
  99685. * Detach the current controls from the specified dom element.
  99686. * @param element Defines the element to stop listening the inputs from
  99687. */
  99688. detachControl(element: Nullable<HTMLElement>): void;
  99689. /**
  99690. * Gets the class name of the current intput.
  99691. * @returns the class name
  99692. */
  99693. getClassName(): string;
  99694. /** @hidden */
  99695. _onLostFocus(e: FocusEvent): void;
  99696. /**
  99697. * Get the friendly name associated with the input class.
  99698. * @returns the input friendly name
  99699. */
  99700. getSimpleName(): string;
  99701. /**
  99702. * Update the current camera state depending on the inputs that have been used this frame.
  99703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99704. */
  99705. checkInputs(): void;
  99706. }
  99707. }
  99708. declare module BABYLON {
  99709. /**
  99710. * Manage the mouse wheel inputs to control a follow camera.
  99711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99712. */
  99713. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99714. /**
  99715. * Defines the camera the input is attached to.
  99716. */
  99717. camera: FollowCamera;
  99718. /**
  99719. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99720. */
  99721. axisControlRadius: boolean;
  99722. /**
  99723. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99724. */
  99725. axisControlHeight: boolean;
  99726. /**
  99727. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99728. */
  99729. axisControlRotation: boolean;
  99730. /**
  99731. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99732. * relation to mouseWheel events.
  99733. */
  99734. wheelPrecision: number;
  99735. /**
  99736. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99737. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99738. */
  99739. wheelDeltaPercentage: number;
  99740. private _wheel;
  99741. private _observer;
  99742. /**
  99743. * Attach the input controls to a specific dom element to get the input from.
  99744. * @param element Defines the element the controls should be listened from
  99745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99746. */
  99747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99748. /**
  99749. * Detach the current controls from the specified dom element.
  99750. * @param element Defines the element to stop listening the inputs from
  99751. */
  99752. detachControl(element: Nullable<HTMLElement>): void;
  99753. /**
  99754. * Gets the class name of the current intput.
  99755. * @returns the class name
  99756. */
  99757. getClassName(): string;
  99758. /**
  99759. * Get the friendly name associated with the input class.
  99760. * @returns the input friendly name
  99761. */
  99762. getSimpleName(): string;
  99763. }
  99764. }
  99765. declare module BABYLON {
  99766. /**
  99767. * Manage the pointers inputs to control an follow camera.
  99768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99769. */
  99770. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99771. /**
  99772. * Defines the camera the input is attached to.
  99773. */
  99774. camera: FollowCamera;
  99775. /**
  99776. * Gets the class name of the current input.
  99777. * @returns the class name
  99778. */
  99779. getClassName(): string;
  99780. /**
  99781. * Defines the pointer angular sensibility along the X axis or how fast is
  99782. * the camera rotating.
  99783. * A negative number will reverse the axis direction.
  99784. */
  99785. angularSensibilityX: number;
  99786. /**
  99787. * Defines the pointer angular sensibility along the Y axis or how fast is
  99788. * the camera rotating.
  99789. * A negative number will reverse the axis direction.
  99790. */
  99791. angularSensibilityY: number;
  99792. /**
  99793. * Defines the pointer pinch precision or how fast is the camera zooming.
  99794. * A negative number will reverse the axis direction.
  99795. */
  99796. pinchPrecision: number;
  99797. /**
  99798. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99799. * from 0.
  99800. * It defines the percentage of current camera.radius to use as delta when
  99801. * pinch zoom is used.
  99802. */
  99803. pinchDeltaPercentage: number;
  99804. /**
  99805. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99806. */
  99807. axisXControlRadius: boolean;
  99808. /**
  99809. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99810. */
  99811. axisXControlHeight: boolean;
  99812. /**
  99813. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99814. */
  99815. axisXControlRotation: boolean;
  99816. /**
  99817. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99818. */
  99819. axisYControlRadius: boolean;
  99820. /**
  99821. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99822. */
  99823. axisYControlHeight: boolean;
  99824. /**
  99825. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99826. */
  99827. axisYControlRotation: boolean;
  99828. /**
  99829. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99830. */
  99831. axisPinchControlRadius: boolean;
  99832. /**
  99833. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99834. */
  99835. axisPinchControlHeight: boolean;
  99836. /**
  99837. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99838. */
  99839. axisPinchControlRotation: boolean;
  99840. /**
  99841. * Log error messages if basic misconfiguration has occurred.
  99842. */
  99843. warningEnable: boolean;
  99844. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99845. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99846. private _warningCounter;
  99847. private _warning;
  99848. }
  99849. }
  99850. declare module BABYLON {
  99851. /**
  99852. * Default Inputs manager for the FollowCamera.
  99853. * It groups all the default supported inputs for ease of use.
  99854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99855. */
  99856. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99857. /**
  99858. * Instantiates a new FollowCameraInputsManager.
  99859. * @param camera Defines the camera the inputs belong to
  99860. */
  99861. constructor(camera: FollowCamera);
  99862. /**
  99863. * Add keyboard input support to the input manager.
  99864. * @returns the current input manager
  99865. */
  99866. addKeyboard(): FollowCameraInputsManager;
  99867. /**
  99868. * Add mouse wheel input support to the input manager.
  99869. * @returns the current input manager
  99870. */
  99871. addMouseWheel(): FollowCameraInputsManager;
  99872. /**
  99873. * Add pointers input support to the input manager.
  99874. * @returns the current input manager
  99875. */
  99876. addPointers(): FollowCameraInputsManager;
  99877. /**
  99878. * Add orientation input support to the input manager.
  99879. * @returns the current input manager
  99880. */
  99881. addVRDeviceOrientation(): FollowCameraInputsManager;
  99882. }
  99883. }
  99884. declare module BABYLON {
  99885. /**
  99886. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99887. * an arc rotate version arcFollowCamera are available.
  99888. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99889. */
  99890. export class FollowCamera extends TargetCamera {
  99891. /**
  99892. * Distance the follow camera should follow an object at
  99893. */
  99894. radius: number;
  99895. /**
  99896. * Minimum allowed distance of the camera to the axis of rotation
  99897. * (The camera can not get closer).
  99898. * This can help limiting how the Camera is able to move in the scene.
  99899. */
  99900. lowerRadiusLimit: Nullable<number>;
  99901. /**
  99902. * Maximum allowed distance of the camera to the axis of rotation
  99903. * (The camera can not get further).
  99904. * This can help limiting how the Camera is able to move in the scene.
  99905. */
  99906. upperRadiusLimit: Nullable<number>;
  99907. /**
  99908. * Define a rotation offset between the camera and the object it follows
  99909. */
  99910. rotationOffset: number;
  99911. /**
  99912. * Minimum allowed angle to camera position relative to target object.
  99913. * This can help limiting how the Camera is able to move in the scene.
  99914. */
  99915. lowerRotationOffsetLimit: Nullable<number>;
  99916. /**
  99917. * Maximum allowed angle to camera position relative to target object.
  99918. * This can help limiting how the Camera is able to move in the scene.
  99919. */
  99920. upperRotationOffsetLimit: Nullable<number>;
  99921. /**
  99922. * Define a height offset between the camera and the object it follows.
  99923. * It can help following an object from the top (like a car chaing a plane)
  99924. */
  99925. heightOffset: number;
  99926. /**
  99927. * Minimum allowed height of camera position relative to target object.
  99928. * This can help limiting how the Camera is able to move in the scene.
  99929. */
  99930. lowerHeightOffsetLimit: Nullable<number>;
  99931. /**
  99932. * Maximum allowed height of camera position relative to target object.
  99933. * This can help limiting how the Camera is able to move in the scene.
  99934. */
  99935. upperHeightOffsetLimit: Nullable<number>;
  99936. /**
  99937. * Define how fast the camera can accelerate to follow it s target.
  99938. */
  99939. cameraAcceleration: number;
  99940. /**
  99941. * Define the speed limit of the camera following an object.
  99942. */
  99943. maxCameraSpeed: number;
  99944. /**
  99945. * Define the target of the camera.
  99946. */
  99947. lockedTarget: Nullable<AbstractMesh>;
  99948. /**
  99949. * Defines the input associated with the camera.
  99950. */
  99951. inputs: FollowCameraInputsManager;
  99952. /**
  99953. * Instantiates the follow camera.
  99954. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99955. * @param name Define the name of the camera in the scene
  99956. * @param position Define the position of the camera
  99957. * @param scene Define the scene the camera belong to
  99958. * @param lockedTarget Define the target of the camera
  99959. */
  99960. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99961. private _follow;
  99962. /**
  99963. * Attached controls to the current camera.
  99964. * @param element Defines the element the controls should be listened from
  99965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99966. */
  99967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99968. /**
  99969. * Detach the current controls from the camera.
  99970. * The camera will stop reacting to inputs.
  99971. * @param element Defines the element to stop listening the inputs from
  99972. */
  99973. detachControl(element: HTMLElement): void;
  99974. /** @hidden */
  99975. _checkInputs(): void;
  99976. private _checkLimits;
  99977. /**
  99978. * Gets the camera class name.
  99979. * @returns the class name
  99980. */
  99981. getClassName(): string;
  99982. }
  99983. /**
  99984. * Arc Rotate version of the follow camera.
  99985. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99986. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99987. */
  99988. export class ArcFollowCamera extends TargetCamera {
  99989. /** The longitudinal angle of the camera */
  99990. alpha: number;
  99991. /** The latitudinal angle of the camera */
  99992. beta: number;
  99993. /** The radius of the camera from its target */
  99994. radius: number;
  99995. /** Define the camera target (the messh it should follow) */
  99996. target: Nullable<AbstractMesh>;
  99997. private _cartesianCoordinates;
  99998. /**
  99999. * Instantiates a new ArcFollowCamera
  100000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  100001. * @param name Define the name of the camera
  100002. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  100003. * @param beta Define the rotation angle of the camera around the elevation axis
  100004. * @param radius Define the radius of the camera from its target point
  100005. * @param target Define the target of the camera
  100006. * @param scene Define the scene the camera belongs to
  100007. */
  100008. constructor(name: string,
  100009. /** The longitudinal angle of the camera */
  100010. alpha: number,
  100011. /** The latitudinal angle of the camera */
  100012. beta: number,
  100013. /** The radius of the camera from its target */
  100014. radius: number,
  100015. /** Define the camera target (the messh it should follow) */
  100016. target: Nullable<AbstractMesh>, scene: Scene);
  100017. private _follow;
  100018. /** @hidden */
  100019. _checkInputs(): void;
  100020. /**
  100021. * Returns the class name of the object.
  100022. * It is mostly used internally for serialization purposes.
  100023. */
  100024. getClassName(): string;
  100025. }
  100026. }
  100027. declare module BABYLON {
  100028. /**
  100029. * Manage the keyboard inputs to control the movement of a follow camera.
  100030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100031. */
  100032. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  100033. /**
  100034. * Defines the camera the input is attached to.
  100035. */
  100036. camera: FollowCamera;
  100037. /**
  100038. * Defines the list of key codes associated with the up action (increase heightOffset)
  100039. */
  100040. keysHeightOffsetIncr: number[];
  100041. /**
  100042. * Defines the list of key codes associated with the down action (decrease heightOffset)
  100043. */
  100044. keysHeightOffsetDecr: number[];
  100045. /**
  100046. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100047. */
  100048. keysHeightOffsetModifierAlt: boolean;
  100049. /**
  100050. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100051. */
  100052. keysHeightOffsetModifierCtrl: boolean;
  100053. /**
  100054. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100055. */
  100056. keysHeightOffsetModifierShift: boolean;
  100057. /**
  100058. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100059. */
  100060. keysRotationOffsetIncr: number[];
  100061. /**
  100062. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100063. */
  100064. keysRotationOffsetDecr: number[];
  100065. /**
  100066. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100067. */
  100068. keysRotationOffsetModifierAlt: boolean;
  100069. /**
  100070. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100071. */
  100072. keysRotationOffsetModifierCtrl: boolean;
  100073. /**
  100074. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100075. */
  100076. keysRotationOffsetModifierShift: boolean;
  100077. /**
  100078. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100079. */
  100080. keysRadiusIncr: number[];
  100081. /**
  100082. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100083. */
  100084. keysRadiusDecr: number[];
  100085. /**
  100086. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100087. */
  100088. keysRadiusModifierAlt: boolean;
  100089. /**
  100090. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100091. */
  100092. keysRadiusModifierCtrl: boolean;
  100093. /**
  100094. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100095. */
  100096. keysRadiusModifierShift: boolean;
  100097. /**
  100098. * Defines the rate of change of heightOffset.
  100099. */
  100100. heightSensibility: number;
  100101. /**
  100102. * Defines the rate of change of rotationOffset.
  100103. */
  100104. rotationSensibility: number;
  100105. /**
  100106. * Defines the rate of change of radius.
  100107. */
  100108. radiusSensibility: number;
  100109. private _keys;
  100110. private _ctrlPressed;
  100111. private _altPressed;
  100112. private _shiftPressed;
  100113. private _onCanvasBlurObserver;
  100114. private _onKeyboardObserver;
  100115. private _engine;
  100116. private _scene;
  100117. /**
  100118. * Attach the input controls to a specific dom element to get the input from.
  100119. * @param element Defines the element the controls should be listened from
  100120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100121. */
  100122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100123. /**
  100124. * Detach the current controls from the specified dom element.
  100125. * @param element Defines the element to stop listening the inputs from
  100126. */
  100127. detachControl(element: Nullable<HTMLElement>): void;
  100128. /**
  100129. * Update the current camera state depending on the inputs that have been used this frame.
  100130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100131. */
  100132. checkInputs(): void;
  100133. /**
  100134. * Gets the class name of the current input.
  100135. * @returns the class name
  100136. */
  100137. getClassName(): string;
  100138. /**
  100139. * Get the friendly name associated with the input class.
  100140. * @returns the input friendly name
  100141. */
  100142. getSimpleName(): string;
  100143. /**
  100144. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100145. * allow modification of the heightOffset value.
  100146. */
  100147. private _modifierHeightOffset;
  100148. /**
  100149. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100150. * allow modification of the rotationOffset value.
  100151. */
  100152. private _modifierRotationOffset;
  100153. /**
  100154. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100155. * allow modification of the radius value.
  100156. */
  100157. private _modifierRadius;
  100158. }
  100159. }
  100160. declare module BABYLON {
  100161. interface FreeCameraInputsManager {
  100162. /**
  100163. * @hidden
  100164. */
  100165. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100166. /**
  100167. * Add orientation input support to the input manager.
  100168. * @returns the current input manager
  100169. */
  100170. addDeviceOrientation(): FreeCameraInputsManager;
  100171. }
  100172. /**
  100173. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100174. * Screen rotation is taken into account.
  100175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100176. */
  100177. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100178. private _camera;
  100179. private _screenOrientationAngle;
  100180. private _constantTranform;
  100181. private _screenQuaternion;
  100182. private _alpha;
  100183. private _beta;
  100184. private _gamma;
  100185. /**
  100186. * Can be used to detect if a device orientation sensor is availible on a device
  100187. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100188. * @returns a promise that will resolve on orientation change
  100189. */
  100190. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100191. /**
  100192. * @hidden
  100193. */
  100194. _onDeviceOrientationChangedObservable: Observable<void>;
  100195. /**
  100196. * Instantiates a new input
  100197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100198. */
  100199. constructor();
  100200. /**
  100201. * Define the camera controlled by the input.
  100202. */
  100203. camera: FreeCamera;
  100204. /**
  100205. * Attach the input controls to a specific dom element to get the input from.
  100206. * @param element Defines the element the controls should be listened from
  100207. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100208. */
  100209. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100210. private _orientationChanged;
  100211. private _deviceOrientation;
  100212. /**
  100213. * Detach the current controls from the specified dom element.
  100214. * @param element Defines the element to stop listening the inputs from
  100215. */
  100216. detachControl(element: Nullable<HTMLElement>): void;
  100217. /**
  100218. * Update the current camera state depending on the inputs that have been used this frame.
  100219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100220. */
  100221. checkInputs(): void;
  100222. /**
  100223. * Gets the class name of the current intput.
  100224. * @returns the class name
  100225. */
  100226. getClassName(): string;
  100227. /**
  100228. * Get the friendly name associated with the input class.
  100229. * @returns the input friendly name
  100230. */
  100231. getSimpleName(): string;
  100232. }
  100233. }
  100234. declare module BABYLON {
  100235. /**
  100236. * Manage the gamepad inputs to control a free camera.
  100237. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100238. */
  100239. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100240. /**
  100241. * Define the camera the input is attached to.
  100242. */
  100243. camera: FreeCamera;
  100244. /**
  100245. * Define the Gamepad controlling the input
  100246. */
  100247. gamepad: Nullable<Gamepad>;
  100248. /**
  100249. * Defines the gamepad rotation sensiblity.
  100250. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100251. */
  100252. gamepadAngularSensibility: number;
  100253. /**
  100254. * Defines the gamepad move sensiblity.
  100255. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100256. */
  100257. gamepadMoveSensibility: number;
  100258. private _onGamepadConnectedObserver;
  100259. private _onGamepadDisconnectedObserver;
  100260. private _cameraTransform;
  100261. private _deltaTransform;
  100262. private _vector3;
  100263. private _vector2;
  100264. /**
  100265. * Attach the input controls to a specific dom element to get the input from.
  100266. * @param element Defines the element the controls should be listened from
  100267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100268. */
  100269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100270. /**
  100271. * Detach the current controls from the specified dom element.
  100272. * @param element Defines the element to stop listening the inputs from
  100273. */
  100274. detachControl(element: Nullable<HTMLElement>): void;
  100275. /**
  100276. * Update the current camera state depending on the inputs that have been used this frame.
  100277. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100278. */
  100279. checkInputs(): void;
  100280. /**
  100281. * Gets the class name of the current intput.
  100282. * @returns the class name
  100283. */
  100284. getClassName(): string;
  100285. /**
  100286. * Get the friendly name associated with the input class.
  100287. * @returns the input friendly name
  100288. */
  100289. getSimpleName(): string;
  100290. }
  100291. }
  100292. declare module BABYLON {
  100293. /**
  100294. * Defines the potential axis of a Joystick
  100295. */
  100296. export enum JoystickAxis {
  100297. /** X axis */
  100298. X = 0,
  100299. /** Y axis */
  100300. Y = 1,
  100301. /** Z axis */
  100302. Z = 2
  100303. }
  100304. /**
  100305. * Class used to define virtual joystick (used in touch mode)
  100306. */
  100307. export class VirtualJoystick {
  100308. /**
  100309. * Gets or sets a boolean indicating that left and right values must be inverted
  100310. */
  100311. reverseLeftRight: boolean;
  100312. /**
  100313. * Gets or sets a boolean indicating that up and down values must be inverted
  100314. */
  100315. reverseUpDown: boolean;
  100316. /**
  100317. * Gets the offset value for the position (ie. the change of the position value)
  100318. */
  100319. deltaPosition: Vector3;
  100320. /**
  100321. * Gets a boolean indicating if the virtual joystick was pressed
  100322. */
  100323. pressed: boolean;
  100324. /**
  100325. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100326. */
  100327. static Canvas: Nullable<HTMLCanvasElement>;
  100328. private static _globalJoystickIndex;
  100329. private static vjCanvasContext;
  100330. private static vjCanvasWidth;
  100331. private static vjCanvasHeight;
  100332. private static halfWidth;
  100333. private _action;
  100334. private _axisTargetedByLeftAndRight;
  100335. private _axisTargetedByUpAndDown;
  100336. private _joystickSensibility;
  100337. private _inversedSensibility;
  100338. private _joystickPointerID;
  100339. private _joystickColor;
  100340. private _joystickPointerPos;
  100341. private _joystickPreviousPointerPos;
  100342. private _joystickPointerStartPos;
  100343. private _deltaJoystickVector;
  100344. private _leftJoystick;
  100345. private _touches;
  100346. private _onPointerDownHandlerRef;
  100347. private _onPointerMoveHandlerRef;
  100348. private _onPointerUpHandlerRef;
  100349. private _onResize;
  100350. /**
  100351. * Creates a new virtual joystick
  100352. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100353. */
  100354. constructor(leftJoystick?: boolean);
  100355. /**
  100356. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100357. * @param newJoystickSensibility defines the new sensibility
  100358. */
  100359. setJoystickSensibility(newJoystickSensibility: number): void;
  100360. private _onPointerDown;
  100361. private _onPointerMove;
  100362. private _onPointerUp;
  100363. /**
  100364. * Change the color of the virtual joystick
  100365. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100366. */
  100367. setJoystickColor(newColor: string): void;
  100368. /**
  100369. * Defines a callback to call when the joystick is touched
  100370. * @param action defines the callback
  100371. */
  100372. setActionOnTouch(action: () => any): void;
  100373. /**
  100374. * Defines which axis you'd like to control for left & right
  100375. * @param axis defines the axis to use
  100376. */
  100377. setAxisForLeftRight(axis: JoystickAxis): void;
  100378. /**
  100379. * Defines which axis you'd like to control for up & down
  100380. * @param axis defines the axis to use
  100381. */
  100382. setAxisForUpDown(axis: JoystickAxis): void;
  100383. private _drawVirtualJoystick;
  100384. /**
  100385. * Release internal HTML canvas
  100386. */
  100387. releaseCanvas(): void;
  100388. }
  100389. }
  100390. declare module BABYLON {
  100391. interface FreeCameraInputsManager {
  100392. /**
  100393. * Add virtual joystick input support to the input manager.
  100394. * @returns the current input manager
  100395. */
  100396. addVirtualJoystick(): FreeCameraInputsManager;
  100397. }
  100398. /**
  100399. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100401. */
  100402. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100403. /**
  100404. * Defines the camera the input is attached to.
  100405. */
  100406. camera: FreeCamera;
  100407. private _leftjoystick;
  100408. private _rightjoystick;
  100409. /**
  100410. * Gets the left stick of the virtual joystick.
  100411. * @returns The virtual Joystick
  100412. */
  100413. getLeftJoystick(): VirtualJoystick;
  100414. /**
  100415. * Gets the right stick of the virtual joystick.
  100416. * @returns The virtual Joystick
  100417. */
  100418. getRightJoystick(): VirtualJoystick;
  100419. /**
  100420. * Update the current camera state depending on the inputs that have been used this frame.
  100421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100422. */
  100423. checkInputs(): void;
  100424. /**
  100425. * Attach the input controls to a specific dom element to get the input from.
  100426. * @param element Defines the element the controls should be listened from
  100427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100428. */
  100429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100430. /**
  100431. * Detach the current controls from the specified dom element.
  100432. * @param element Defines the element to stop listening the inputs from
  100433. */
  100434. detachControl(element: Nullable<HTMLElement>): void;
  100435. /**
  100436. * Gets the class name of the current intput.
  100437. * @returns the class name
  100438. */
  100439. getClassName(): string;
  100440. /**
  100441. * Get the friendly name associated with the input class.
  100442. * @returns the input friendly name
  100443. */
  100444. getSimpleName(): string;
  100445. }
  100446. }
  100447. declare module BABYLON {
  100448. /**
  100449. * This represents a FPS type of camera controlled by touch.
  100450. * This is like a universal camera minus the Gamepad controls.
  100451. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100452. */
  100453. export class TouchCamera extends FreeCamera {
  100454. /**
  100455. * Defines the touch sensibility for rotation.
  100456. * The higher the faster.
  100457. */
  100458. touchAngularSensibility: number;
  100459. /**
  100460. * Defines the touch sensibility for move.
  100461. * The higher the faster.
  100462. */
  100463. touchMoveSensibility: number;
  100464. /**
  100465. * Instantiates a new touch camera.
  100466. * This represents a FPS type of camera controlled by touch.
  100467. * This is like a universal camera minus the Gamepad controls.
  100468. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100469. * @param name Define the name of the camera in the scene
  100470. * @param position Define the start position of the camera in the scene
  100471. * @param scene Define the scene the camera belongs to
  100472. */
  100473. constructor(name: string, position: Vector3, scene: Scene);
  100474. /**
  100475. * Gets the current object class name.
  100476. * @return the class name
  100477. */
  100478. getClassName(): string;
  100479. /** @hidden */
  100480. _setupInputs(): void;
  100481. }
  100482. }
  100483. declare module BABYLON {
  100484. /**
  100485. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100486. * being tilted forward or back and left or right.
  100487. */
  100488. export class DeviceOrientationCamera extends FreeCamera {
  100489. private _initialQuaternion;
  100490. private _quaternionCache;
  100491. private _tmpDragQuaternion;
  100492. /**
  100493. * Creates a new device orientation camera
  100494. * @param name The name of the camera
  100495. * @param position The start position camera
  100496. * @param scene The scene the camera belongs to
  100497. */
  100498. constructor(name: string, position: Vector3, scene: Scene);
  100499. /**
  100500. * @hidden
  100501. * Disabled pointer input on first orientation sensor update (Default: true)
  100502. */
  100503. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100504. private _dragFactor;
  100505. /**
  100506. * Enabled turning on the y axis when the orientation sensor is active
  100507. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100508. */
  100509. enableHorizontalDragging(dragFactor?: number): void;
  100510. /**
  100511. * Gets the current instance class name ("DeviceOrientationCamera").
  100512. * This helps avoiding instanceof at run time.
  100513. * @returns the class name
  100514. */
  100515. getClassName(): string;
  100516. /**
  100517. * @hidden
  100518. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100519. */
  100520. _checkInputs(): void;
  100521. /**
  100522. * Reset the camera to its default orientation on the specified axis only.
  100523. * @param axis The axis to reset
  100524. */
  100525. resetToCurrentRotation(axis?: Axis): void;
  100526. }
  100527. }
  100528. declare module BABYLON {
  100529. /**
  100530. * Defines supported buttons for XBox360 compatible gamepads
  100531. */
  100532. export enum Xbox360Button {
  100533. /** A */
  100534. A = 0,
  100535. /** B */
  100536. B = 1,
  100537. /** X */
  100538. X = 2,
  100539. /** Y */
  100540. Y = 3,
  100541. /** Start */
  100542. Start = 4,
  100543. /** Back */
  100544. Back = 5,
  100545. /** Left button */
  100546. LB = 6,
  100547. /** Right button */
  100548. RB = 7,
  100549. /** Left stick */
  100550. LeftStick = 8,
  100551. /** Right stick */
  100552. RightStick = 9
  100553. }
  100554. /** Defines values for XBox360 DPad */
  100555. export enum Xbox360Dpad {
  100556. /** Up */
  100557. Up = 0,
  100558. /** Down */
  100559. Down = 1,
  100560. /** Left */
  100561. Left = 2,
  100562. /** Right */
  100563. Right = 3
  100564. }
  100565. /**
  100566. * Defines a XBox360 gamepad
  100567. */
  100568. export class Xbox360Pad extends Gamepad {
  100569. private _leftTrigger;
  100570. private _rightTrigger;
  100571. private _onlefttriggerchanged;
  100572. private _onrighttriggerchanged;
  100573. private _onbuttondown;
  100574. private _onbuttonup;
  100575. private _ondpaddown;
  100576. private _ondpadup;
  100577. /** Observable raised when a button is pressed */
  100578. onButtonDownObservable: Observable<Xbox360Button>;
  100579. /** Observable raised when a button is released */
  100580. onButtonUpObservable: Observable<Xbox360Button>;
  100581. /** Observable raised when a pad is pressed */
  100582. onPadDownObservable: Observable<Xbox360Dpad>;
  100583. /** Observable raised when a pad is released */
  100584. onPadUpObservable: Observable<Xbox360Dpad>;
  100585. private _buttonA;
  100586. private _buttonB;
  100587. private _buttonX;
  100588. private _buttonY;
  100589. private _buttonBack;
  100590. private _buttonStart;
  100591. private _buttonLB;
  100592. private _buttonRB;
  100593. private _buttonLeftStick;
  100594. private _buttonRightStick;
  100595. private _dPadUp;
  100596. private _dPadDown;
  100597. private _dPadLeft;
  100598. private _dPadRight;
  100599. private _isXboxOnePad;
  100600. /**
  100601. * Creates a new XBox360 gamepad object
  100602. * @param id defines the id of this gamepad
  100603. * @param index defines its index
  100604. * @param gamepad defines the internal HTML gamepad object
  100605. * @param xboxOne defines if it is a XBox One gamepad
  100606. */
  100607. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100608. /**
  100609. * Defines the callback to call when left trigger is pressed
  100610. * @param callback defines the callback to use
  100611. */
  100612. onlefttriggerchanged(callback: (value: number) => void): void;
  100613. /**
  100614. * Defines the callback to call when right trigger is pressed
  100615. * @param callback defines the callback to use
  100616. */
  100617. onrighttriggerchanged(callback: (value: number) => void): void;
  100618. /**
  100619. * Gets the left trigger value
  100620. */
  100621. /**
  100622. * Sets the left trigger value
  100623. */
  100624. leftTrigger: number;
  100625. /**
  100626. * Gets the right trigger value
  100627. */
  100628. /**
  100629. * Sets the right trigger value
  100630. */
  100631. rightTrigger: number;
  100632. /**
  100633. * Defines the callback to call when a button is pressed
  100634. * @param callback defines the callback to use
  100635. */
  100636. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100637. /**
  100638. * Defines the callback to call when a button is released
  100639. * @param callback defines the callback to use
  100640. */
  100641. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100642. /**
  100643. * Defines the callback to call when a pad is pressed
  100644. * @param callback defines the callback to use
  100645. */
  100646. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100647. /**
  100648. * Defines the callback to call when a pad is released
  100649. * @param callback defines the callback to use
  100650. */
  100651. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100652. private _setButtonValue;
  100653. private _setDPadValue;
  100654. /**
  100655. * Gets the value of the `A` button
  100656. */
  100657. /**
  100658. * Sets the value of the `A` button
  100659. */
  100660. buttonA: number;
  100661. /**
  100662. * Gets the value of the `B` button
  100663. */
  100664. /**
  100665. * Sets the value of the `B` button
  100666. */
  100667. buttonB: number;
  100668. /**
  100669. * Gets the value of the `X` button
  100670. */
  100671. /**
  100672. * Sets the value of the `X` button
  100673. */
  100674. buttonX: number;
  100675. /**
  100676. * Gets the value of the `Y` button
  100677. */
  100678. /**
  100679. * Sets the value of the `Y` button
  100680. */
  100681. buttonY: number;
  100682. /**
  100683. * Gets the value of the `Start` button
  100684. */
  100685. /**
  100686. * Sets the value of the `Start` button
  100687. */
  100688. buttonStart: number;
  100689. /**
  100690. * Gets the value of the `Back` button
  100691. */
  100692. /**
  100693. * Sets the value of the `Back` button
  100694. */
  100695. buttonBack: number;
  100696. /**
  100697. * Gets the value of the `Left` button
  100698. */
  100699. /**
  100700. * Sets the value of the `Left` button
  100701. */
  100702. buttonLB: number;
  100703. /**
  100704. * Gets the value of the `Right` button
  100705. */
  100706. /**
  100707. * Sets the value of the `Right` button
  100708. */
  100709. buttonRB: number;
  100710. /**
  100711. * Gets the value of the Left joystick
  100712. */
  100713. /**
  100714. * Sets the value of the Left joystick
  100715. */
  100716. buttonLeftStick: number;
  100717. /**
  100718. * Gets the value of the Right joystick
  100719. */
  100720. /**
  100721. * Sets the value of the Right joystick
  100722. */
  100723. buttonRightStick: number;
  100724. /**
  100725. * Gets the value of D-pad up
  100726. */
  100727. /**
  100728. * Sets the value of D-pad up
  100729. */
  100730. dPadUp: number;
  100731. /**
  100732. * Gets the value of D-pad down
  100733. */
  100734. /**
  100735. * Sets the value of D-pad down
  100736. */
  100737. dPadDown: number;
  100738. /**
  100739. * Gets the value of D-pad left
  100740. */
  100741. /**
  100742. * Sets the value of D-pad left
  100743. */
  100744. dPadLeft: number;
  100745. /**
  100746. * Gets the value of D-pad right
  100747. */
  100748. /**
  100749. * Sets the value of D-pad right
  100750. */
  100751. dPadRight: number;
  100752. /**
  100753. * Force the gamepad to synchronize with device values
  100754. */
  100755. update(): void;
  100756. /**
  100757. * Disposes the gamepad
  100758. */
  100759. dispose(): void;
  100760. }
  100761. }
  100762. declare module BABYLON {
  100763. /**
  100764. * Manager for handling gamepads
  100765. */
  100766. export class GamepadManager {
  100767. private _scene?;
  100768. private _babylonGamepads;
  100769. private _oneGamepadConnected;
  100770. /** @hidden */
  100771. _isMonitoring: boolean;
  100772. private _gamepadEventSupported;
  100773. private _gamepadSupport;
  100774. /**
  100775. * observable to be triggered when the gamepad controller has been connected
  100776. */
  100777. onGamepadConnectedObservable: Observable<Gamepad>;
  100778. /**
  100779. * observable to be triggered when the gamepad controller has been disconnected
  100780. */
  100781. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100782. private _onGamepadConnectedEvent;
  100783. private _onGamepadDisconnectedEvent;
  100784. /**
  100785. * Initializes the gamepad manager
  100786. * @param _scene BabylonJS scene
  100787. */
  100788. constructor(_scene?: Scene | undefined);
  100789. /**
  100790. * The gamepads in the game pad manager
  100791. */
  100792. readonly gamepads: Gamepad[];
  100793. /**
  100794. * Get the gamepad controllers based on type
  100795. * @param type The type of gamepad controller
  100796. * @returns Nullable gamepad
  100797. */
  100798. getGamepadByType(type?: number): Nullable<Gamepad>;
  100799. /**
  100800. * Disposes the gamepad manager
  100801. */
  100802. dispose(): void;
  100803. private _addNewGamepad;
  100804. private _startMonitoringGamepads;
  100805. private _stopMonitoringGamepads;
  100806. /** @hidden */
  100807. _checkGamepadsStatus(): void;
  100808. private _updateGamepadObjects;
  100809. }
  100810. }
  100811. declare module BABYLON {
  100812. interface Scene {
  100813. /** @hidden */
  100814. _gamepadManager: Nullable<GamepadManager>;
  100815. /**
  100816. * Gets the gamepad manager associated with the scene
  100817. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100818. */
  100819. gamepadManager: GamepadManager;
  100820. }
  100821. /**
  100822. * Interface representing a free camera inputs manager
  100823. */
  100824. interface FreeCameraInputsManager {
  100825. /**
  100826. * Adds gamepad input support to the FreeCameraInputsManager.
  100827. * @returns the FreeCameraInputsManager
  100828. */
  100829. addGamepad(): FreeCameraInputsManager;
  100830. }
  100831. /**
  100832. * Interface representing an arc rotate camera inputs manager
  100833. */
  100834. interface ArcRotateCameraInputsManager {
  100835. /**
  100836. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100837. * @returns the camera inputs manager
  100838. */
  100839. addGamepad(): ArcRotateCameraInputsManager;
  100840. }
  100841. /**
  100842. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100843. */
  100844. export class GamepadSystemSceneComponent implements ISceneComponent {
  100845. /**
  100846. * The component name helpfull to identify the component in the list of scene components.
  100847. */
  100848. readonly name: string;
  100849. /**
  100850. * The scene the component belongs to.
  100851. */
  100852. scene: Scene;
  100853. /**
  100854. * Creates a new instance of the component for the given scene
  100855. * @param scene Defines the scene to register the component in
  100856. */
  100857. constructor(scene: Scene);
  100858. /**
  100859. * Registers the component in a given scene
  100860. */
  100861. register(): void;
  100862. /**
  100863. * Rebuilds the elements related to this component in case of
  100864. * context lost for instance.
  100865. */
  100866. rebuild(): void;
  100867. /**
  100868. * Disposes the component and the associated ressources
  100869. */
  100870. dispose(): void;
  100871. private _beforeCameraUpdate;
  100872. }
  100873. }
  100874. declare module BABYLON {
  100875. /**
  100876. * 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,
  100877. * which still works and will still be found in many Playgrounds.
  100878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100879. */
  100880. export class UniversalCamera extends TouchCamera {
  100881. /**
  100882. * Defines the gamepad rotation sensiblity.
  100883. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100884. */
  100885. gamepadAngularSensibility: number;
  100886. /**
  100887. * Defines the gamepad move sensiblity.
  100888. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100889. */
  100890. gamepadMoveSensibility: number;
  100891. /**
  100892. * 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,
  100893. * which still works and will still be found in many Playgrounds.
  100894. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100895. * @param name Define the name of the camera in the scene
  100896. * @param position Define the start position of the camera in the scene
  100897. * @param scene Define the scene the camera belongs to
  100898. */
  100899. constructor(name: string, position: Vector3, scene: Scene);
  100900. /**
  100901. * Gets the current object class name.
  100902. * @return the class name
  100903. */
  100904. getClassName(): string;
  100905. }
  100906. }
  100907. declare module BABYLON {
  100908. /**
  100909. * This represents a FPS type of camera. This is only here for back compat purpose.
  100910. * Please use the UniversalCamera instead as both are identical.
  100911. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100912. */
  100913. export class GamepadCamera extends UniversalCamera {
  100914. /**
  100915. * Instantiates a new Gamepad Camera
  100916. * This represents a FPS type of camera. This is only here for back compat purpose.
  100917. * Please use the UniversalCamera instead as both are identical.
  100918. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100919. * @param name Define the name of the camera in the scene
  100920. * @param position Define the start position of the camera in the scene
  100921. * @param scene Define the scene the camera belongs to
  100922. */
  100923. constructor(name: string, position: Vector3, scene: Scene);
  100924. /**
  100925. * Gets the current object class name.
  100926. * @return the class name
  100927. */
  100928. getClassName(): string;
  100929. }
  100930. }
  100931. declare module BABYLON {
  100932. /** @hidden */
  100933. export var passPixelShader: {
  100934. name: string;
  100935. shader: string;
  100936. };
  100937. }
  100938. declare module BABYLON {
  100939. /** @hidden */
  100940. export var passCubePixelShader: {
  100941. name: string;
  100942. shader: string;
  100943. };
  100944. }
  100945. declare module BABYLON {
  100946. /**
  100947. * PassPostProcess which produces an output the same as it's input
  100948. */
  100949. export class PassPostProcess extends PostProcess {
  100950. /**
  100951. * Creates the PassPostProcess
  100952. * @param name The name of the effect.
  100953. * @param options The required width/height ratio to downsize to before computing the render pass.
  100954. * @param camera The camera to apply the render pass to.
  100955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100956. * @param engine The engine which the post process will be applied. (default: current engine)
  100957. * @param reusable If the post process can be reused on the same frame. (default: false)
  100958. * @param textureType The type of texture to be used when performing the post processing.
  100959. * @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)
  100960. */
  100961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100962. }
  100963. /**
  100964. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100965. */
  100966. export class PassCubePostProcess extends PostProcess {
  100967. private _face;
  100968. /**
  100969. * Gets or sets the cube face to display.
  100970. * * 0 is +X
  100971. * * 1 is -X
  100972. * * 2 is +Y
  100973. * * 3 is -Y
  100974. * * 4 is +Z
  100975. * * 5 is -Z
  100976. */
  100977. face: number;
  100978. /**
  100979. * Creates the PassCubePostProcess
  100980. * @param name The name of the effect.
  100981. * @param options The required width/height ratio to downsize to before computing the render pass.
  100982. * @param camera The camera to apply the render pass to.
  100983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100984. * @param engine The engine which the post process will be applied. (default: current engine)
  100985. * @param reusable If the post process can be reused on the same frame. (default: false)
  100986. * @param textureType The type of texture to be used when performing the post processing.
  100987. * @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)
  100988. */
  100989. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100990. }
  100991. }
  100992. declare module BABYLON {
  100993. /** @hidden */
  100994. export var anaglyphPixelShader: {
  100995. name: string;
  100996. shader: string;
  100997. };
  100998. }
  100999. declare module BABYLON {
  101000. /**
  101001. * Postprocess used to generate anaglyphic rendering
  101002. */
  101003. export class AnaglyphPostProcess extends PostProcess {
  101004. private _passedProcess;
  101005. /**
  101006. * Creates a new AnaglyphPostProcess
  101007. * @param name defines postprocess name
  101008. * @param options defines creation options or target ratio scale
  101009. * @param rigCameras defines cameras using this postprocess
  101010. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  101011. * @param engine defines hosting engine
  101012. * @param reusable defines if the postprocess will be reused multiple times per frame
  101013. */
  101014. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  101015. }
  101016. }
  101017. declare module BABYLON {
  101018. /**
  101019. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  101020. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101021. */
  101022. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  101023. /**
  101024. * Creates a new AnaglyphArcRotateCamera
  101025. * @param name defines camera name
  101026. * @param alpha defines alpha angle (in radians)
  101027. * @param beta defines beta angle (in radians)
  101028. * @param radius defines radius
  101029. * @param target defines camera target
  101030. * @param interaxialDistance defines distance between each color axis
  101031. * @param scene defines the hosting scene
  101032. */
  101033. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  101034. /**
  101035. * Gets camera class name
  101036. * @returns AnaglyphArcRotateCamera
  101037. */
  101038. getClassName(): string;
  101039. }
  101040. }
  101041. declare module BABYLON {
  101042. /**
  101043. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101044. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101045. */
  101046. export class AnaglyphFreeCamera extends FreeCamera {
  101047. /**
  101048. * Creates a new AnaglyphFreeCamera
  101049. * @param name defines camera name
  101050. * @param position defines initial position
  101051. * @param interaxialDistance defines distance between each color axis
  101052. * @param scene defines the hosting scene
  101053. */
  101054. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101055. /**
  101056. * Gets camera class name
  101057. * @returns AnaglyphFreeCamera
  101058. */
  101059. getClassName(): string;
  101060. }
  101061. }
  101062. declare module BABYLON {
  101063. /**
  101064. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101066. */
  101067. export class AnaglyphGamepadCamera extends GamepadCamera {
  101068. /**
  101069. * Creates a new AnaglyphGamepadCamera
  101070. * @param name defines camera name
  101071. * @param position defines initial position
  101072. * @param interaxialDistance defines distance between each color axis
  101073. * @param scene defines the hosting scene
  101074. */
  101075. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101076. /**
  101077. * Gets camera class name
  101078. * @returns AnaglyphGamepadCamera
  101079. */
  101080. getClassName(): string;
  101081. }
  101082. }
  101083. declare module BABYLON {
  101084. /**
  101085. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101086. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101087. */
  101088. export class AnaglyphUniversalCamera extends UniversalCamera {
  101089. /**
  101090. * Creates a new AnaglyphUniversalCamera
  101091. * @param name defines camera name
  101092. * @param position defines initial position
  101093. * @param interaxialDistance defines distance between each color axis
  101094. * @param scene defines the hosting scene
  101095. */
  101096. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101097. /**
  101098. * Gets camera class name
  101099. * @returns AnaglyphUniversalCamera
  101100. */
  101101. getClassName(): string;
  101102. }
  101103. }
  101104. declare module BABYLON {
  101105. /** @hidden */
  101106. export var stereoscopicInterlacePixelShader: {
  101107. name: string;
  101108. shader: string;
  101109. };
  101110. }
  101111. declare module BABYLON {
  101112. /**
  101113. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101114. */
  101115. export class StereoscopicInterlacePostProcess extends PostProcess {
  101116. private _stepSize;
  101117. private _passedProcess;
  101118. /**
  101119. * Initializes a StereoscopicInterlacePostProcess
  101120. * @param name The name of the effect.
  101121. * @param rigCameras The rig cameras to be appled to the post process
  101122. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101124. * @param engine The engine which the post process will be applied. (default: current engine)
  101125. * @param reusable If the post process can be reused on the same frame. (default: false)
  101126. */
  101127. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101128. }
  101129. }
  101130. declare module BABYLON {
  101131. /**
  101132. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101133. * @see http://doc.babylonjs.com/features/cameras
  101134. */
  101135. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101136. /**
  101137. * Creates a new StereoscopicArcRotateCamera
  101138. * @param name defines camera name
  101139. * @param alpha defines alpha angle (in radians)
  101140. * @param beta defines beta angle (in radians)
  101141. * @param radius defines radius
  101142. * @param target defines camera target
  101143. * @param interaxialDistance defines distance between each color axis
  101144. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101145. * @param scene defines the hosting scene
  101146. */
  101147. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101148. /**
  101149. * Gets camera class name
  101150. * @returns StereoscopicArcRotateCamera
  101151. */
  101152. getClassName(): string;
  101153. }
  101154. }
  101155. declare module BABYLON {
  101156. /**
  101157. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101158. * @see http://doc.babylonjs.com/features/cameras
  101159. */
  101160. export class StereoscopicFreeCamera extends FreeCamera {
  101161. /**
  101162. * Creates a new StereoscopicFreeCamera
  101163. * @param name defines camera name
  101164. * @param position defines initial position
  101165. * @param interaxialDistance defines distance between each color axis
  101166. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101167. * @param scene defines the hosting scene
  101168. */
  101169. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101170. /**
  101171. * Gets camera class name
  101172. * @returns StereoscopicFreeCamera
  101173. */
  101174. getClassName(): string;
  101175. }
  101176. }
  101177. declare module BABYLON {
  101178. /**
  101179. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101180. * @see http://doc.babylonjs.com/features/cameras
  101181. */
  101182. export class StereoscopicGamepadCamera extends GamepadCamera {
  101183. /**
  101184. * Creates a new StereoscopicGamepadCamera
  101185. * @param name defines camera name
  101186. * @param position defines initial position
  101187. * @param interaxialDistance defines distance between each color axis
  101188. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101189. * @param scene defines the hosting scene
  101190. */
  101191. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101192. /**
  101193. * Gets camera class name
  101194. * @returns StereoscopicGamepadCamera
  101195. */
  101196. getClassName(): string;
  101197. }
  101198. }
  101199. declare module BABYLON {
  101200. /**
  101201. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101202. * @see http://doc.babylonjs.com/features/cameras
  101203. */
  101204. export class StereoscopicUniversalCamera extends UniversalCamera {
  101205. /**
  101206. * Creates a new StereoscopicUniversalCamera
  101207. * @param name defines camera name
  101208. * @param position defines initial position
  101209. * @param interaxialDistance defines distance between each color axis
  101210. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101211. * @param scene defines the hosting scene
  101212. */
  101213. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101214. /**
  101215. * Gets camera class name
  101216. * @returns StereoscopicUniversalCamera
  101217. */
  101218. getClassName(): string;
  101219. }
  101220. }
  101221. declare module BABYLON {
  101222. /**
  101223. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101224. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101225. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101226. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101227. */
  101228. export class VirtualJoysticksCamera extends FreeCamera {
  101229. /**
  101230. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101231. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101232. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101233. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101234. * @param name Define the name of the camera in the scene
  101235. * @param position Define the start position of the camera in the scene
  101236. * @param scene Define the scene the camera belongs to
  101237. */
  101238. constructor(name: string, position: Vector3, scene: Scene);
  101239. /**
  101240. * Gets the current object class name.
  101241. * @return the class name
  101242. */
  101243. getClassName(): string;
  101244. }
  101245. }
  101246. declare module BABYLON {
  101247. /**
  101248. * This represents all the required metrics to create a VR camera.
  101249. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101250. */
  101251. export class VRCameraMetrics {
  101252. /**
  101253. * Define the horizontal resolution off the screen.
  101254. */
  101255. hResolution: number;
  101256. /**
  101257. * Define the vertical resolution off the screen.
  101258. */
  101259. vResolution: number;
  101260. /**
  101261. * Define the horizontal screen size.
  101262. */
  101263. hScreenSize: number;
  101264. /**
  101265. * Define the vertical screen size.
  101266. */
  101267. vScreenSize: number;
  101268. /**
  101269. * Define the vertical screen center position.
  101270. */
  101271. vScreenCenter: number;
  101272. /**
  101273. * Define the distance of the eyes to the screen.
  101274. */
  101275. eyeToScreenDistance: number;
  101276. /**
  101277. * Define the distance between both lenses
  101278. */
  101279. lensSeparationDistance: number;
  101280. /**
  101281. * Define the distance between both viewer's eyes.
  101282. */
  101283. interpupillaryDistance: number;
  101284. /**
  101285. * Define the distortion factor of the VR postprocess.
  101286. * Please, touch with care.
  101287. */
  101288. distortionK: number[];
  101289. /**
  101290. * Define the chromatic aberration correction factors for the VR post process.
  101291. */
  101292. chromaAbCorrection: number[];
  101293. /**
  101294. * Define the scale factor of the post process.
  101295. * The smaller the better but the slower.
  101296. */
  101297. postProcessScaleFactor: number;
  101298. /**
  101299. * Define an offset for the lens center.
  101300. */
  101301. lensCenterOffset: number;
  101302. /**
  101303. * Define if the current vr camera should compensate the distortion of the lense or not.
  101304. */
  101305. compensateDistortion: boolean;
  101306. /**
  101307. * Defines if multiview should be enabled when rendering (Default: false)
  101308. */
  101309. multiviewEnabled: boolean;
  101310. /**
  101311. * Gets the rendering aspect ratio based on the provided resolutions.
  101312. */
  101313. readonly aspectRatio: number;
  101314. /**
  101315. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101316. */
  101317. readonly aspectRatioFov: number;
  101318. /**
  101319. * @hidden
  101320. */
  101321. readonly leftHMatrix: Matrix;
  101322. /**
  101323. * @hidden
  101324. */
  101325. readonly rightHMatrix: Matrix;
  101326. /**
  101327. * @hidden
  101328. */
  101329. readonly leftPreViewMatrix: Matrix;
  101330. /**
  101331. * @hidden
  101332. */
  101333. readonly rightPreViewMatrix: Matrix;
  101334. /**
  101335. * Get the default VRMetrics based on the most generic setup.
  101336. * @returns the default vr metrics
  101337. */
  101338. static GetDefault(): VRCameraMetrics;
  101339. }
  101340. }
  101341. declare module BABYLON {
  101342. /** @hidden */
  101343. export var vrDistortionCorrectionPixelShader: {
  101344. name: string;
  101345. shader: string;
  101346. };
  101347. }
  101348. declare module BABYLON {
  101349. /**
  101350. * VRDistortionCorrectionPostProcess used for mobile VR
  101351. */
  101352. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101353. private _isRightEye;
  101354. private _distortionFactors;
  101355. private _postProcessScaleFactor;
  101356. private _lensCenterOffset;
  101357. private _scaleIn;
  101358. private _scaleFactor;
  101359. private _lensCenter;
  101360. /**
  101361. * Initializes the VRDistortionCorrectionPostProcess
  101362. * @param name The name of the effect.
  101363. * @param camera The camera to apply the render pass to.
  101364. * @param isRightEye If this is for the right eye distortion
  101365. * @param vrMetrics All the required metrics for the VR camera
  101366. */
  101367. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101368. }
  101369. }
  101370. declare module BABYLON {
  101371. /**
  101372. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101373. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101374. */
  101375. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101376. /**
  101377. * Creates a new VRDeviceOrientationArcRotateCamera
  101378. * @param name defines camera name
  101379. * @param alpha defines the camera rotation along the logitudinal axis
  101380. * @param beta defines the camera rotation along the latitudinal axis
  101381. * @param radius defines the camera distance from its target
  101382. * @param target defines the camera target
  101383. * @param scene defines the scene the camera belongs to
  101384. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101385. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101386. */
  101387. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101388. /**
  101389. * Gets camera class name
  101390. * @returns VRDeviceOrientationArcRotateCamera
  101391. */
  101392. getClassName(): string;
  101393. }
  101394. }
  101395. declare module BABYLON {
  101396. /**
  101397. * Camera used to simulate VR rendering (based on FreeCamera)
  101398. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101399. */
  101400. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101401. /**
  101402. * Creates a new VRDeviceOrientationFreeCamera
  101403. * @param name defines camera name
  101404. * @param position defines the start position of the camera
  101405. * @param scene defines the scene the camera belongs to
  101406. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101407. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101408. */
  101409. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101410. /**
  101411. * Gets camera class name
  101412. * @returns VRDeviceOrientationFreeCamera
  101413. */
  101414. getClassName(): string;
  101415. }
  101416. }
  101417. declare module BABYLON {
  101418. /**
  101419. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101420. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101421. */
  101422. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101423. /**
  101424. * Creates a new VRDeviceOrientationGamepadCamera
  101425. * @param name defines camera name
  101426. * @param position defines the start position of the camera
  101427. * @param scene defines the scene the camera belongs to
  101428. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101429. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101430. */
  101431. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101432. /**
  101433. * Gets camera class name
  101434. * @returns VRDeviceOrientationGamepadCamera
  101435. */
  101436. getClassName(): string;
  101437. }
  101438. }
  101439. declare module BABYLON {
  101440. /**
  101441. * Base class of materials working in push mode in babylon JS
  101442. * @hidden
  101443. */
  101444. export class PushMaterial extends Material {
  101445. protected _activeEffect: Effect;
  101446. protected _normalMatrix: Matrix;
  101447. /**
  101448. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101449. * This means that the material can keep using a previous shader while a new one is being compiled.
  101450. * This is mostly used when shader parallel compilation is supported (true by default)
  101451. */
  101452. allowShaderHotSwapping: boolean;
  101453. constructor(name: string, scene: Scene);
  101454. getEffect(): Effect;
  101455. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101456. /**
  101457. * Binds the given world matrix to the active effect
  101458. *
  101459. * @param world the matrix to bind
  101460. */
  101461. bindOnlyWorldMatrix(world: Matrix): void;
  101462. /**
  101463. * Binds the given normal matrix to the active effect
  101464. *
  101465. * @param normalMatrix the matrix to bind
  101466. */
  101467. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101468. bind(world: Matrix, mesh?: Mesh): void;
  101469. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101470. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101471. }
  101472. }
  101473. declare module BABYLON {
  101474. /**
  101475. * This groups all the flags used to control the materials channel.
  101476. */
  101477. export class MaterialFlags {
  101478. private static _DiffuseTextureEnabled;
  101479. /**
  101480. * Are diffuse textures enabled in the application.
  101481. */
  101482. static DiffuseTextureEnabled: boolean;
  101483. private static _AmbientTextureEnabled;
  101484. /**
  101485. * Are ambient textures enabled in the application.
  101486. */
  101487. static AmbientTextureEnabled: boolean;
  101488. private static _OpacityTextureEnabled;
  101489. /**
  101490. * Are opacity textures enabled in the application.
  101491. */
  101492. static OpacityTextureEnabled: boolean;
  101493. private static _ReflectionTextureEnabled;
  101494. /**
  101495. * Are reflection textures enabled in the application.
  101496. */
  101497. static ReflectionTextureEnabled: boolean;
  101498. private static _EmissiveTextureEnabled;
  101499. /**
  101500. * Are emissive textures enabled in the application.
  101501. */
  101502. static EmissiveTextureEnabled: boolean;
  101503. private static _SpecularTextureEnabled;
  101504. /**
  101505. * Are specular textures enabled in the application.
  101506. */
  101507. static SpecularTextureEnabled: boolean;
  101508. private static _BumpTextureEnabled;
  101509. /**
  101510. * Are bump textures enabled in the application.
  101511. */
  101512. static BumpTextureEnabled: boolean;
  101513. private static _LightmapTextureEnabled;
  101514. /**
  101515. * Are lightmap textures enabled in the application.
  101516. */
  101517. static LightmapTextureEnabled: boolean;
  101518. private static _RefractionTextureEnabled;
  101519. /**
  101520. * Are refraction textures enabled in the application.
  101521. */
  101522. static RefractionTextureEnabled: boolean;
  101523. private static _ColorGradingTextureEnabled;
  101524. /**
  101525. * Are color grading textures enabled in the application.
  101526. */
  101527. static ColorGradingTextureEnabled: boolean;
  101528. private static _FresnelEnabled;
  101529. /**
  101530. * Are fresnels enabled in the application.
  101531. */
  101532. static FresnelEnabled: boolean;
  101533. private static _ClearCoatTextureEnabled;
  101534. /**
  101535. * Are clear coat textures enabled in the application.
  101536. */
  101537. static ClearCoatTextureEnabled: boolean;
  101538. private static _ClearCoatBumpTextureEnabled;
  101539. /**
  101540. * Are clear coat bump textures enabled in the application.
  101541. */
  101542. static ClearCoatBumpTextureEnabled: boolean;
  101543. private static _ClearCoatTintTextureEnabled;
  101544. /**
  101545. * Are clear coat tint textures enabled in the application.
  101546. */
  101547. static ClearCoatTintTextureEnabled: boolean;
  101548. private static _SheenTextureEnabled;
  101549. /**
  101550. * Are sheen textures enabled in the application.
  101551. */
  101552. static SheenTextureEnabled: boolean;
  101553. private static _AnisotropicTextureEnabled;
  101554. /**
  101555. * Are anisotropic textures enabled in the application.
  101556. */
  101557. static AnisotropicTextureEnabled: boolean;
  101558. private static _ThicknessTextureEnabled;
  101559. /**
  101560. * Are thickness textures enabled in the application.
  101561. */
  101562. static ThicknessTextureEnabled: boolean;
  101563. }
  101564. }
  101565. declare module BABYLON {
  101566. /** @hidden */
  101567. export var defaultFragmentDeclaration: {
  101568. name: string;
  101569. shader: string;
  101570. };
  101571. }
  101572. declare module BABYLON {
  101573. /** @hidden */
  101574. export var defaultUboDeclaration: {
  101575. name: string;
  101576. shader: string;
  101577. };
  101578. }
  101579. declare module BABYLON {
  101580. /** @hidden */
  101581. export var lightFragmentDeclaration: {
  101582. name: string;
  101583. shader: string;
  101584. };
  101585. }
  101586. declare module BABYLON {
  101587. /** @hidden */
  101588. export var lightUboDeclaration: {
  101589. name: string;
  101590. shader: string;
  101591. };
  101592. }
  101593. declare module BABYLON {
  101594. /** @hidden */
  101595. export var lightsFragmentFunctions: {
  101596. name: string;
  101597. shader: string;
  101598. };
  101599. }
  101600. declare module BABYLON {
  101601. /** @hidden */
  101602. export var shadowsFragmentFunctions: {
  101603. name: string;
  101604. shader: string;
  101605. };
  101606. }
  101607. declare module BABYLON {
  101608. /** @hidden */
  101609. export var fresnelFunction: {
  101610. name: string;
  101611. shader: string;
  101612. };
  101613. }
  101614. declare module BABYLON {
  101615. /** @hidden */
  101616. export var reflectionFunction: {
  101617. name: string;
  101618. shader: string;
  101619. };
  101620. }
  101621. declare module BABYLON {
  101622. /** @hidden */
  101623. export var bumpFragmentFunctions: {
  101624. name: string;
  101625. shader: string;
  101626. };
  101627. }
  101628. declare module BABYLON {
  101629. /** @hidden */
  101630. export var logDepthDeclaration: {
  101631. name: string;
  101632. shader: string;
  101633. };
  101634. }
  101635. declare module BABYLON {
  101636. /** @hidden */
  101637. export var bumpFragment: {
  101638. name: string;
  101639. shader: string;
  101640. };
  101641. }
  101642. declare module BABYLON {
  101643. /** @hidden */
  101644. export var depthPrePass: {
  101645. name: string;
  101646. shader: string;
  101647. };
  101648. }
  101649. declare module BABYLON {
  101650. /** @hidden */
  101651. export var lightFragment: {
  101652. name: string;
  101653. shader: string;
  101654. };
  101655. }
  101656. declare module BABYLON {
  101657. /** @hidden */
  101658. export var logDepthFragment: {
  101659. name: string;
  101660. shader: string;
  101661. };
  101662. }
  101663. declare module BABYLON {
  101664. /** @hidden */
  101665. export var defaultPixelShader: {
  101666. name: string;
  101667. shader: string;
  101668. };
  101669. }
  101670. declare module BABYLON {
  101671. /** @hidden */
  101672. export var defaultVertexDeclaration: {
  101673. name: string;
  101674. shader: string;
  101675. };
  101676. }
  101677. declare module BABYLON {
  101678. /** @hidden */
  101679. export var bumpVertexDeclaration: {
  101680. name: string;
  101681. shader: string;
  101682. };
  101683. }
  101684. declare module BABYLON {
  101685. /** @hidden */
  101686. export var bumpVertex: {
  101687. name: string;
  101688. shader: string;
  101689. };
  101690. }
  101691. declare module BABYLON {
  101692. /** @hidden */
  101693. export var fogVertex: {
  101694. name: string;
  101695. shader: string;
  101696. };
  101697. }
  101698. declare module BABYLON {
  101699. /** @hidden */
  101700. export var shadowsVertex: {
  101701. name: string;
  101702. shader: string;
  101703. };
  101704. }
  101705. declare module BABYLON {
  101706. /** @hidden */
  101707. export var pointCloudVertex: {
  101708. name: string;
  101709. shader: string;
  101710. };
  101711. }
  101712. declare module BABYLON {
  101713. /** @hidden */
  101714. export var logDepthVertex: {
  101715. name: string;
  101716. shader: string;
  101717. };
  101718. }
  101719. declare module BABYLON {
  101720. /** @hidden */
  101721. export var defaultVertexShader: {
  101722. name: string;
  101723. shader: string;
  101724. };
  101725. }
  101726. declare module BABYLON {
  101727. /** @hidden */
  101728. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101729. MAINUV1: boolean;
  101730. MAINUV2: boolean;
  101731. DIFFUSE: boolean;
  101732. DIFFUSEDIRECTUV: number;
  101733. AMBIENT: boolean;
  101734. AMBIENTDIRECTUV: number;
  101735. OPACITY: boolean;
  101736. OPACITYDIRECTUV: number;
  101737. OPACITYRGB: boolean;
  101738. REFLECTION: boolean;
  101739. EMISSIVE: boolean;
  101740. EMISSIVEDIRECTUV: number;
  101741. SPECULAR: boolean;
  101742. SPECULARDIRECTUV: number;
  101743. BUMP: boolean;
  101744. BUMPDIRECTUV: number;
  101745. PARALLAX: boolean;
  101746. PARALLAXOCCLUSION: boolean;
  101747. SPECULAROVERALPHA: boolean;
  101748. CLIPPLANE: boolean;
  101749. CLIPPLANE2: boolean;
  101750. CLIPPLANE3: boolean;
  101751. CLIPPLANE4: boolean;
  101752. ALPHATEST: boolean;
  101753. DEPTHPREPASS: boolean;
  101754. ALPHAFROMDIFFUSE: boolean;
  101755. POINTSIZE: boolean;
  101756. FOG: boolean;
  101757. SPECULARTERM: boolean;
  101758. DIFFUSEFRESNEL: boolean;
  101759. OPACITYFRESNEL: boolean;
  101760. REFLECTIONFRESNEL: boolean;
  101761. REFRACTIONFRESNEL: boolean;
  101762. EMISSIVEFRESNEL: boolean;
  101763. FRESNEL: boolean;
  101764. NORMAL: boolean;
  101765. UV1: boolean;
  101766. UV2: boolean;
  101767. VERTEXCOLOR: boolean;
  101768. VERTEXALPHA: boolean;
  101769. NUM_BONE_INFLUENCERS: number;
  101770. BonesPerMesh: number;
  101771. BONETEXTURE: boolean;
  101772. INSTANCES: boolean;
  101773. GLOSSINESS: boolean;
  101774. ROUGHNESS: boolean;
  101775. EMISSIVEASILLUMINATION: boolean;
  101776. LINKEMISSIVEWITHDIFFUSE: boolean;
  101777. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101778. LIGHTMAP: boolean;
  101779. LIGHTMAPDIRECTUV: number;
  101780. OBJECTSPACE_NORMALMAP: boolean;
  101781. USELIGHTMAPASSHADOWMAP: boolean;
  101782. REFLECTIONMAP_3D: boolean;
  101783. REFLECTIONMAP_SPHERICAL: boolean;
  101784. REFLECTIONMAP_PLANAR: boolean;
  101785. REFLECTIONMAP_CUBIC: boolean;
  101786. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101787. REFLECTIONMAP_PROJECTION: boolean;
  101788. REFLECTIONMAP_SKYBOX: boolean;
  101789. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101790. REFLECTIONMAP_EXPLICIT: boolean;
  101791. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101792. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101793. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101794. INVERTCUBICMAP: boolean;
  101795. LOGARITHMICDEPTH: boolean;
  101796. REFRACTION: boolean;
  101797. REFRACTIONMAP_3D: boolean;
  101798. REFLECTIONOVERALPHA: boolean;
  101799. TWOSIDEDLIGHTING: boolean;
  101800. SHADOWFLOAT: boolean;
  101801. MORPHTARGETS: boolean;
  101802. MORPHTARGETS_NORMAL: boolean;
  101803. MORPHTARGETS_TANGENT: boolean;
  101804. MORPHTARGETS_UV: boolean;
  101805. NUM_MORPH_INFLUENCERS: number;
  101806. NONUNIFORMSCALING: boolean;
  101807. PREMULTIPLYALPHA: boolean;
  101808. IMAGEPROCESSING: boolean;
  101809. VIGNETTE: boolean;
  101810. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101811. VIGNETTEBLENDMODEOPAQUE: boolean;
  101812. TONEMAPPING: boolean;
  101813. TONEMAPPING_ACES: boolean;
  101814. CONTRAST: boolean;
  101815. COLORCURVES: boolean;
  101816. COLORGRADING: boolean;
  101817. COLORGRADING3D: boolean;
  101818. SAMPLER3DGREENDEPTH: boolean;
  101819. SAMPLER3DBGRMAP: boolean;
  101820. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101821. MULTIVIEW: boolean;
  101822. /**
  101823. * If the reflection texture on this material is in linear color space
  101824. * @hidden
  101825. */
  101826. IS_REFLECTION_LINEAR: boolean;
  101827. /**
  101828. * If the refraction texture on this material is in linear color space
  101829. * @hidden
  101830. */
  101831. IS_REFRACTION_LINEAR: boolean;
  101832. EXPOSURE: boolean;
  101833. constructor();
  101834. setReflectionMode(modeToEnable: string): void;
  101835. }
  101836. /**
  101837. * This is the default material used in Babylon. It is the best trade off between quality
  101838. * and performances.
  101839. * @see http://doc.babylonjs.com/babylon101/materials
  101840. */
  101841. export class StandardMaterial extends PushMaterial {
  101842. private _diffuseTexture;
  101843. /**
  101844. * The basic texture of the material as viewed under a light.
  101845. */
  101846. diffuseTexture: Nullable<BaseTexture>;
  101847. private _ambientTexture;
  101848. /**
  101849. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101850. */
  101851. ambientTexture: Nullable<BaseTexture>;
  101852. private _opacityTexture;
  101853. /**
  101854. * Define the transparency of the material from a texture.
  101855. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101856. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101857. */
  101858. opacityTexture: Nullable<BaseTexture>;
  101859. private _reflectionTexture;
  101860. /**
  101861. * Define the texture used to display the reflection.
  101862. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101863. */
  101864. reflectionTexture: Nullable<BaseTexture>;
  101865. private _emissiveTexture;
  101866. /**
  101867. * Define texture of the material as if self lit.
  101868. * This will be mixed in the final result even in the absence of light.
  101869. */
  101870. emissiveTexture: Nullable<BaseTexture>;
  101871. private _specularTexture;
  101872. /**
  101873. * Define how the color and intensity of the highlight given by the light in the material.
  101874. */
  101875. specularTexture: Nullable<BaseTexture>;
  101876. private _bumpTexture;
  101877. /**
  101878. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101879. * 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.
  101880. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101881. */
  101882. bumpTexture: Nullable<BaseTexture>;
  101883. private _lightmapTexture;
  101884. /**
  101885. * Complex lighting can be computationally expensive to compute at runtime.
  101886. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101887. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101888. */
  101889. lightmapTexture: Nullable<BaseTexture>;
  101890. private _refractionTexture;
  101891. /**
  101892. * Define the texture used to display the refraction.
  101893. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101894. */
  101895. refractionTexture: Nullable<BaseTexture>;
  101896. /**
  101897. * The color of the material lit by the environmental background lighting.
  101898. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101899. */
  101900. ambientColor: Color3;
  101901. /**
  101902. * The basic color of the material as viewed under a light.
  101903. */
  101904. diffuseColor: Color3;
  101905. /**
  101906. * Define how the color and intensity of the highlight given by the light in the material.
  101907. */
  101908. specularColor: Color3;
  101909. /**
  101910. * Define the color of the material as if self lit.
  101911. * This will be mixed in the final result even in the absence of light.
  101912. */
  101913. emissiveColor: Color3;
  101914. /**
  101915. * Defines how sharp are the highlights in the material.
  101916. * The bigger the value the sharper giving a more glossy feeling to the result.
  101917. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101918. */
  101919. specularPower: number;
  101920. private _useAlphaFromDiffuseTexture;
  101921. /**
  101922. * Does the transparency come from the diffuse texture alpha channel.
  101923. */
  101924. useAlphaFromDiffuseTexture: boolean;
  101925. private _useEmissiveAsIllumination;
  101926. /**
  101927. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101928. */
  101929. useEmissiveAsIllumination: boolean;
  101930. private _linkEmissiveWithDiffuse;
  101931. /**
  101932. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101933. * the emissive level when the final color is close to one.
  101934. */
  101935. linkEmissiveWithDiffuse: boolean;
  101936. private _useSpecularOverAlpha;
  101937. /**
  101938. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101939. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101940. */
  101941. useSpecularOverAlpha: boolean;
  101942. private _useReflectionOverAlpha;
  101943. /**
  101944. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101945. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101946. */
  101947. useReflectionOverAlpha: boolean;
  101948. private _disableLighting;
  101949. /**
  101950. * Does lights from the scene impacts this material.
  101951. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101952. */
  101953. disableLighting: boolean;
  101954. private _useObjectSpaceNormalMap;
  101955. /**
  101956. * Allows using an object space normal map (instead of tangent space).
  101957. */
  101958. useObjectSpaceNormalMap: boolean;
  101959. private _useParallax;
  101960. /**
  101961. * Is parallax enabled or not.
  101962. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101963. */
  101964. useParallax: boolean;
  101965. private _useParallaxOcclusion;
  101966. /**
  101967. * Is parallax occlusion enabled or not.
  101968. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101969. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101970. */
  101971. useParallaxOcclusion: boolean;
  101972. /**
  101973. * 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.
  101974. */
  101975. parallaxScaleBias: number;
  101976. private _roughness;
  101977. /**
  101978. * Helps to define how blurry the reflections should appears in the material.
  101979. */
  101980. roughness: number;
  101981. /**
  101982. * In case of refraction, define the value of the index of refraction.
  101983. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101984. */
  101985. indexOfRefraction: number;
  101986. /**
  101987. * Invert the refraction texture alongside the y axis.
  101988. * It can be useful with procedural textures or probe for instance.
  101989. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101990. */
  101991. invertRefractionY: boolean;
  101992. /**
  101993. * Defines the alpha limits in alpha test mode.
  101994. */
  101995. alphaCutOff: number;
  101996. private _useLightmapAsShadowmap;
  101997. /**
  101998. * In case of light mapping, define whether the map contains light or shadow informations.
  101999. */
  102000. useLightmapAsShadowmap: boolean;
  102001. private _diffuseFresnelParameters;
  102002. /**
  102003. * Define the diffuse fresnel parameters of the material.
  102004. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102005. */
  102006. diffuseFresnelParameters: FresnelParameters;
  102007. private _opacityFresnelParameters;
  102008. /**
  102009. * Define the opacity fresnel parameters of the material.
  102010. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102011. */
  102012. opacityFresnelParameters: FresnelParameters;
  102013. private _reflectionFresnelParameters;
  102014. /**
  102015. * Define the reflection fresnel parameters of the material.
  102016. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102017. */
  102018. reflectionFresnelParameters: FresnelParameters;
  102019. private _refractionFresnelParameters;
  102020. /**
  102021. * Define the refraction fresnel parameters of the material.
  102022. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102023. */
  102024. refractionFresnelParameters: FresnelParameters;
  102025. private _emissiveFresnelParameters;
  102026. /**
  102027. * Define the emissive fresnel parameters of the material.
  102028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102029. */
  102030. emissiveFresnelParameters: FresnelParameters;
  102031. private _useReflectionFresnelFromSpecular;
  102032. /**
  102033. * If true automatically deducts the fresnels values from the material specularity.
  102034. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  102035. */
  102036. useReflectionFresnelFromSpecular: boolean;
  102037. private _useGlossinessFromSpecularMapAlpha;
  102038. /**
  102039. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  102040. */
  102041. useGlossinessFromSpecularMapAlpha: boolean;
  102042. private _maxSimultaneousLights;
  102043. /**
  102044. * Defines the maximum number of lights that can be used in the material
  102045. */
  102046. maxSimultaneousLights: number;
  102047. private _invertNormalMapX;
  102048. /**
  102049. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102050. */
  102051. invertNormalMapX: boolean;
  102052. private _invertNormalMapY;
  102053. /**
  102054. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102055. */
  102056. invertNormalMapY: boolean;
  102057. private _twoSidedLighting;
  102058. /**
  102059. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102060. */
  102061. twoSidedLighting: boolean;
  102062. /**
  102063. * Default configuration related to image processing available in the standard Material.
  102064. */
  102065. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102066. /**
  102067. * Gets the image processing configuration used either in this material.
  102068. */
  102069. /**
  102070. * Sets the Default image processing configuration used either in the this material.
  102071. *
  102072. * If sets to null, the scene one is in use.
  102073. */
  102074. imageProcessingConfiguration: ImageProcessingConfiguration;
  102075. /**
  102076. * Keep track of the image processing observer to allow dispose and replace.
  102077. */
  102078. private _imageProcessingObserver;
  102079. /**
  102080. * Attaches a new image processing configuration to the Standard Material.
  102081. * @param configuration
  102082. */
  102083. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102084. /**
  102085. * Gets wether the color curves effect is enabled.
  102086. */
  102087. /**
  102088. * Sets wether the color curves effect is enabled.
  102089. */
  102090. cameraColorCurvesEnabled: boolean;
  102091. /**
  102092. * Gets wether the color grading effect is enabled.
  102093. */
  102094. /**
  102095. * Gets wether the color grading effect is enabled.
  102096. */
  102097. cameraColorGradingEnabled: boolean;
  102098. /**
  102099. * Gets wether tonemapping is enabled or not.
  102100. */
  102101. /**
  102102. * Sets wether tonemapping is enabled or not
  102103. */
  102104. cameraToneMappingEnabled: boolean;
  102105. /**
  102106. * The camera exposure used on this material.
  102107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102108. * This corresponds to a photographic exposure.
  102109. */
  102110. /**
  102111. * The camera exposure used on this material.
  102112. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102113. * This corresponds to a photographic exposure.
  102114. */
  102115. cameraExposure: number;
  102116. /**
  102117. * Gets The camera contrast used on this material.
  102118. */
  102119. /**
  102120. * Sets The camera contrast used on this material.
  102121. */
  102122. cameraContrast: number;
  102123. /**
  102124. * Gets the Color Grading 2D Lookup Texture.
  102125. */
  102126. /**
  102127. * Sets the Color Grading 2D Lookup Texture.
  102128. */
  102129. cameraColorGradingTexture: Nullable<BaseTexture>;
  102130. /**
  102131. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102132. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102133. * 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;
  102134. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102135. */
  102136. /**
  102137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102139. * 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;
  102140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102141. */
  102142. cameraColorCurves: Nullable<ColorCurves>;
  102143. /**
  102144. * Custom callback helping to override the default shader used in the material.
  102145. */
  102146. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102147. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102148. protected _worldViewProjectionMatrix: Matrix;
  102149. protected _globalAmbientColor: Color3;
  102150. protected _useLogarithmicDepth: boolean;
  102151. /**
  102152. * Instantiates a new standard material.
  102153. * This is the default material used in Babylon. It is the best trade off between quality
  102154. * and performances.
  102155. * @see http://doc.babylonjs.com/babylon101/materials
  102156. * @param name Define the name of the material in the scene
  102157. * @param scene Define the scene the material belong to
  102158. */
  102159. constructor(name: string, scene: Scene);
  102160. /**
  102161. * Gets a boolean indicating that current material needs to register RTT
  102162. */
  102163. readonly hasRenderTargetTextures: boolean;
  102164. /**
  102165. * Gets the current class name of the material e.g. "StandardMaterial"
  102166. * Mainly use in serialization.
  102167. * @returns the class name
  102168. */
  102169. getClassName(): string;
  102170. /**
  102171. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102172. * You can try switching to logarithmic depth.
  102173. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102174. */
  102175. useLogarithmicDepth: boolean;
  102176. /**
  102177. * Specifies if the material will require alpha blending
  102178. * @returns a boolean specifying if alpha blending is needed
  102179. */
  102180. needAlphaBlending(): boolean;
  102181. /**
  102182. * Specifies if this material should be rendered in alpha test mode
  102183. * @returns a boolean specifying if an alpha test is needed.
  102184. */
  102185. needAlphaTesting(): boolean;
  102186. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102187. /**
  102188. * Get the texture used for alpha test purpose.
  102189. * @returns the diffuse texture in case of the standard material.
  102190. */
  102191. getAlphaTestTexture(): Nullable<BaseTexture>;
  102192. /**
  102193. * Get if the submesh is ready to be used and all its information available.
  102194. * Child classes can use it to update shaders
  102195. * @param mesh defines the mesh to check
  102196. * @param subMesh defines which submesh to check
  102197. * @param useInstances specifies that instances should be used
  102198. * @returns a boolean indicating that the submesh is ready or not
  102199. */
  102200. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102201. /**
  102202. * Builds the material UBO layouts.
  102203. * Used internally during the effect preparation.
  102204. */
  102205. buildUniformLayout(): void;
  102206. /**
  102207. * Unbinds the material from the mesh
  102208. */
  102209. unbind(): void;
  102210. /**
  102211. * Binds the submesh to this material by preparing the effect and shader to draw
  102212. * @param world defines the world transformation matrix
  102213. * @param mesh defines the mesh containing the submesh
  102214. * @param subMesh defines the submesh to bind the material to
  102215. */
  102216. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102217. /**
  102218. * Get the list of animatables in the material.
  102219. * @returns the list of animatables object used in the material
  102220. */
  102221. getAnimatables(): IAnimatable[];
  102222. /**
  102223. * Gets the active textures from the material
  102224. * @returns an array of textures
  102225. */
  102226. getActiveTextures(): BaseTexture[];
  102227. /**
  102228. * Specifies if the material uses a texture
  102229. * @param texture defines the texture to check against the material
  102230. * @returns a boolean specifying if the material uses the texture
  102231. */
  102232. hasTexture(texture: BaseTexture): boolean;
  102233. /**
  102234. * Disposes the material
  102235. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102236. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102237. */
  102238. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102239. /**
  102240. * Makes a duplicate of the material, and gives it a new name
  102241. * @param name defines the new name for the duplicated material
  102242. * @returns the cloned material
  102243. */
  102244. clone(name: string): StandardMaterial;
  102245. /**
  102246. * Serializes this material in a JSON representation
  102247. * @returns the serialized material object
  102248. */
  102249. serialize(): any;
  102250. /**
  102251. * Creates a standard material from parsed material data
  102252. * @param source defines the JSON representation of the material
  102253. * @param scene defines the hosting scene
  102254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102255. * @returns a new standard material
  102256. */
  102257. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102258. /**
  102259. * Are diffuse textures enabled in the application.
  102260. */
  102261. static DiffuseTextureEnabled: boolean;
  102262. /**
  102263. * Are ambient textures enabled in the application.
  102264. */
  102265. static AmbientTextureEnabled: boolean;
  102266. /**
  102267. * Are opacity textures enabled in the application.
  102268. */
  102269. static OpacityTextureEnabled: boolean;
  102270. /**
  102271. * Are reflection textures enabled in the application.
  102272. */
  102273. static ReflectionTextureEnabled: boolean;
  102274. /**
  102275. * Are emissive textures enabled in the application.
  102276. */
  102277. static EmissiveTextureEnabled: boolean;
  102278. /**
  102279. * Are specular textures enabled in the application.
  102280. */
  102281. static SpecularTextureEnabled: boolean;
  102282. /**
  102283. * Are bump textures enabled in the application.
  102284. */
  102285. static BumpTextureEnabled: boolean;
  102286. /**
  102287. * Are lightmap textures enabled in the application.
  102288. */
  102289. static LightmapTextureEnabled: boolean;
  102290. /**
  102291. * Are refraction textures enabled in the application.
  102292. */
  102293. static RefractionTextureEnabled: boolean;
  102294. /**
  102295. * Are color grading textures enabled in the application.
  102296. */
  102297. static ColorGradingTextureEnabled: boolean;
  102298. /**
  102299. * Are fresnels enabled in the application.
  102300. */
  102301. static FresnelEnabled: boolean;
  102302. }
  102303. }
  102304. declare module BABYLON {
  102305. /**
  102306. * A class extending Texture allowing drawing on a texture
  102307. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102308. */
  102309. export class DynamicTexture extends Texture {
  102310. private _generateMipMaps;
  102311. private _canvas;
  102312. private _context;
  102313. private _engine;
  102314. /**
  102315. * Creates a DynamicTexture
  102316. * @param name defines the name of the texture
  102317. * @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
  102318. * @param scene defines the scene where you want the texture
  102319. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102320. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102321. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102322. */
  102323. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102324. /**
  102325. * Get the current class name of the texture useful for serialization or dynamic coding.
  102326. * @returns "DynamicTexture"
  102327. */
  102328. getClassName(): string;
  102329. /**
  102330. * Gets the current state of canRescale
  102331. */
  102332. readonly canRescale: boolean;
  102333. private _recreate;
  102334. /**
  102335. * Scales the texture
  102336. * @param ratio the scale factor to apply to both width and height
  102337. */
  102338. scale(ratio: number): void;
  102339. /**
  102340. * Resizes the texture
  102341. * @param width the new width
  102342. * @param height the new height
  102343. */
  102344. scaleTo(width: number, height: number): void;
  102345. /**
  102346. * Gets the context of the canvas used by the texture
  102347. * @returns the canvas context of the dynamic texture
  102348. */
  102349. getContext(): CanvasRenderingContext2D;
  102350. /**
  102351. * Clears the texture
  102352. */
  102353. clear(): void;
  102354. /**
  102355. * Updates the texture
  102356. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102357. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102358. */
  102359. update(invertY?: boolean, premulAlpha?: boolean): void;
  102360. /**
  102361. * Draws text onto the texture
  102362. * @param text defines the text to be drawn
  102363. * @param x defines the placement of the text from the left
  102364. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102365. * @param font defines the font to be used with font-style, font-size, font-name
  102366. * @param color defines the color used for the text
  102367. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102368. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102369. * @param update defines whether texture is immediately update (default is true)
  102370. */
  102371. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102372. /**
  102373. * Clones the texture
  102374. * @returns the clone of the texture.
  102375. */
  102376. clone(): DynamicTexture;
  102377. /**
  102378. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102379. * @returns a serialized dynamic texture object
  102380. */
  102381. serialize(): any;
  102382. /** @hidden */
  102383. _rebuild(): void;
  102384. }
  102385. }
  102386. declare module BABYLON {
  102387. /** @hidden */
  102388. export var imageProcessingPixelShader: {
  102389. name: string;
  102390. shader: string;
  102391. };
  102392. }
  102393. declare module BABYLON {
  102394. /**
  102395. * ImageProcessingPostProcess
  102396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102397. */
  102398. export class ImageProcessingPostProcess extends PostProcess {
  102399. /**
  102400. * Default configuration related to image processing available in the PBR Material.
  102401. */
  102402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102403. /**
  102404. * Gets the image processing configuration used either in this material.
  102405. */
  102406. /**
  102407. * Sets the Default image processing configuration used either in the this material.
  102408. *
  102409. * If sets to null, the scene one is in use.
  102410. */
  102411. imageProcessingConfiguration: ImageProcessingConfiguration;
  102412. /**
  102413. * Keep track of the image processing observer to allow dispose and replace.
  102414. */
  102415. private _imageProcessingObserver;
  102416. /**
  102417. * Attaches a new image processing configuration to the PBR Material.
  102418. * @param configuration
  102419. */
  102420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102421. /**
  102422. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102423. */
  102424. /**
  102425. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102426. */
  102427. colorCurves: Nullable<ColorCurves>;
  102428. /**
  102429. * Gets wether the color curves effect is enabled.
  102430. */
  102431. /**
  102432. * Sets wether the color curves effect is enabled.
  102433. */
  102434. colorCurvesEnabled: boolean;
  102435. /**
  102436. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102437. */
  102438. /**
  102439. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102440. */
  102441. colorGradingTexture: Nullable<BaseTexture>;
  102442. /**
  102443. * Gets wether the color grading effect is enabled.
  102444. */
  102445. /**
  102446. * Gets wether the color grading effect is enabled.
  102447. */
  102448. colorGradingEnabled: boolean;
  102449. /**
  102450. * Gets exposure used in the effect.
  102451. */
  102452. /**
  102453. * Sets exposure used in the effect.
  102454. */
  102455. exposure: number;
  102456. /**
  102457. * Gets wether tonemapping is enabled or not.
  102458. */
  102459. /**
  102460. * Sets wether tonemapping is enabled or not
  102461. */
  102462. toneMappingEnabled: boolean;
  102463. /**
  102464. * Gets the type of tone mapping effect.
  102465. */
  102466. /**
  102467. * Sets the type of tone mapping effect.
  102468. */
  102469. toneMappingType: number;
  102470. /**
  102471. * Gets contrast used in the effect.
  102472. */
  102473. /**
  102474. * Sets contrast used in the effect.
  102475. */
  102476. contrast: number;
  102477. /**
  102478. * Gets Vignette stretch size.
  102479. */
  102480. /**
  102481. * Sets Vignette stretch size.
  102482. */
  102483. vignetteStretch: number;
  102484. /**
  102485. * Gets Vignette centre X Offset.
  102486. */
  102487. /**
  102488. * Sets Vignette centre X Offset.
  102489. */
  102490. vignetteCentreX: number;
  102491. /**
  102492. * Gets Vignette centre Y Offset.
  102493. */
  102494. /**
  102495. * Sets Vignette centre Y Offset.
  102496. */
  102497. vignetteCentreY: number;
  102498. /**
  102499. * Gets Vignette weight or intensity of the vignette effect.
  102500. */
  102501. /**
  102502. * Sets Vignette weight or intensity of the vignette effect.
  102503. */
  102504. vignetteWeight: number;
  102505. /**
  102506. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102507. * if vignetteEnabled is set to true.
  102508. */
  102509. /**
  102510. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102511. * if vignetteEnabled is set to true.
  102512. */
  102513. vignetteColor: Color4;
  102514. /**
  102515. * Gets Camera field of view used by the Vignette effect.
  102516. */
  102517. /**
  102518. * Sets Camera field of view used by the Vignette effect.
  102519. */
  102520. vignetteCameraFov: number;
  102521. /**
  102522. * Gets the vignette blend mode allowing different kind of effect.
  102523. */
  102524. /**
  102525. * Sets the vignette blend mode allowing different kind of effect.
  102526. */
  102527. vignetteBlendMode: number;
  102528. /**
  102529. * Gets wether the vignette effect is enabled.
  102530. */
  102531. /**
  102532. * Sets wether the vignette effect is enabled.
  102533. */
  102534. vignetteEnabled: boolean;
  102535. private _fromLinearSpace;
  102536. /**
  102537. * Gets wether the input of the processing is in Gamma or Linear Space.
  102538. */
  102539. /**
  102540. * Sets wether the input of the processing is in Gamma or Linear Space.
  102541. */
  102542. fromLinearSpace: boolean;
  102543. /**
  102544. * Defines cache preventing GC.
  102545. */
  102546. private _defines;
  102547. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102548. /**
  102549. * "ImageProcessingPostProcess"
  102550. * @returns "ImageProcessingPostProcess"
  102551. */
  102552. getClassName(): string;
  102553. protected _updateParameters(): void;
  102554. dispose(camera?: Camera): void;
  102555. }
  102556. }
  102557. declare module BABYLON {
  102558. /**
  102559. * Class containing static functions to help procedurally build meshes
  102560. */
  102561. export class GroundBuilder {
  102562. /**
  102563. * Creates a ground mesh
  102564. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102565. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102567. * @param name defines the name of the mesh
  102568. * @param options defines the options used to create the mesh
  102569. * @param scene defines the hosting scene
  102570. * @returns the ground mesh
  102571. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102572. */
  102573. static CreateGround(name: string, options: {
  102574. width?: number;
  102575. height?: number;
  102576. subdivisions?: number;
  102577. subdivisionsX?: number;
  102578. subdivisionsY?: number;
  102579. updatable?: boolean;
  102580. }, scene: any): Mesh;
  102581. /**
  102582. * Creates a tiled ground mesh
  102583. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102584. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102585. * * 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
  102586. * * 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
  102587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102588. * @param name defines the name of the mesh
  102589. * @param options defines the options used to create the mesh
  102590. * @param scene defines the hosting scene
  102591. * @returns the tiled ground mesh
  102592. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102593. */
  102594. static CreateTiledGround(name: string, options: {
  102595. xmin: number;
  102596. zmin: number;
  102597. xmax: number;
  102598. zmax: number;
  102599. subdivisions?: {
  102600. w: number;
  102601. h: number;
  102602. };
  102603. precision?: {
  102604. w: number;
  102605. h: number;
  102606. };
  102607. updatable?: boolean;
  102608. }, scene?: Nullable<Scene>): Mesh;
  102609. /**
  102610. * Creates a ground mesh from a height map
  102611. * * The parameter `url` sets the URL of the height map image resource.
  102612. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102613. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102614. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102615. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102616. * * 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.
  102617. * * 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).
  102618. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102620. * @param name defines the name of the mesh
  102621. * @param url defines the url to the height map
  102622. * @param options defines the options used to create the mesh
  102623. * @param scene defines the hosting scene
  102624. * @returns the ground mesh
  102625. * @see https://doc.babylonjs.com/babylon101/height_map
  102626. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102627. */
  102628. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102629. width?: number;
  102630. height?: number;
  102631. subdivisions?: number;
  102632. minHeight?: number;
  102633. maxHeight?: number;
  102634. colorFilter?: Color3;
  102635. alphaFilter?: number;
  102636. updatable?: boolean;
  102637. onReady?: (mesh: GroundMesh) => void;
  102638. }, scene?: Nullable<Scene>): GroundMesh;
  102639. }
  102640. }
  102641. declare module BABYLON {
  102642. /**
  102643. * Class containing static functions to help procedurally build meshes
  102644. */
  102645. export class TorusBuilder {
  102646. /**
  102647. * Creates a torus mesh
  102648. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102649. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102650. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102654. * @param name defines the name of the mesh
  102655. * @param options defines the options used to create the mesh
  102656. * @param scene defines the hosting scene
  102657. * @returns the torus mesh
  102658. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102659. */
  102660. static CreateTorus(name: string, options: {
  102661. diameter?: number;
  102662. thickness?: number;
  102663. tessellation?: number;
  102664. updatable?: boolean;
  102665. sideOrientation?: number;
  102666. frontUVs?: Vector4;
  102667. backUVs?: Vector4;
  102668. }, scene: any): Mesh;
  102669. }
  102670. }
  102671. declare module BABYLON {
  102672. /**
  102673. * Class containing static functions to help procedurally build meshes
  102674. */
  102675. export class CylinderBuilder {
  102676. /**
  102677. * Creates a cylinder or a cone mesh
  102678. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102679. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102680. * * 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.
  102681. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102682. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102683. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102684. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102685. * * 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).
  102686. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102687. * * 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).
  102688. * * 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
  102689. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102690. * * 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
  102691. * * 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.
  102692. * * If `enclose` is false, a ring surface is one element.
  102693. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102694. * * 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
  102695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102698. * @param name defines the name of the mesh
  102699. * @param options defines the options used to create the mesh
  102700. * @param scene defines the hosting scene
  102701. * @returns the cylinder mesh
  102702. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102703. */
  102704. static CreateCylinder(name: string, options: {
  102705. height?: number;
  102706. diameterTop?: number;
  102707. diameterBottom?: number;
  102708. diameter?: number;
  102709. tessellation?: number;
  102710. subdivisions?: number;
  102711. arc?: number;
  102712. faceColors?: Color4[];
  102713. faceUV?: Vector4[];
  102714. updatable?: boolean;
  102715. hasRings?: boolean;
  102716. enclose?: boolean;
  102717. cap?: number;
  102718. sideOrientation?: number;
  102719. frontUVs?: Vector4;
  102720. backUVs?: Vector4;
  102721. }, scene: any): Mesh;
  102722. }
  102723. }
  102724. declare module BABYLON {
  102725. /**
  102726. * Options to modify the vr teleportation behavior.
  102727. */
  102728. export interface VRTeleportationOptions {
  102729. /**
  102730. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102731. */
  102732. floorMeshName?: string;
  102733. /**
  102734. * A list of meshes to be used as the teleportation floor. (default: empty)
  102735. */
  102736. floorMeshes?: Mesh[];
  102737. }
  102738. /**
  102739. * Options to modify the vr experience helper's behavior.
  102740. */
  102741. export interface VRExperienceHelperOptions extends WebVROptions {
  102742. /**
  102743. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102744. */
  102745. createDeviceOrientationCamera?: boolean;
  102746. /**
  102747. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102748. */
  102749. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102750. /**
  102751. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102752. */
  102753. laserToggle?: boolean;
  102754. /**
  102755. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102756. */
  102757. floorMeshes?: Mesh[];
  102758. /**
  102759. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102760. */
  102761. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102762. }
  102763. /**
  102764. * Event containing information after VR has been entered
  102765. */
  102766. export class OnAfterEnteringVRObservableEvent {
  102767. /**
  102768. * If entering vr was successful
  102769. */
  102770. success: boolean;
  102771. }
  102772. /**
  102773. * Helps to quickly add VR support to an existing scene.
  102774. * See http://doc.babylonjs.com/how_to/webvr_helper
  102775. */
  102776. export class VRExperienceHelper {
  102777. /** Options to modify the vr experience helper's behavior. */
  102778. webVROptions: VRExperienceHelperOptions;
  102779. private _scene;
  102780. private _position;
  102781. private _btnVR;
  102782. private _btnVRDisplayed;
  102783. private _webVRsupported;
  102784. private _webVRready;
  102785. private _webVRrequesting;
  102786. private _webVRpresenting;
  102787. private _hasEnteredVR;
  102788. private _fullscreenVRpresenting;
  102789. private _canvas;
  102790. private _webVRCamera;
  102791. private _vrDeviceOrientationCamera;
  102792. private _deviceOrientationCamera;
  102793. private _existingCamera;
  102794. private _onKeyDown;
  102795. private _onVrDisplayPresentChange;
  102796. private _onVRDisplayChanged;
  102797. private _onVRRequestPresentStart;
  102798. private _onVRRequestPresentComplete;
  102799. /**
  102800. * Observable raised right before entering VR.
  102801. */
  102802. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102803. /**
  102804. * Observable raised when entering VR has completed.
  102805. */
  102806. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102807. /**
  102808. * Observable raised when exiting VR.
  102809. */
  102810. onExitingVRObservable: Observable<VRExperienceHelper>;
  102811. /**
  102812. * Observable raised when controller mesh is loaded.
  102813. */
  102814. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102815. /** Return this.onEnteringVRObservable
  102816. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102817. */
  102818. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102819. /** Return this.onExitingVRObservable
  102820. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102821. */
  102822. readonly onExitingVR: Observable<VRExperienceHelper>;
  102823. /** Return this.onControllerMeshLoadedObservable
  102824. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102825. */
  102826. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102827. private _rayLength;
  102828. private _useCustomVRButton;
  102829. private _teleportationRequested;
  102830. private _teleportActive;
  102831. private _floorMeshName;
  102832. private _floorMeshesCollection;
  102833. private _rotationAllowed;
  102834. private _teleportBackwardsVector;
  102835. private _teleportationTarget;
  102836. private _isDefaultTeleportationTarget;
  102837. private _postProcessMove;
  102838. private _teleportationFillColor;
  102839. private _teleportationBorderColor;
  102840. private _rotationAngle;
  102841. private _haloCenter;
  102842. private _cameraGazer;
  102843. private _padSensibilityUp;
  102844. private _padSensibilityDown;
  102845. private _leftController;
  102846. private _rightController;
  102847. /**
  102848. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102849. */
  102850. onNewMeshSelected: Observable<AbstractMesh>;
  102851. /**
  102852. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102853. */
  102854. onNewMeshPicked: Observable<PickingInfo>;
  102855. private _circleEase;
  102856. /**
  102857. * Observable raised before camera teleportation
  102858. */
  102859. onBeforeCameraTeleport: Observable<Vector3>;
  102860. /**
  102861. * Observable raised after camera teleportation
  102862. */
  102863. onAfterCameraTeleport: Observable<Vector3>;
  102864. /**
  102865. * Observable raised when current selected mesh gets unselected
  102866. */
  102867. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102868. private _raySelectionPredicate;
  102869. /**
  102870. * To be optionaly changed by user to define custom ray selection
  102871. */
  102872. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102873. /**
  102874. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102875. */
  102876. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102877. /**
  102878. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102879. */
  102880. teleportationEnabled: boolean;
  102881. private _defaultHeight;
  102882. private _teleportationInitialized;
  102883. private _interactionsEnabled;
  102884. private _interactionsRequested;
  102885. private _displayGaze;
  102886. private _displayLaserPointer;
  102887. /**
  102888. * The mesh used to display where the user is going to teleport.
  102889. */
  102890. /**
  102891. * Sets the mesh to be used to display where the user is going to teleport.
  102892. */
  102893. teleportationTarget: Mesh;
  102894. /**
  102895. * 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
  102896. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102897. * See http://doc.babylonjs.com/resources/baking_transformations
  102898. */
  102899. gazeTrackerMesh: Mesh;
  102900. /**
  102901. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102902. */
  102903. updateGazeTrackerScale: boolean;
  102904. /**
  102905. * If the gaze trackers color should be updated when selecting meshes
  102906. */
  102907. updateGazeTrackerColor: boolean;
  102908. /**
  102909. * The gaze tracking mesh corresponding to the left controller
  102910. */
  102911. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102912. /**
  102913. * The gaze tracking mesh corresponding to the right controller
  102914. */
  102915. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102916. /**
  102917. * If the ray of the gaze should be displayed.
  102918. */
  102919. /**
  102920. * Sets if the ray of the gaze should be displayed.
  102921. */
  102922. displayGaze: boolean;
  102923. /**
  102924. * If the ray of the LaserPointer should be displayed.
  102925. */
  102926. /**
  102927. * Sets if the ray of the LaserPointer should be displayed.
  102928. */
  102929. displayLaserPointer: boolean;
  102930. /**
  102931. * The deviceOrientationCamera used as the camera when not in VR.
  102932. */
  102933. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102934. /**
  102935. * Based on the current WebVR support, returns the current VR camera used.
  102936. */
  102937. readonly currentVRCamera: Nullable<Camera>;
  102938. /**
  102939. * The webVRCamera which is used when in VR.
  102940. */
  102941. readonly webVRCamera: WebVRFreeCamera;
  102942. /**
  102943. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102944. */
  102945. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102946. private readonly _teleportationRequestInitiated;
  102947. /**
  102948. * Defines wether or not Pointer lock should be requested when switching to
  102949. * full screen.
  102950. */
  102951. requestPointerLockOnFullScreen: boolean;
  102952. /**
  102953. * Instantiates a VRExperienceHelper.
  102954. * Helps to quickly add VR support to an existing scene.
  102955. * @param scene The scene the VRExperienceHelper belongs to.
  102956. * @param webVROptions Options to modify the vr experience helper's behavior.
  102957. */
  102958. constructor(scene: Scene,
  102959. /** Options to modify the vr experience helper's behavior. */
  102960. webVROptions?: VRExperienceHelperOptions);
  102961. private _onDefaultMeshLoaded;
  102962. private _onResize;
  102963. private _onFullscreenChange;
  102964. /**
  102965. * Gets a value indicating if we are currently in VR mode.
  102966. */
  102967. readonly isInVRMode: boolean;
  102968. private onVrDisplayPresentChange;
  102969. private onVRDisplayChanged;
  102970. private moveButtonToBottomRight;
  102971. private displayVRButton;
  102972. private updateButtonVisibility;
  102973. private _cachedAngularSensibility;
  102974. /**
  102975. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102976. * Otherwise, will use the fullscreen API.
  102977. */
  102978. enterVR(): void;
  102979. /**
  102980. * Attempt to exit VR, or fullscreen.
  102981. */
  102982. exitVR(): void;
  102983. /**
  102984. * The position of the vr experience helper.
  102985. */
  102986. /**
  102987. * Sets the position of the vr experience helper.
  102988. */
  102989. position: Vector3;
  102990. /**
  102991. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102992. */
  102993. enableInteractions(): void;
  102994. private readonly _noControllerIsActive;
  102995. private beforeRender;
  102996. private _isTeleportationFloor;
  102997. /**
  102998. * Adds a floor mesh to be used for teleportation.
  102999. * @param floorMesh the mesh to be used for teleportation.
  103000. */
  103001. addFloorMesh(floorMesh: Mesh): void;
  103002. /**
  103003. * Removes a floor mesh from being used for teleportation.
  103004. * @param floorMesh the mesh to be removed.
  103005. */
  103006. removeFloorMesh(floorMesh: Mesh): void;
  103007. /**
  103008. * Enables interactions and teleportation using the VR controllers and gaze.
  103009. * @param vrTeleportationOptions options to modify teleportation behavior.
  103010. */
  103011. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  103012. private _onNewGamepadConnected;
  103013. private _tryEnableInteractionOnController;
  103014. private _onNewGamepadDisconnected;
  103015. private _enableInteractionOnController;
  103016. private _checkTeleportWithRay;
  103017. private _checkRotate;
  103018. private _checkTeleportBackwards;
  103019. private _enableTeleportationOnController;
  103020. private _createTeleportationCircles;
  103021. private _displayTeleportationTarget;
  103022. private _hideTeleportationTarget;
  103023. private _rotateCamera;
  103024. private _moveTeleportationSelectorTo;
  103025. private _workingVector;
  103026. private _workingQuaternion;
  103027. private _workingMatrix;
  103028. /**
  103029. * Teleports the users feet to the desired location
  103030. * @param location The location where the user's feet should be placed
  103031. */
  103032. teleportCamera(location: Vector3): void;
  103033. private _convertNormalToDirectionOfRay;
  103034. private _castRayAndSelectObject;
  103035. private _notifySelectedMeshUnselected;
  103036. /**
  103037. * Sets the color of the laser ray from the vr controllers.
  103038. * @param color new color for the ray.
  103039. */
  103040. changeLaserColor(color: Color3): void;
  103041. /**
  103042. * Sets the color of the ray from the vr headsets gaze.
  103043. * @param color new color for the ray.
  103044. */
  103045. changeGazeColor(color: Color3): void;
  103046. /**
  103047. * Exits VR and disposes of the vr experience helper
  103048. */
  103049. dispose(): void;
  103050. /**
  103051. * Gets the name of the VRExperienceHelper class
  103052. * @returns "VRExperienceHelper"
  103053. */
  103054. getClassName(): string;
  103055. }
  103056. }
  103057. declare module BABYLON {
  103058. /**
  103059. * Manages an XRSession to work with Babylon's engine
  103060. * @see https://doc.babylonjs.com/how_to/webxr
  103061. */
  103062. export class WebXRSessionManager implements IDisposable {
  103063. private scene;
  103064. /**
  103065. * Fires every time a new xrFrame arrives which can be used to update the camera
  103066. */
  103067. onXRFrameObservable: Observable<any>;
  103068. /**
  103069. * Fires when the xr session is ended either by the device or manually done
  103070. */
  103071. onXRSessionEnded: Observable<any>;
  103072. /**
  103073. * Underlying xr session
  103074. */
  103075. session: XRSession;
  103076. /**
  103077. * Type of reference space used when creating the session
  103078. */
  103079. referenceSpace: XRReferenceSpace;
  103080. /** @hidden */
  103081. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103082. /**
  103083. * Current XR frame
  103084. */
  103085. currentFrame: Nullable<XRFrame>;
  103086. private _xrNavigator;
  103087. private baseLayer;
  103088. /**
  103089. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103090. * @param scene The scene which the session should be created for
  103091. */
  103092. constructor(scene: Scene);
  103093. /**
  103094. * Initializes the manager
  103095. * After initialization enterXR can be called to start an XR session
  103096. * @returns Promise which resolves after it is initialized
  103097. */
  103098. initializeAsync(): Promise<void>;
  103099. /**
  103100. * Initializes an xr session
  103101. * @param xrSessionMode mode to initialize
  103102. * @returns a promise which will resolve once the session has been initialized
  103103. */
  103104. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  103105. /**
  103106. * Sets the reference space on the xr session
  103107. * @param referenceSpace space to set
  103108. * @returns a promise that will resolve once the reference space has been set
  103109. */
  103110. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  103111. /**
  103112. * Updates the render state of the session
  103113. * @param state state to set
  103114. * @returns a promise that resolves once the render state has been updated
  103115. */
  103116. updateRenderStateAsync(state: any): Promise<void>;
  103117. /**
  103118. * Starts rendering to the xr layer
  103119. * @returns a promise that will resolve once rendering has started
  103120. */
  103121. startRenderingToXRAsync(): Promise<void>;
  103122. /**
  103123. * Stops the xrSession and restores the renderloop
  103124. * @returns Promise which resolves after it exits XR
  103125. */
  103126. exitXRAsync(): Promise<void>;
  103127. /**
  103128. * Checks if a session would be supported for the creation options specified
  103129. * @param sessionMode session mode to check if supported eg. immersive-vr
  103130. * @returns true if supported
  103131. */
  103132. supportsSessionAsync(sessionMode: XRSessionMode): any;
  103133. /**
  103134. * @hidden
  103135. * Converts the render layer of xrSession to a render target
  103136. * @param session session to create render target for
  103137. * @param scene scene the new render target should be created for
  103138. */
  103139. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  103140. /**
  103141. * Disposes of the session manager
  103142. */
  103143. dispose(): void;
  103144. }
  103145. }
  103146. declare module BABYLON {
  103147. /**
  103148. * WebXR Camera which holds the views for the xrSession
  103149. * @see https://doc.babylonjs.com/how_to/webxr
  103150. */
  103151. export class WebXRCamera extends FreeCamera {
  103152. private static _TmpMatrix;
  103153. /**
  103154. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103155. * @param name the name of the camera
  103156. * @param scene the scene to add the camera to
  103157. */
  103158. constructor(name: string, scene: Scene);
  103159. private _updateNumberOfRigCameras;
  103160. /** @hidden */
  103161. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103162. /**
  103163. * Updates the cameras position from the current pose information of the XR session
  103164. * @param xrSessionManager the session containing pose information
  103165. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103166. */
  103167. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103168. }
  103169. }
  103170. declare module BABYLON {
  103171. /**
  103172. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103173. */
  103174. export class WebXRManagedOutputCanvas implements IDisposable {
  103175. private helper;
  103176. private _canvas;
  103177. /**
  103178. * xrpresent context of the canvas which can be used to display/mirror xr content
  103179. */
  103180. canvasContext: WebGLRenderingContext;
  103181. /**
  103182. * xr layer for the canvas
  103183. */
  103184. xrLayer: Nullable<XRWebGLLayer>;
  103185. /**
  103186. * Initializes the xr layer for the session
  103187. * @param xrSession xr session
  103188. * @returns a promise that will resolve once the XR Layer has been created
  103189. */
  103190. initializeXRLayerAsync(xrSession: any): any;
  103191. /**
  103192. * Initializes the canvas to be added/removed upon entering/exiting xr
  103193. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103194. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103195. */
  103196. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103197. /**
  103198. * Disposes of the object
  103199. */
  103200. dispose(): void;
  103201. private _setManagedOutputCanvas;
  103202. private _addCanvas;
  103203. private _removeCanvas;
  103204. }
  103205. }
  103206. declare module BABYLON {
  103207. /**
  103208. * States of the webXR experience
  103209. */
  103210. export enum WebXRState {
  103211. /**
  103212. * Transitioning to being in XR mode
  103213. */
  103214. ENTERING_XR = 0,
  103215. /**
  103216. * Transitioning to non XR mode
  103217. */
  103218. EXITING_XR = 1,
  103219. /**
  103220. * In XR mode and presenting
  103221. */
  103222. IN_XR = 2,
  103223. /**
  103224. * Not entered XR mode
  103225. */
  103226. NOT_IN_XR = 3
  103227. }
  103228. /**
  103229. * Helper class used to enable XR
  103230. * @see https://doc.babylonjs.com/how_to/webxr
  103231. */
  103232. export class WebXRExperienceHelper implements IDisposable {
  103233. private scene;
  103234. /**
  103235. * 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
  103236. */
  103237. container: AbstractMesh;
  103238. /**
  103239. * Camera used to render xr content
  103240. */
  103241. camera: WebXRCamera;
  103242. /**
  103243. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103244. */
  103245. state: WebXRState;
  103246. private _setState;
  103247. private static _TmpVector;
  103248. /**
  103249. * Fires when the state of the experience helper has changed
  103250. */
  103251. onStateChangedObservable: Observable<WebXRState>;
  103252. /** Session manager used to keep track of xr session */
  103253. sessionManager: WebXRSessionManager;
  103254. private _nonVRCamera;
  103255. private _originalSceneAutoClear;
  103256. private _supported;
  103257. /**
  103258. * Creates the experience helper
  103259. * @param scene the scene to attach the experience helper to
  103260. * @returns a promise for the experience helper
  103261. */
  103262. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103263. /**
  103264. * Creates a WebXRExperienceHelper
  103265. * @param scene The scene the helper should be created in
  103266. */
  103267. private constructor();
  103268. /**
  103269. * Exits XR mode and returns the scene to its original state
  103270. * @returns promise that resolves after xr mode has exited
  103271. */
  103272. exitXRAsync(): Promise<void>;
  103273. /**
  103274. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103275. * @param sessionCreationOptions options for the XR session
  103276. * @param referenceSpaceType frame of reference of the XR session
  103277. * @param outputCanvas the output canvas that will be used to enter XR mode
  103278. * @returns promise that resolves after xr mode has entered
  103279. */
  103280. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  103281. /**
  103282. * Updates the global position of the camera by moving the camera's container
  103283. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103284. * @param position The desired global position of the camera
  103285. */
  103286. setPositionOfCameraUsingContainer(position: Vector3): void;
  103287. /**
  103288. * Rotates the xr camera by rotating the camera's container around the camera's position
  103289. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103290. * @param rotation the desired quaternion rotation to apply to the camera
  103291. */
  103292. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103293. /**
  103294. * Disposes of the experience helper
  103295. */
  103296. dispose(): void;
  103297. }
  103298. }
  103299. declare module BABYLON {
  103300. /**
  103301. * Button which can be used to enter a different mode of XR
  103302. */
  103303. export class WebXREnterExitUIButton {
  103304. /** button element */
  103305. element: HTMLElement;
  103306. /** XR initialization options for the button */
  103307. sessionMode: XRSessionMode;
  103308. /** Reference space type */
  103309. referenceSpaceType: XRReferenceSpaceType;
  103310. /**
  103311. * Creates a WebXREnterExitUIButton
  103312. * @param element button element
  103313. * @param sessionMode XR initialization session mode
  103314. * @param referenceSpaceType the type of reference space to be used
  103315. */
  103316. constructor(
  103317. /** button element */
  103318. element: HTMLElement,
  103319. /** XR initialization options for the button */
  103320. sessionMode: XRSessionMode,
  103321. /** Reference space type */
  103322. referenceSpaceType: XRReferenceSpaceType);
  103323. /**
  103324. * Overwritable function which can be used to update the button's visuals when the state changes
  103325. * @param activeButton the current active button in the UI
  103326. */
  103327. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103328. }
  103329. /**
  103330. * Options to create the webXR UI
  103331. */
  103332. export class WebXREnterExitUIOptions {
  103333. /**
  103334. * Context to enter xr with
  103335. */
  103336. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  103337. /**
  103338. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103339. */
  103340. customButtons?: Array<WebXREnterExitUIButton>;
  103341. }
  103342. /**
  103343. * UI to allow the user to enter/exit XR mode
  103344. */
  103345. export class WebXREnterExitUI implements IDisposable {
  103346. private scene;
  103347. private _overlay;
  103348. private _buttons;
  103349. private _activeButton;
  103350. /**
  103351. * Fired every time the active button is changed.
  103352. *
  103353. * When xr is entered via a button that launches xr that button will be the callback parameter
  103354. *
  103355. * When exiting xr the callback parameter will be null)
  103356. */
  103357. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103358. /**
  103359. * Creates UI to allow the user to enter/exit XR mode
  103360. * @param scene the scene to add the ui to
  103361. * @param helper the xr experience helper to enter/exit xr with
  103362. * @param options options to configure the UI
  103363. * @returns the created ui
  103364. */
  103365. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103366. private constructor();
  103367. private _updateButtons;
  103368. /**
  103369. * Disposes of the object
  103370. */
  103371. dispose(): void;
  103372. }
  103373. }
  103374. declare module BABYLON {
  103375. /**
  103376. * Represents an XR input
  103377. */
  103378. export class WebXRController {
  103379. private scene;
  103380. /** The underlying input source for the controller */
  103381. inputSource: XRInputSource;
  103382. private parentContainer;
  103383. /**
  103384. * 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
  103385. */
  103386. grip?: AbstractMesh;
  103387. /**
  103388. * Pointer which can be used to select objects or attach a visible laser to
  103389. */
  103390. pointer: AbstractMesh;
  103391. private _tmpMatrix;
  103392. /**
  103393. * Creates the controller
  103394. * @see https://doc.babylonjs.com/how_to/webxr
  103395. * @param scene the scene which the controller should be associated to
  103396. * @param inputSource the underlying input source for the controller
  103397. * @param parentContainer parent that the controller meshes should be children of
  103398. */
  103399. constructor(scene: Scene,
  103400. /** The underlying input source for the controller */
  103401. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  103402. /**
  103403. * Updates the controller pose based on the given XRFrame
  103404. * @param xrFrame xr frame to update the pose with
  103405. * @param referenceSpace reference space to use
  103406. */
  103407. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  103408. /**
  103409. * Disposes of the object
  103410. */
  103411. dispose(): void;
  103412. }
  103413. /**
  103414. * XR input used to track XR inputs such as controllers/rays
  103415. */
  103416. export class WebXRInput implements IDisposable {
  103417. private helper;
  103418. /**
  103419. * XR controllers being tracked
  103420. */
  103421. controllers: Array<WebXRController>;
  103422. private _frameObserver;
  103423. /**
  103424. * Event when a controller has been connected/added
  103425. */
  103426. onControllerAddedObservable: Observable<WebXRController>;
  103427. /**
  103428. * Event when a controller has been removed/disconnected
  103429. */
  103430. onControllerRemovedObservable: Observable<WebXRController>;
  103431. /**
  103432. * Initializes the WebXRInput
  103433. * @param helper experience helper which the input should be created for
  103434. */
  103435. constructor(helper: WebXRExperienceHelper);
  103436. private _onInputSourcesChange;
  103437. private _addAndRemoveControllers;
  103438. /**
  103439. * Disposes of the object
  103440. */
  103441. dispose(): void;
  103442. }
  103443. }
  103444. declare module BABYLON {
  103445. /**
  103446. * Contains an array of blocks representing the octree
  103447. */
  103448. export interface IOctreeContainer<T> {
  103449. /**
  103450. * Blocks within the octree
  103451. */
  103452. blocks: Array<OctreeBlock<T>>;
  103453. }
  103454. /**
  103455. * Class used to store a cell in an octree
  103456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103457. */
  103458. export class OctreeBlock<T> {
  103459. /**
  103460. * Gets the content of the current block
  103461. */
  103462. entries: T[];
  103463. /**
  103464. * Gets the list of block children
  103465. */
  103466. blocks: Array<OctreeBlock<T>>;
  103467. private _depth;
  103468. private _maxDepth;
  103469. private _capacity;
  103470. private _minPoint;
  103471. private _maxPoint;
  103472. private _boundingVectors;
  103473. private _creationFunc;
  103474. /**
  103475. * Creates a new block
  103476. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103477. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103478. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103479. * @param depth defines the current depth of this block in the octree
  103480. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103481. * @param creationFunc defines a callback to call when an element is added to the block
  103482. */
  103483. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103484. /**
  103485. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103486. */
  103487. readonly capacity: number;
  103488. /**
  103489. * Gets the minimum vector (in world space) of the block's bounding box
  103490. */
  103491. readonly minPoint: Vector3;
  103492. /**
  103493. * Gets the maximum vector (in world space) of the block's bounding box
  103494. */
  103495. readonly maxPoint: Vector3;
  103496. /**
  103497. * Add a new element to this block
  103498. * @param entry defines the element to add
  103499. */
  103500. addEntry(entry: T): void;
  103501. /**
  103502. * Remove an element from this block
  103503. * @param entry defines the element to remove
  103504. */
  103505. removeEntry(entry: T): void;
  103506. /**
  103507. * Add an array of elements to this block
  103508. * @param entries defines the array of elements to add
  103509. */
  103510. addEntries(entries: T[]): void;
  103511. /**
  103512. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103513. * @param frustumPlanes defines the frustum planes to test
  103514. * @param selection defines the array to store current content if selection is positive
  103515. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103516. */
  103517. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103518. /**
  103519. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103520. * @param sphereCenter defines the bounding sphere center
  103521. * @param sphereRadius defines the bounding sphere radius
  103522. * @param selection defines the array to store current content if selection is positive
  103523. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103524. */
  103525. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103526. /**
  103527. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103528. * @param ray defines the ray to test with
  103529. * @param selection defines the array to store current content if selection is positive
  103530. */
  103531. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103532. /**
  103533. * Subdivide the content into child blocks (this block will then be empty)
  103534. */
  103535. createInnerBlocks(): void;
  103536. /**
  103537. * @hidden
  103538. */
  103539. 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;
  103540. }
  103541. }
  103542. declare module BABYLON {
  103543. /**
  103544. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103546. */
  103547. export class Octree<T> {
  103548. /** 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.) */
  103549. maxDepth: number;
  103550. /**
  103551. * Blocks within the octree containing objects
  103552. */
  103553. blocks: Array<OctreeBlock<T>>;
  103554. /**
  103555. * Content stored in the octree
  103556. */
  103557. dynamicContent: T[];
  103558. private _maxBlockCapacity;
  103559. private _selectionContent;
  103560. private _creationFunc;
  103561. /**
  103562. * Creates a octree
  103563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103564. * @param creationFunc function to be used to instatiate the octree
  103565. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103566. * @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.)
  103567. */
  103568. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103569. /** 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.) */
  103570. maxDepth?: number);
  103571. /**
  103572. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103573. * @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);
  103574. * @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);
  103575. * @param entries meshes to be added to the octree blocks
  103576. */
  103577. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103578. /**
  103579. * Adds a mesh to the octree
  103580. * @param entry Mesh to add to the octree
  103581. */
  103582. addMesh(entry: T): void;
  103583. /**
  103584. * Remove an element from the octree
  103585. * @param entry defines the element to remove
  103586. */
  103587. removeMesh(entry: T): void;
  103588. /**
  103589. * Selects an array of meshes within the frustum
  103590. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103591. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103592. * @returns array of meshes within the frustum
  103593. */
  103594. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103595. /**
  103596. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103597. * @param sphereCenter defines the bounding sphere center
  103598. * @param sphereRadius defines the bounding sphere radius
  103599. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103600. * @returns an array of objects that intersect the sphere
  103601. */
  103602. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103603. /**
  103604. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103605. * @param ray defines the ray to test with
  103606. * @returns array of intersected objects
  103607. */
  103608. intersectsRay(ray: Ray): SmartArray<T>;
  103609. /**
  103610. * Adds a mesh into the octree block if it intersects the block
  103611. */
  103612. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103613. /**
  103614. * Adds a submesh into the octree block if it intersects the block
  103615. */
  103616. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103617. }
  103618. }
  103619. declare module BABYLON {
  103620. interface Scene {
  103621. /**
  103622. * @hidden
  103623. * Backing Filed
  103624. */
  103625. _selectionOctree: Octree<AbstractMesh>;
  103626. /**
  103627. * Gets the octree used to boost mesh selection (picking)
  103628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103629. */
  103630. selectionOctree: Octree<AbstractMesh>;
  103631. /**
  103632. * Creates or updates the octree used to boost selection (picking)
  103633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103634. * @param maxCapacity defines the maximum capacity per leaf
  103635. * @param maxDepth defines the maximum depth of the octree
  103636. * @returns an octree of AbstractMesh
  103637. */
  103638. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103639. }
  103640. interface AbstractMesh {
  103641. /**
  103642. * @hidden
  103643. * Backing Field
  103644. */
  103645. _submeshesOctree: Octree<SubMesh>;
  103646. /**
  103647. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103648. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103649. * @param maxCapacity defines the maximum size of each block (64 by default)
  103650. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103651. * @returns the new octree
  103652. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103654. */
  103655. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103656. }
  103657. /**
  103658. * Defines the octree scene component responsible to manage any octrees
  103659. * in a given scene.
  103660. */
  103661. export class OctreeSceneComponent {
  103662. /**
  103663. * The component name help to identify the component in the list of scene components.
  103664. */
  103665. readonly name: string;
  103666. /**
  103667. * The scene the component belongs to.
  103668. */
  103669. scene: Scene;
  103670. /**
  103671. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103672. */
  103673. readonly checksIsEnabled: boolean;
  103674. /**
  103675. * Creates a new instance of the component for the given scene
  103676. * @param scene Defines the scene to register the component in
  103677. */
  103678. constructor(scene: Scene);
  103679. /**
  103680. * Registers the component in a given scene
  103681. */
  103682. register(): void;
  103683. /**
  103684. * Return the list of active meshes
  103685. * @returns the list of active meshes
  103686. */
  103687. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103688. /**
  103689. * Return the list of active sub meshes
  103690. * @param mesh The mesh to get the candidates sub meshes from
  103691. * @returns the list of active sub meshes
  103692. */
  103693. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103694. private _tempRay;
  103695. /**
  103696. * Return the list of sub meshes intersecting with a given local ray
  103697. * @param mesh defines the mesh to find the submesh for
  103698. * @param localRay defines the ray in local space
  103699. * @returns the list of intersecting sub meshes
  103700. */
  103701. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103702. /**
  103703. * Return the list of sub meshes colliding with a collider
  103704. * @param mesh defines the mesh to find the submesh for
  103705. * @param collider defines the collider to evaluate the collision against
  103706. * @returns the list of colliding sub meshes
  103707. */
  103708. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103709. /**
  103710. * Rebuilds the elements related to this component in case of
  103711. * context lost for instance.
  103712. */
  103713. rebuild(): void;
  103714. /**
  103715. * Disposes the component and the associated ressources.
  103716. */
  103717. dispose(): void;
  103718. }
  103719. }
  103720. declare module BABYLON {
  103721. /**
  103722. * Renders a layer on top of an existing scene
  103723. */
  103724. export class UtilityLayerRenderer implements IDisposable {
  103725. /** the original scene that will be rendered on top of */
  103726. originalScene: Scene;
  103727. private _pointerCaptures;
  103728. private _lastPointerEvents;
  103729. private static _DefaultUtilityLayer;
  103730. private static _DefaultKeepDepthUtilityLayer;
  103731. private _sharedGizmoLight;
  103732. private _renderCamera;
  103733. /**
  103734. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103735. * @returns the camera that is used when rendering the utility layer
  103736. */
  103737. getRenderCamera(): Nullable<Camera>;
  103738. /**
  103739. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103740. * @param cam the camera that should be used when rendering the utility layer
  103741. */
  103742. setRenderCamera(cam: Nullable<Camera>): void;
  103743. /**
  103744. * @hidden
  103745. * Light which used by gizmos to get light shading
  103746. */
  103747. _getSharedGizmoLight(): HemisphericLight;
  103748. /**
  103749. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103750. */
  103751. pickUtilitySceneFirst: boolean;
  103752. /**
  103753. * 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)
  103754. */
  103755. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103756. /**
  103757. * 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)
  103758. */
  103759. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103760. /**
  103761. * The scene that is rendered on top of the original scene
  103762. */
  103763. utilityLayerScene: Scene;
  103764. /**
  103765. * If the utility layer should automatically be rendered on top of existing scene
  103766. */
  103767. shouldRender: boolean;
  103768. /**
  103769. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103770. */
  103771. onlyCheckPointerDownEvents: boolean;
  103772. /**
  103773. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103774. */
  103775. processAllEvents: boolean;
  103776. /**
  103777. * Observable raised when the pointer move from the utility layer scene to the main scene
  103778. */
  103779. onPointerOutObservable: Observable<number>;
  103780. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103781. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103782. private _afterRenderObserver;
  103783. private _sceneDisposeObserver;
  103784. private _originalPointerObserver;
  103785. /**
  103786. * Instantiates a UtilityLayerRenderer
  103787. * @param originalScene the original scene that will be rendered on top of
  103788. * @param handleEvents boolean indicating if the utility layer should handle events
  103789. */
  103790. constructor(
  103791. /** the original scene that will be rendered on top of */
  103792. originalScene: Scene, handleEvents?: boolean);
  103793. private _notifyObservers;
  103794. /**
  103795. * Renders the utility layers scene on top of the original scene
  103796. */
  103797. render(): void;
  103798. /**
  103799. * Disposes of the renderer
  103800. */
  103801. dispose(): void;
  103802. private _updateCamera;
  103803. }
  103804. }
  103805. declare module BABYLON {
  103806. /**
  103807. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103808. */
  103809. export class Gizmo implements IDisposable {
  103810. /** The utility layer the gizmo will be added to */
  103811. gizmoLayer: UtilityLayerRenderer;
  103812. /**
  103813. * The root mesh of the gizmo
  103814. */
  103815. _rootMesh: Mesh;
  103816. private _attachedMesh;
  103817. /**
  103818. * Ratio for the scale of the gizmo (Default: 1)
  103819. */
  103820. scaleRatio: number;
  103821. /**
  103822. * If a custom mesh has been set (Default: false)
  103823. */
  103824. protected _customMeshSet: boolean;
  103825. /**
  103826. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103827. * * When set, interactions will be enabled
  103828. */
  103829. attachedMesh: Nullable<AbstractMesh>;
  103830. /**
  103831. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103832. * @param mesh The mesh to replace the default mesh of the gizmo
  103833. */
  103834. setCustomMesh(mesh: Mesh): void;
  103835. /**
  103836. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103837. */
  103838. updateGizmoRotationToMatchAttachedMesh: boolean;
  103839. /**
  103840. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103841. */
  103842. updateGizmoPositionToMatchAttachedMesh: boolean;
  103843. /**
  103844. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103845. */
  103846. protected _updateScale: boolean;
  103847. protected _interactionsEnabled: boolean;
  103848. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103849. private _beforeRenderObserver;
  103850. private _tempVector;
  103851. /**
  103852. * Creates a gizmo
  103853. * @param gizmoLayer The utility layer the gizmo will be added to
  103854. */
  103855. constructor(
  103856. /** The utility layer the gizmo will be added to */
  103857. gizmoLayer?: UtilityLayerRenderer);
  103858. /**
  103859. * Updates the gizmo to match the attached mesh's position/rotation
  103860. */
  103861. protected _update(): void;
  103862. /**
  103863. * Disposes of the gizmo
  103864. */
  103865. dispose(): void;
  103866. }
  103867. }
  103868. declare module BABYLON {
  103869. /**
  103870. * Single plane drag gizmo
  103871. */
  103872. export class PlaneDragGizmo extends Gizmo {
  103873. /**
  103874. * Drag behavior responsible for the gizmos dragging interactions
  103875. */
  103876. dragBehavior: PointerDragBehavior;
  103877. private _pointerObserver;
  103878. /**
  103879. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103880. */
  103881. snapDistance: number;
  103882. /**
  103883. * Event that fires each time the gizmo snaps to a new location.
  103884. * * snapDistance is the the change in distance
  103885. */
  103886. onSnapObservable: Observable<{
  103887. snapDistance: number;
  103888. }>;
  103889. private _plane;
  103890. private _coloredMaterial;
  103891. private _hoverMaterial;
  103892. private _isEnabled;
  103893. private _parent;
  103894. /** @hidden */
  103895. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103896. /** @hidden */
  103897. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103898. /**
  103899. * Creates a PlaneDragGizmo
  103900. * @param gizmoLayer The utility layer the gizmo will be added to
  103901. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103902. * @param color The color of the gizmo
  103903. */
  103904. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103905. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103906. /**
  103907. * If the gizmo is enabled
  103908. */
  103909. isEnabled: boolean;
  103910. /**
  103911. * Disposes of the gizmo
  103912. */
  103913. dispose(): void;
  103914. }
  103915. }
  103916. declare module BABYLON {
  103917. /**
  103918. * Gizmo that enables dragging a mesh along 3 axis
  103919. */
  103920. export class PositionGizmo extends Gizmo {
  103921. /**
  103922. * Internal gizmo used for interactions on the x axis
  103923. */
  103924. xGizmo: AxisDragGizmo;
  103925. /**
  103926. * Internal gizmo used for interactions on the y axis
  103927. */
  103928. yGizmo: AxisDragGizmo;
  103929. /**
  103930. * Internal gizmo used for interactions on the z axis
  103931. */
  103932. zGizmo: AxisDragGizmo;
  103933. /**
  103934. * Internal gizmo used for interactions on the yz plane
  103935. */
  103936. xPlaneGizmo: PlaneDragGizmo;
  103937. /**
  103938. * Internal gizmo used for interactions on the xz plane
  103939. */
  103940. yPlaneGizmo: PlaneDragGizmo;
  103941. /**
  103942. * Internal gizmo used for interactions on the xy plane
  103943. */
  103944. zPlaneGizmo: PlaneDragGizmo;
  103945. /**
  103946. * private variables
  103947. */
  103948. private _meshAttached;
  103949. private _updateGizmoRotationToMatchAttachedMesh;
  103950. private _snapDistance;
  103951. private _scaleRatio;
  103952. /** Fires an event when any of it's sub gizmos are dragged */
  103953. onDragStartObservable: Observable<unknown>;
  103954. /** Fires an event when any of it's sub gizmos are released from dragging */
  103955. onDragEndObservable: Observable<unknown>;
  103956. /**
  103957. * If set to true, planar drag is enabled
  103958. */
  103959. private _planarGizmoEnabled;
  103960. attachedMesh: Nullable<AbstractMesh>;
  103961. /**
  103962. * Creates a PositionGizmo
  103963. * @param gizmoLayer The utility layer the gizmo will be added to
  103964. */
  103965. constructor(gizmoLayer?: UtilityLayerRenderer);
  103966. /**
  103967. * If the planar drag gizmo is enabled
  103968. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103969. */
  103970. planarGizmoEnabled: boolean;
  103971. updateGizmoRotationToMatchAttachedMesh: boolean;
  103972. /**
  103973. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103974. */
  103975. snapDistance: number;
  103976. /**
  103977. * Ratio for the scale of the gizmo (Default: 1)
  103978. */
  103979. scaleRatio: number;
  103980. /**
  103981. * Disposes of the gizmo
  103982. */
  103983. dispose(): void;
  103984. /**
  103985. * CustomMeshes are not supported by this gizmo
  103986. * @param mesh The mesh to replace the default mesh of the gizmo
  103987. */
  103988. setCustomMesh(mesh: Mesh): void;
  103989. }
  103990. }
  103991. declare module BABYLON {
  103992. /**
  103993. * Single axis drag gizmo
  103994. */
  103995. export class AxisDragGizmo extends Gizmo {
  103996. /**
  103997. * Drag behavior responsible for the gizmos dragging interactions
  103998. */
  103999. dragBehavior: PointerDragBehavior;
  104000. private _pointerObserver;
  104001. /**
  104002. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104003. */
  104004. snapDistance: number;
  104005. /**
  104006. * Event that fires each time the gizmo snaps to a new location.
  104007. * * snapDistance is the the change in distance
  104008. */
  104009. onSnapObservable: Observable<{
  104010. snapDistance: number;
  104011. }>;
  104012. private _isEnabled;
  104013. private _parent;
  104014. private _arrow;
  104015. private _coloredMaterial;
  104016. private _hoverMaterial;
  104017. /** @hidden */
  104018. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  104019. /** @hidden */
  104020. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  104021. /**
  104022. * Creates an AxisDragGizmo
  104023. * @param gizmoLayer The utility layer the gizmo will be added to
  104024. * @param dragAxis The axis which the gizmo will be able to drag on
  104025. * @param color The color of the gizmo
  104026. */
  104027. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  104028. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104029. /**
  104030. * If the gizmo is enabled
  104031. */
  104032. isEnabled: boolean;
  104033. /**
  104034. * Disposes of the gizmo
  104035. */
  104036. dispose(): void;
  104037. }
  104038. }
  104039. declare module BABYLON.Debug {
  104040. /**
  104041. * The Axes viewer will show 3 axes in a specific point in space
  104042. */
  104043. export class AxesViewer {
  104044. private _xAxis;
  104045. private _yAxis;
  104046. private _zAxis;
  104047. private _scaleLinesFactor;
  104048. private _instanced;
  104049. /**
  104050. * Gets the hosting scene
  104051. */
  104052. scene: Scene;
  104053. /**
  104054. * Gets or sets a number used to scale line length
  104055. */
  104056. scaleLines: number;
  104057. /** Gets the node hierarchy used to render x-axis */
  104058. readonly xAxis: TransformNode;
  104059. /** Gets the node hierarchy used to render y-axis */
  104060. readonly yAxis: TransformNode;
  104061. /** Gets the node hierarchy used to render z-axis */
  104062. readonly zAxis: TransformNode;
  104063. /**
  104064. * Creates a new AxesViewer
  104065. * @param scene defines the hosting scene
  104066. * @param scaleLines defines a number used to scale line length (1 by default)
  104067. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  104068. * @param xAxis defines the node hierarchy used to render the x-axis
  104069. * @param yAxis defines the node hierarchy used to render the y-axis
  104070. * @param zAxis defines the node hierarchy used to render the z-axis
  104071. */
  104072. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  104073. /**
  104074. * Force the viewer to update
  104075. * @param position defines the position of the viewer
  104076. * @param xaxis defines the x axis of the viewer
  104077. * @param yaxis defines the y axis of the viewer
  104078. * @param zaxis defines the z axis of the viewer
  104079. */
  104080. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  104081. /**
  104082. * Creates an instance of this axes viewer.
  104083. * @returns a new axes viewer with instanced meshes
  104084. */
  104085. createInstance(): AxesViewer;
  104086. /** Releases resources */
  104087. dispose(): void;
  104088. private static _SetRenderingGroupId;
  104089. }
  104090. }
  104091. declare module BABYLON.Debug {
  104092. /**
  104093. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104094. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104095. */
  104096. export class BoneAxesViewer extends AxesViewer {
  104097. /**
  104098. * Gets or sets the target mesh where to display the axes viewer
  104099. */
  104100. mesh: Nullable<Mesh>;
  104101. /**
  104102. * Gets or sets the target bone where to display the axes viewer
  104103. */
  104104. bone: Nullable<Bone>;
  104105. /** Gets current position */
  104106. pos: Vector3;
  104107. /** Gets direction of X axis */
  104108. xaxis: Vector3;
  104109. /** Gets direction of Y axis */
  104110. yaxis: Vector3;
  104111. /** Gets direction of Z axis */
  104112. zaxis: Vector3;
  104113. /**
  104114. * Creates a new BoneAxesViewer
  104115. * @param scene defines the hosting scene
  104116. * @param bone defines the target bone
  104117. * @param mesh defines the target mesh
  104118. * @param scaleLines defines a scaling factor for line length (1 by default)
  104119. */
  104120. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104121. /**
  104122. * Force the viewer to update
  104123. */
  104124. update(): void;
  104125. /** Releases resources */
  104126. dispose(): void;
  104127. }
  104128. }
  104129. declare module BABYLON {
  104130. /**
  104131. * Interface used to define scene explorer extensibility option
  104132. */
  104133. export interface IExplorerExtensibilityOption {
  104134. /**
  104135. * Define the option label
  104136. */
  104137. label: string;
  104138. /**
  104139. * Defines the action to execute on click
  104140. */
  104141. action: (entity: any) => void;
  104142. }
  104143. /**
  104144. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104145. */
  104146. export interface IExplorerExtensibilityGroup {
  104147. /**
  104148. * Defines a predicate to test if a given type mut be extended
  104149. */
  104150. predicate: (entity: any) => boolean;
  104151. /**
  104152. * Gets the list of options added to a type
  104153. */
  104154. entries: IExplorerExtensibilityOption[];
  104155. }
  104156. /**
  104157. * Interface used to define the options to use to create the Inspector
  104158. */
  104159. export interface IInspectorOptions {
  104160. /**
  104161. * Display in overlay mode (default: false)
  104162. */
  104163. overlay?: boolean;
  104164. /**
  104165. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104166. */
  104167. globalRoot?: HTMLElement;
  104168. /**
  104169. * Display the Scene explorer
  104170. */
  104171. showExplorer?: boolean;
  104172. /**
  104173. * Display the property inspector
  104174. */
  104175. showInspector?: boolean;
  104176. /**
  104177. * Display in embed mode (both panes on the right)
  104178. */
  104179. embedMode?: boolean;
  104180. /**
  104181. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104182. */
  104183. handleResize?: boolean;
  104184. /**
  104185. * Allow the panes to popup (default: true)
  104186. */
  104187. enablePopup?: boolean;
  104188. /**
  104189. * Allow the panes to be closed by users (default: true)
  104190. */
  104191. enableClose?: boolean;
  104192. /**
  104193. * Optional list of extensibility entries
  104194. */
  104195. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104196. /**
  104197. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104198. */
  104199. inspectorURL?: string;
  104200. }
  104201. interface Scene {
  104202. /**
  104203. * @hidden
  104204. * Backing field
  104205. */
  104206. _debugLayer: DebugLayer;
  104207. /**
  104208. * Gets the debug layer (aka Inspector) associated with the scene
  104209. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104210. */
  104211. debugLayer: DebugLayer;
  104212. }
  104213. /**
  104214. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104215. * what is happening in your scene
  104216. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104217. */
  104218. export class DebugLayer {
  104219. /**
  104220. * Define the url to get the inspector script from.
  104221. * By default it uses the babylonjs CDN.
  104222. * @ignoreNaming
  104223. */
  104224. static InspectorURL: string;
  104225. private _scene;
  104226. private BJSINSPECTOR;
  104227. private _onPropertyChangedObservable?;
  104228. /**
  104229. * Observable triggered when a property is changed through the inspector.
  104230. */
  104231. readonly onPropertyChangedObservable: any;
  104232. /**
  104233. * Instantiates a new debug layer.
  104234. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104235. * what is happening in your scene
  104236. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104237. * @param scene Defines the scene to inspect
  104238. */
  104239. constructor(scene: Scene);
  104240. /** Creates the inspector window. */
  104241. private _createInspector;
  104242. /**
  104243. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104244. * @param entity defines the entity to select
  104245. * @param lineContainerTitle defines the specific block to highlight
  104246. */
  104247. select(entity: any, lineContainerTitle?: string): void;
  104248. /** Get the inspector from bundle or global */
  104249. private _getGlobalInspector;
  104250. /**
  104251. * Get if the inspector is visible or not.
  104252. * @returns true if visible otherwise, false
  104253. */
  104254. isVisible(): boolean;
  104255. /**
  104256. * Hide the inspector and close its window.
  104257. */
  104258. hide(): void;
  104259. /**
  104260. * Launch the debugLayer.
  104261. * @param config Define the configuration of the inspector
  104262. * @return a promise fulfilled when the debug layer is visible
  104263. */
  104264. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104265. }
  104266. }
  104267. declare module BABYLON {
  104268. /**
  104269. * Class containing static functions to help procedurally build meshes
  104270. */
  104271. export class BoxBuilder {
  104272. /**
  104273. * Creates a box mesh
  104274. * * The parameter `size` sets the size (float) of each box side (default 1)
  104275. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104276. * * 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)
  104277. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104281. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104282. * @param name defines the name of the mesh
  104283. * @param options defines the options used to create the mesh
  104284. * @param scene defines the hosting scene
  104285. * @returns the box mesh
  104286. */
  104287. static CreateBox(name: string, options: {
  104288. size?: number;
  104289. width?: number;
  104290. height?: number;
  104291. depth?: number;
  104292. faceUV?: Vector4[];
  104293. faceColors?: Color4[];
  104294. sideOrientation?: number;
  104295. frontUVs?: Vector4;
  104296. backUVs?: Vector4;
  104297. wrap?: boolean;
  104298. topBaseAt?: number;
  104299. bottomBaseAt?: number;
  104300. updatable?: boolean;
  104301. }, scene?: Nullable<Scene>): Mesh;
  104302. }
  104303. }
  104304. declare module BABYLON {
  104305. /**
  104306. * Class containing static functions to help procedurally build meshes
  104307. */
  104308. export class SphereBuilder {
  104309. /**
  104310. * Creates a sphere mesh
  104311. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104312. * * 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`)
  104313. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104314. * * 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
  104315. * * 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)
  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. * @param name defines the name of the mesh
  104320. * @param options defines the options used to create the mesh
  104321. * @param scene defines the hosting scene
  104322. * @returns the sphere mesh
  104323. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104324. */
  104325. static CreateSphere(name: string, options: {
  104326. segments?: number;
  104327. diameter?: number;
  104328. diameterX?: number;
  104329. diameterY?: number;
  104330. diameterZ?: number;
  104331. arc?: number;
  104332. slice?: number;
  104333. sideOrientation?: number;
  104334. frontUVs?: Vector4;
  104335. backUVs?: Vector4;
  104336. updatable?: boolean;
  104337. }, scene: any): Mesh;
  104338. }
  104339. }
  104340. declare module BABYLON.Debug {
  104341. /**
  104342. * Used to show the physics impostor around the specific mesh
  104343. */
  104344. export class PhysicsViewer {
  104345. /** @hidden */
  104346. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104347. /** @hidden */
  104348. protected _meshes: Array<Nullable<AbstractMesh>>;
  104349. /** @hidden */
  104350. protected _scene: Nullable<Scene>;
  104351. /** @hidden */
  104352. protected _numMeshes: number;
  104353. /** @hidden */
  104354. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104355. private _renderFunction;
  104356. private _utilityLayer;
  104357. private _debugBoxMesh;
  104358. private _debugSphereMesh;
  104359. private _debugCylinderMesh;
  104360. private _debugMaterial;
  104361. private _debugMeshMeshes;
  104362. /**
  104363. * Creates a new PhysicsViewer
  104364. * @param scene defines the hosting scene
  104365. */
  104366. constructor(scene: Scene);
  104367. /** @hidden */
  104368. protected _updateDebugMeshes(): void;
  104369. /**
  104370. * Renders a specified physic impostor
  104371. * @param impostor defines the impostor to render
  104372. * @param targetMesh defines the mesh represented by the impostor
  104373. * @returns the new debug mesh used to render the impostor
  104374. */
  104375. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104376. /**
  104377. * Hides a specified physic impostor
  104378. * @param impostor defines the impostor to hide
  104379. */
  104380. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104381. private _getDebugMaterial;
  104382. private _getDebugBoxMesh;
  104383. private _getDebugSphereMesh;
  104384. private _getDebugCylinderMesh;
  104385. private _getDebugMeshMesh;
  104386. private _getDebugMesh;
  104387. /** Releases all resources */
  104388. dispose(): void;
  104389. }
  104390. }
  104391. declare module BABYLON {
  104392. /**
  104393. * Class containing static functions to help procedurally build meshes
  104394. */
  104395. export class LinesBuilder {
  104396. /**
  104397. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104398. * * 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
  104399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104400. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104401. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104402. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104403. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104404. * * 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
  104405. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104408. * @param name defines the name of the new line system
  104409. * @param options defines the options used to create the line system
  104410. * @param scene defines the hosting scene
  104411. * @returns a new line system mesh
  104412. */
  104413. static CreateLineSystem(name: string, options: {
  104414. lines: Vector3[][];
  104415. updatable?: boolean;
  104416. instance?: Nullable<LinesMesh>;
  104417. colors?: Nullable<Color4[][]>;
  104418. useVertexAlpha?: boolean;
  104419. }, scene: Nullable<Scene>): LinesMesh;
  104420. /**
  104421. * Creates a line mesh
  104422. * 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
  104423. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104424. * * The parameter `points` is an array successive Vector3
  104425. * * 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
  104426. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104427. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104428. * * When updating an instance, remember that only point positions can change, not the number of points
  104429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104431. * @param name defines the name of the new line system
  104432. * @param options defines the options used to create the line system
  104433. * @param scene defines the hosting scene
  104434. * @returns a new line mesh
  104435. */
  104436. static CreateLines(name: string, options: {
  104437. points: Vector3[];
  104438. updatable?: boolean;
  104439. instance?: Nullable<LinesMesh>;
  104440. colors?: Color4[];
  104441. useVertexAlpha?: boolean;
  104442. }, scene?: Nullable<Scene>): LinesMesh;
  104443. /**
  104444. * Creates a dashed line mesh
  104445. * * 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
  104446. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104447. * * The parameter `points` is an array successive Vector3
  104448. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104449. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104450. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104451. * * 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
  104452. * * When updating an instance, remember that only point positions can change, not the number of points
  104453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104454. * @param name defines the name of the mesh
  104455. * @param options defines the options used to create the mesh
  104456. * @param scene defines the hosting scene
  104457. * @returns the dashed line mesh
  104458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104459. */
  104460. static CreateDashedLines(name: string, options: {
  104461. points: Vector3[];
  104462. dashSize?: number;
  104463. gapSize?: number;
  104464. dashNb?: number;
  104465. updatable?: boolean;
  104466. instance?: LinesMesh;
  104467. }, scene?: Nullable<Scene>): LinesMesh;
  104468. }
  104469. }
  104470. declare module BABYLON {
  104471. /**
  104472. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104473. * in order to better appreciate the issue one might have.
  104474. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104475. */
  104476. export class RayHelper {
  104477. /**
  104478. * Defines the ray we are currently tryin to visualize.
  104479. */
  104480. ray: Nullable<Ray>;
  104481. private _renderPoints;
  104482. private _renderLine;
  104483. private _renderFunction;
  104484. private _scene;
  104485. private _updateToMeshFunction;
  104486. private _attachedToMesh;
  104487. private _meshSpaceDirection;
  104488. private _meshSpaceOrigin;
  104489. /**
  104490. * Helper function to create a colored helper in a scene in one line.
  104491. * @param ray Defines the ray we are currently tryin to visualize
  104492. * @param scene Defines the scene the ray is used in
  104493. * @param color Defines the color we want to see the ray in
  104494. * @returns The newly created ray helper.
  104495. */
  104496. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104497. /**
  104498. * Instantiate a new ray helper.
  104499. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104500. * in order to better appreciate the issue one might have.
  104501. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104502. * @param ray Defines the ray we are currently tryin to visualize
  104503. */
  104504. constructor(ray: Ray);
  104505. /**
  104506. * Shows the ray we are willing to debug.
  104507. * @param scene Defines the scene the ray needs to be rendered in
  104508. * @param color Defines the color the ray needs to be rendered in
  104509. */
  104510. show(scene: Scene, color?: Color3): void;
  104511. /**
  104512. * Hides the ray we are debugging.
  104513. */
  104514. hide(): void;
  104515. private _render;
  104516. /**
  104517. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104518. * @param mesh Defines the mesh we want the helper attached to
  104519. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104520. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104521. * @param length Defines the length of the ray
  104522. */
  104523. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104524. /**
  104525. * Detach the ray helper from the mesh it has previously been attached to.
  104526. */
  104527. detachFromMesh(): void;
  104528. private _updateToMesh;
  104529. /**
  104530. * Dispose the helper and release its associated resources.
  104531. */
  104532. dispose(): void;
  104533. }
  104534. }
  104535. declare module BABYLON.Debug {
  104536. /**
  104537. * Class used to render a debug view of a given skeleton
  104538. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104539. */
  104540. export class SkeletonViewer {
  104541. /** defines the skeleton to render */
  104542. skeleton: Skeleton;
  104543. /** defines the mesh attached to the skeleton */
  104544. mesh: AbstractMesh;
  104545. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104546. autoUpdateBonesMatrices: boolean;
  104547. /** defines the rendering group id to use with the viewer */
  104548. renderingGroupId: number;
  104549. /** Gets or sets the color used to render the skeleton */
  104550. color: Color3;
  104551. private _scene;
  104552. private _debugLines;
  104553. private _debugMesh;
  104554. private _isEnabled;
  104555. private _renderFunction;
  104556. private _utilityLayer;
  104557. /**
  104558. * Returns the mesh used to render the bones
  104559. */
  104560. readonly debugMesh: Nullable<LinesMesh>;
  104561. /**
  104562. * Creates a new SkeletonViewer
  104563. * @param skeleton defines the skeleton to render
  104564. * @param mesh defines the mesh attached to the skeleton
  104565. * @param scene defines the hosting scene
  104566. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104567. * @param renderingGroupId defines the rendering group id to use with the viewer
  104568. */
  104569. constructor(
  104570. /** defines the skeleton to render */
  104571. skeleton: Skeleton,
  104572. /** defines the mesh attached to the skeleton */
  104573. mesh: AbstractMesh, scene: Scene,
  104574. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104575. autoUpdateBonesMatrices?: boolean,
  104576. /** defines the rendering group id to use with the viewer */
  104577. renderingGroupId?: number);
  104578. /** Gets or sets a boolean indicating if the viewer is enabled */
  104579. isEnabled: boolean;
  104580. private _getBonePosition;
  104581. private _getLinesForBonesWithLength;
  104582. private _getLinesForBonesNoLength;
  104583. /** Update the viewer to sync with current skeleton state */
  104584. update(): void;
  104585. /** Release associated resources */
  104586. dispose(): void;
  104587. }
  104588. }
  104589. declare module BABYLON {
  104590. /**
  104591. * Options to create the null engine
  104592. */
  104593. export class NullEngineOptions {
  104594. /**
  104595. * Render width (Default: 512)
  104596. */
  104597. renderWidth: number;
  104598. /**
  104599. * Render height (Default: 256)
  104600. */
  104601. renderHeight: number;
  104602. /**
  104603. * Texture size (Default: 512)
  104604. */
  104605. textureSize: number;
  104606. /**
  104607. * If delta time between frames should be constant
  104608. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104609. */
  104610. deterministicLockstep: boolean;
  104611. /**
  104612. * Maximum about of steps between frames (Default: 4)
  104613. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104614. */
  104615. lockstepMaxSteps: number;
  104616. }
  104617. /**
  104618. * The null engine class provides support for headless version of babylon.js.
  104619. * This can be used in server side scenario or for testing purposes
  104620. */
  104621. export class NullEngine extends Engine {
  104622. private _options;
  104623. /**
  104624. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104625. */
  104626. isDeterministicLockStep(): boolean;
  104627. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104628. getLockstepMaxSteps(): number;
  104629. /**
  104630. * Sets hardware scaling, used to save performance if needed
  104631. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104632. */
  104633. getHardwareScalingLevel(): number;
  104634. constructor(options?: NullEngineOptions);
  104635. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104636. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104637. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104638. getRenderWidth(useScreen?: boolean): number;
  104639. getRenderHeight(useScreen?: boolean): number;
  104640. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104641. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104642. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104643. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104644. bindSamplers(effect: Effect): void;
  104645. enableEffect(effect: Effect): void;
  104646. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104647. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104648. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104649. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104650. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104651. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104652. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104653. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104654. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104655. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104656. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104657. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104658. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104659. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104660. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104661. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104662. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104663. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104664. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104665. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104666. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104667. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104668. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104669. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104670. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104671. bindBuffers(vertexBuffers: {
  104672. [key: string]: VertexBuffer;
  104673. }, indexBuffer: DataBuffer, effect: Effect): void;
  104674. wipeCaches(bruteForce?: boolean): void;
  104675. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104676. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104677. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104678. /** @hidden */
  104679. _createTexture(): WebGLTexture;
  104680. /** @hidden */
  104681. _releaseTexture(texture: InternalTexture): void;
  104682. 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;
  104683. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104684. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104685. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104686. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104687. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104688. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104689. areAllEffectsReady(): boolean;
  104690. /**
  104691. * @hidden
  104692. * Get the current error code of the webGL context
  104693. * @returns the error code
  104694. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104695. */
  104696. getError(): number;
  104697. /** @hidden */
  104698. _getUnpackAlignement(): number;
  104699. /** @hidden */
  104700. _unpackFlipY(value: boolean): void;
  104701. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104702. /**
  104703. * Updates a dynamic vertex buffer.
  104704. * @param vertexBuffer the vertex buffer to update
  104705. * @param data the data used to update the vertex buffer
  104706. * @param byteOffset the byte offset of the data (optional)
  104707. * @param byteLength the byte length of the data (optional)
  104708. */
  104709. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104710. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104711. /** @hidden */
  104712. _bindTexture(channel: number, texture: InternalTexture): void;
  104713. /** @hidden */
  104714. _releaseBuffer(buffer: DataBuffer): boolean;
  104715. releaseEffects(): void;
  104716. displayLoadingUI(): void;
  104717. hideLoadingUI(): void;
  104718. /** @hidden */
  104719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104720. /** @hidden */
  104721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104722. /** @hidden */
  104723. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104724. /** @hidden */
  104725. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104726. }
  104727. }
  104728. declare module BABYLON {
  104729. /** @hidden */
  104730. export class _OcclusionDataStorage {
  104731. /** @hidden */
  104732. occlusionInternalRetryCounter: number;
  104733. /** @hidden */
  104734. isOcclusionQueryInProgress: boolean;
  104735. /** @hidden */
  104736. isOccluded: boolean;
  104737. /** @hidden */
  104738. occlusionRetryCount: number;
  104739. /** @hidden */
  104740. occlusionType: number;
  104741. /** @hidden */
  104742. occlusionQueryAlgorithmType: number;
  104743. }
  104744. interface Engine {
  104745. /**
  104746. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104747. * @return the new query
  104748. */
  104749. createQuery(): WebGLQuery;
  104750. /**
  104751. * Delete and release a webGL query
  104752. * @param query defines the query to delete
  104753. * @return the current engine
  104754. */
  104755. deleteQuery(query: WebGLQuery): Engine;
  104756. /**
  104757. * Check if a given query has resolved and got its value
  104758. * @param query defines the query to check
  104759. * @returns true if the query got its value
  104760. */
  104761. isQueryResultAvailable(query: WebGLQuery): boolean;
  104762. /**
  104763. * Gets the value of a given query
  104764. * @param query defines the query to check
  104765. * @returns the value of the query
  104766. */
  104767. getQueryResult(query: WebGLQuery): number;
  104768. /**
  104769. * Initiates an occlusion query
  104770. * @param algorithmType defines the algorithm to use
  104771. * @param query defines the query to use
  104772. * @returns the current engine
  104773. * @see http://doc.babylonjs.com/features/occlusionquery
  104774. */
  104775. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104776. /**
  104777. * Ends an occlusion query
  104778. * @see http://doc.babylonjs.com/features/occlusionquery
  104779. * @param algorithmType defines the algorithm to use
  104780. * @returns the current engine
  104781. */
  104782. endOcclusionQuery(algorithmType: number): Engine;
  104783. /**
  104784. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104785. * Please note that only one query can be issued at a time
  104786. * @returns a time token used to track the time span
  104787. */
  104788. startTimeQuery(): Nullable<_TimeToken>;
  104789. /**
  104790. * Ends a time query
  104791. * @param token defines the token used to measure the time span
  104792. * @returns the time spent (in ns)
  104793. */
  104794. endTimeQuery(token: _TimeToken): int;
  104795. /** @hidden */
  104796. _currentNonTimestampToken: Nullable<_TimeToken>;
  104797. /** @hidden */
  104798. _createTimeQuery(): WebGLQuery;
  104799. /** @hidden */
  104800. _deleteTimeQuery(query: WebGLQuery): void;
  104801. /** @hidden */
  104802. _getGlAlgorithmType(algorithmType: number): number;
  104803. /** @hidden */
  104804. _getTimeQueryResult(query: WebGLQuery): any;
  104805. /** @hidden */
  104806. _getTimeQueryAvailability(query: WebGLQuery): any;
  104807. }
  104808. interface AbstractMesh {
  104809. /**
  104810. * Backing filed
  104811. * @hidden
  104812. */
  104813. __occlusionDataStorage: _OcclusionDataStorage;
  104814. /**
  104815. * Access property
  104816. * @hidden
  104817. */
  104818. _occlusionDataStorage: _OcclusionDataStorage;
  104819. /**
  104820. * 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.
  104821. * The default value is -1 which means don't break the query and wait till the result
  104822. * @see http://doc.babylonjs.com/features/occlusionquery
  104823. */
  104824. occlusionRetryCount: number;
  104825. /**
  104826. * 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:
  104827. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104828. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104829. * * 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.
  104830. * @see http://doc.babylonjs.com/features/occlusionquery
  104831. */
  104832. occlusionType: number;
  104833. /**
  104834. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104835. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104836. * * 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.
  104837. * @see http://doc.babylonjs.com/features/occlusionquery
  104838. */
  104839. occlusionQueryAlgorithmType: number;
  104840. /**
  104841. * 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
  104842. * @see http://doc.babylonjs.com/features/occlusionquery
  104843. */
  104844. isOccluded: boolean;
  104845. /**
  104846. * Flag to check the progress status of the query
  104847. * @see http://doc.babylonjs.com/features/occlusionquery
  104848. */
  104849. isOcclusionQueryInProgress: boolean;
  104850. }
  104851. }
  104852. declare module BABYLON {
  104853. /** @hidden */
  104854. export var _forceTransformFeedbackToBundle: boolean;
  104855. interface Engine {
  104856. /**
  104857. * Creates a webGL transform feedback object
  104858. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104859. * @returns the webGL transform feedback object
  104860. */
  104861. createTransformFeedback(): WebGLTransformFeedback;
  104862. /**
  104863. * Delete a webGL transform feedback object
  104864. * @param value defines the webGL transform feedback object to delete
  104865. */
  104866. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104867. /**
  104868. * Bind a webGL transform feedback object to the webgl context
  104869. * @param value defines the webGL transform feedback object to bind
  104870. */
  104871. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104872. /**
  104873. * Begins a transform feedback operation
  104874. * @param usePoints defines if points or triangles must be used
  104875. */
  104876. beginTransformFeedback(usePoints: boolean): void;
  104877. /**
  104878. * Ends a transform feedback operation
  104879. */
  104880. endTransformFeedback(): void;
  104881. /**
  104882. * Specify the varyings to use with transform feedback
  104883. * @param program defines the associated webGL program
  104884. * @param value defines the list of strings representing the varying names
  104885. */
  104886. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104887. /**
  104888. * Bind a webGL buffer for a transform feedback operation
  104889. * @param value defines the webGL buffer to bind
  104890. */
  104891. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104892. }
  104893. }
  104894. declare module BABYLON {
  104895. /**
  104896. * Creation options of the multi render target texture.
  104897. */
  104898. export interface IMultiRenderTargetOptions {
  104899. /**
  104900. * Define if the texture needs to create mip maps after render.
  104901. */
  104902. generateMipMaps?: boolean;
  104903. /**
  104904. * Define the types of all the draw buffers we want to create
  104905. */
  104906. types?: number[];
  104907. /**
  104908. * Define the sampling modes of all the draw buffers we want to create
  104909. */
  104910. samplingModes?: number[];
  104911. /**
  104912. * Define if a depth buffer is required
  104913. */
  104914. generateDepthBuffer?: boolean;
  104915. /**
  104916. * Define if a stencil buffer is required
  104917. */
  104918. generateStencilBuffer?: boolean;
  104919. /**
  104920. * Define if a depth texture is required instead of a depth buffer
  104921. */
  104922. generateDepthTexture?: boolean;
  104923. /**
  104924. * Define the number of desired draw buffers
  104925. */
  104926. textureCount?: number;
  104927. /**
  104928. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104929. */
  104930. doNotChangeAspectRatio?: boolean;
  104931. /**
  104932. * Define the default type of the buffers we are creating
  104933. */
  104934. defaultType?: number;
  104935. }
  104936. /**
  104937. * A multi render target, like a render target provides the ability to render to a texture.
  104938. * Unlike the render target, it can render to several draw buffers in one draw.
  104939. * This is specially interesting in deferred rendering or for any effects requiring more than
  104940. * just one color from a single pass.
  104941. */
  104942. export class MultiRenderTarget extends RenderTargetTexture {
  104943. private _internalTextures;
  104944. private _textures;
  104945. private _multiRenderTargetOptions;
  104946. /**
  104947. * Get if draw buffers are currently supported by the used hardware and browser.
  104948. */
  104949. readonly isSupported: boolean;
  104950. /**
  104951. * Get the list of textures generated by the multi render target.
  104952. */
  104953. readonly textures: Texture[];
  104954. /**
  104955. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104956. */
  104957. readonly depthTexture: Texture;
  104958. /**
  104959. * Set the wrapping mode on U of all the textures we are rendering to.
  104960. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104961. */
  104962. wrapU: number;
  104963. /**
  104964. * Set the wrapping mode on V of all the textures we are rendering to.
  104965. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104966. */
  104967. wrapV: number;
  104968. /**
  104969. * Instantiate a new multi render target texture.
  104970. * A multi render target, like a render target provides the ability to render to a texture.
  104971. * Unlike the render target, it can render to several draw buffers in one draw.
  104972. * This is specially interesting in deferred rendering or for any effects requiring more than
  104973. * just one color from a single pass.
  104974. * @param name Define the name of the texture
  104975. * @param size Define the size of the buffers to render to
  104976. * @param count Define the number of target we are rendering into
  104977. * @param scene Define the scene the texture belongs to
  104978. * @param options Define the options used to create the multi render target
  104979. */
  104980. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104981. /** @hidden */
  104982. _rebuild(): void;
  104983. private _createInternalTextures;
  104984. private _createTextures;
  104985. /**
  104986. * Define the number of samples used if MSAA is enabled.
  104987. */
  104988. samples: number;
  104989. /**
  104990. * Resize all the textures in the multi render target.
  104991. * Be carrefull as it will recreate all the data in the new texture.
  104992. * @param size Define the new size
  104993. */
  104994. resize(size: any): void;
  104995. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104996. /**
  104997. * Dispose the render targets and their associated resources
  104998. */
  104999. dispose(): void;
  105000. /**
  105001. * Release all the underlying texture used as draw buffers.
  105002. */
  105003. releaseInternalTextures(): void;
  105004. }
  105005. }
  105006. declare module BABYLON {
  105007. interface Engine {
  105008. /**
  105009. * Unbind a list of render target textures from the webGL context
  105010. * This is used only when drawBuffer extension or webGL2 are active
  105011. * @param textures defines the render target textures to unbind
  105012. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105013. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105014. */
  105015. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  105016. /**
  105017. * Create a multi render target texture
  105018. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  105019. * @param size defines the size of the texture
  105020. * @param options defines the creation options
  105021. * @returns the cube texture as an InternalTexture
  105022. */
  105023. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  105024. /**
  105025. * Update the sample count for a given multiple render target texture
  105026. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  105027. * @param textures defines the textures to update
  105028. * @param samples defines the sample count to set
  105029. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  105030. */
  105031. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  105032. }
  105033. }
  105034. declare module BABYLON {
  105035. /**
  105036. * Gather the list of clipboard event types as constants.
  105037. */
  105038. export class ClipboardEventTypes {
  105039. /**
  105040. * The clipboard event is fired when a copy command is active (pressed).
  105041. */
  105042. static readonly COPY: number;
  105043. /**
  105044. * The clipboard event is fired when a cut command is active (pressed).
  105045. */
  105046. static readonly CUT: number;
  105047. /**
  105048. * The clipboard event is fired when a paste command is active (pressed).
  105049. */
  105050. static readonly PASTE: number;
  105051. }
  105052. /**
  105053. * This class is used to store clipboard related info for the onClipboardObservable event.
  105054. */
  105055. export class ClipboardInfo {
  105056. /**
  105057. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105058. */
  105059. type: number;
  105060. /**
  105061. * Defines the related dom event
  105062. */
  105063. event: ClipboardEvent;
  105064. /**
  105065. *Creates an instance of ClipboardInfo.
  105066. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  105067. * @param event Defines the related dom event
  105068. */
  105069. constructor(
  105070. /**
  105071. * Defines the type of event (BABYLON.ClipboardEventTypes)
  105072. */
  105073. type: number,
  105074. /**
  105075. * Defines the related dom event
  105076. */
  105077. event: ClipboardEvent);
  105078. /**
  105079. * Get the clipboard event's type from the keycode.
  105080. * @param keyCode Defines the keyCode for the current keyboard event.
  105081. * @return {number}
  105082. */
  105083. static GetTypeFromCharacter(keyCode: number): number;
  105084. }
  105085. }
  105086. declare module BABYLON {
  105087. /**
  105088. * Class used to represent data loading progression
  105089. */
  105090. export class SceneLoaderProgressEvent {
  105091. /** defines if data length to load can be evaluated */
  105092. readonly lengthComputable: boolean;
  105093. /** defines the loaded data length */
  105094. readonly loaded: number;
  105095. /** defines the data length to load */
  105096. readonly total: number;
  105097. /**
  105098. * Create a new progress event
  105099. * @param lengthComputable defines if data length to load can be evaluated
  105100. * @param loaded defines the loaded data length
  105101. * @param total defines the data length to load
  105102. */
  105103. constructor(
  105104. /** defines if data length to load can be evaluated */
  105105. lengthComputable: boolean,
  105106. /** defines the loaded data length */
  105107. loaded: number,
  105108. /** defines the data length to load */
  105109. total: number);
  105110. /**
  105111. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105112. * @param event defines the source event
  105113. * @returns a new SceneLoaderProgressEvent
  105114. */
  105115. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105116. }
  105117. /**
  105118. * Interface used by SceneLoader plugins to define supported file extensions
  105119. */
  105120. export interface ISceneLoaderPluginExtensions {
  105121. /**
  105122. * Defines the list of supported extensions
  105123. */
  105124. [extension: string]: {
  105125. isBinary: boolean;
  105126. };
  105127. }
  105128. /**
  105129. * Interface used by SceneLoader plugin factory
  105130. */
  105131. export interface ISceneLoaderPluginFactory {
  105132. /**
  105133. * Defines the name of the factory
  105134. */
  105135. name: string;
  105136. /**
  105137. * Function called to create a new plugin
  105138. * @return the new plugin
  105139. */
  105140. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105141. /**
  105142. * Boolean indicating if the plugin can direct load specific data
  105143. */
  105144. canDirectLoad?: (data: string) => boolean;
  105145. }
  105146. /**
  105147. * Interface used to define a SceneLoader plugin
  105148. */
  105149. export interface ISceneLoaderPlugin {
  105150. /**
  105151. * The friendly name of this plugin.
  105152. */
  105153. name: string;
  105154. /**
  105155. * The file extensions supported by this plugin.
  105156. */
  105157. extensions: string | ISceneLoaderPluginExtensions;
  105158. /**
  105159. * Import meshes into a scene.
  105160. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105161. * @param scene The scene to import into
  105162. * @param data The data to import
  105163. * @param rootUrl The root url for scene and resources
  105164. * @param meshes The meshes array to import into
  105165. * @param particleSystems The particle systems array to import into
  105166. * @param skeletons The skeletons array to import into
  105167. * @param onError The callback when import fails
  105168. * @returns True if successful or false otherwise
  105169. */
  105170. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105171. /**
  105172. * Load into a scene.
  105173. * @param scene The scene to load into
  105174. * @param data The data to import
  105175. * @param rootUrl The root url for scene and resources
  105176. * @param onError The callback when import fails
  105177. * @returns true if successful or false otherwise
  105178. */
  105179. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105180. /**
  105181. * The callback that returns true if the data can be directly loaded.
  105182. */
  105183. canDirectLoad?: (data: string) => boolean;
  105184. /**
  105185. * The callback that allows custom handling of the root url based on the response url.
  105186. */
  105187. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105188. /**
  105189. * Load into an asset container.
  105190. * @param scene The scene to load into
  105191. * @param data The data to import
  105192. * @param rootUrl The root url for scene and resources
  105193. * @param onError The callback when import fails
  105194. * @returns The loaded asset container
  105195. */
  105196. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105197. }
  105198. /**
  105199. * Interface used to define an async SceneLoader plugin
  105200. */
  105201. export interface ISceneLoaderPluginAsync {
  105202. /**
  105203. * The friendly name of this plugin.
  105204. */
  105205. name: string;
  105206. /**
  105207. * The file extensions supported by this plugin.
  105208. */
  105209. extensions: string | ISceneLoaderPluginExtensions;
  105210. /**
  105211. * Import meshes into a scene.
  105212. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105213. * @param scene The scene to import into
  105214. * @param data The data to import
  105215. * @param rootUrl The root url for scene and resources
  105216. * @param onProgress The callback when the load progresses
  105217. * @param fileName Defines the name of the file to load
  105218. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105219. */
  105220. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105221. meshes: AbstractMesh[];
  105222. particleSystems: IParticleSystem[];
  105223. skeletons: Skeleton[];
  105224. animationGroups: AnimationGroup[];
  105225. }>;
  105226. /**
  105227. * Load into a scene.
  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 onProgress The callback when the load progresses
  105232. * @param fileName Defines the name of the file to load
  105233. * @returns Nothing
  105234. */
  105235. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105236. /**
  105237. * The callback that returns true if the data can be directly loaded.
  105238. */
  105239. canDirectLoad?: (data: string) => boolean;
  105240. /**
  105241. * The callback that allows custom handling of the root url based on the response url.
  105242. */
  105243. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105244. /**
  105245. * Load into an asset container.
  105246. * @param scene The scene to load into
  105247. * @param data The data to import
  105248. * @param rootUrl The root url for scene and resources
  105249. * @param onProgress The callback when the load progresses
  105250. * @param fileName Defines the name of the file to load
  105251. * @returns The loaded asset container
  105252. */
  105253. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105254. }
  105255. /**
  105256. * Class used to load scene from various file formats using registered plugins
  105257. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105258. */
  105259. export class SceneLoader {
  105260. /**
  105261. * No logging while loading
  105262. */
  105263. static readonly NO_LOGGING: number;
  105264. /**
  105265. * Minimal logging while loading
  105266. */
  105267. static readonly MINIMAL_LOGGING: number;
  105268. /**
  105269. * Summary logging while loading
  105270. */
  105271. static readonly SUMMARY_LOGGING: number;
  105272. /**
  105273. * Detailled logging while loading
  105274. */
  105275. static readonly DETAILED_LOGGING: number;
  105276. /**
  105277. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105278. */
  105279. static ForceFullSceneLoadingForIncremental: boolean;
  105280. /**
  105281. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105282. */
  105283. static ShowLoadingScreen: boolean;
  105284. /**
  105285. * Defines the current logging level (while loading the scene)
  105286. * @ignorenaming
  105287. */
  105288. static loggingLevel: number;
  105289. /**
  105290. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105291. */
  105292. static CleanBoneMatrixWeights: boolean;
  105293. /**
  105294. * Event raised when a plugin is used to load a scene
  105295. */
  105296. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105297. private static _registeredPlugins;
  105298. private static _getDefaultPlugin;
  105299. private static _getPluginForExtension;
  105300. private static _getPluginForDirectLoad;
  105301. private static _getPluginForFilename;
  105302. private static _getDirectLoad;
  105303. private static _loadData;
  105304. private static _getFileInfo;
  105305. /**
  105306. * Gets a plugin that can load the given extension
  105307. * @param extension defines the extension to load
  105308. * @returns a plugin or null if none works
  105309. */
  105310. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105311. /**
  105312. * Gets a boolean indicating that the given extension can be loaded
  105313. * @param extension defines the extension to load
  105314. * @returns true if the extension is supported
  105315. */
  105316. static IsPluginForExtensionAvailable(extension: string): boolean;
  105317. /**
  105318. * Adds a new plugin to the list of registered plugins
  105319. * @param plugin defines the plugin to add
  105320. */
  105321. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105322. /**
  105323. * Import meshes into a scene
  105324. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105325. * @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)
  105326. * @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)
  105327. * @param scene the instance of BABYLON.Scene to append to
  105328. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105329. * @param onProgress a callback with a progress event for each file being loaded
  105330. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105331. * @param pluginExtension the extension used to determine the plugin
  105332. * @returns The loaded plugin
  105333. */
  105334. 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>;
  105335. /**
  105336. * Import meshes into a scene
  105337. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105338. * @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)
  105339. * @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)
  105340. * @param scene the instance of BABYLON.Scene to append to
  105341. * @param onProgress a callback with a progress event for each file being loaded
  105342. * @param pluginExtension the extension used to determine the plugin
  105343. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105344. */
  105345. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105346. meshes: AbstractMesh[];
  105347. particleSystems: IParticleSystem[];
  105348. skeletons: Skeleton[];
  105349. animationGroups: AnimationGroup[];
  105350. }>;
  105351. /**
  105352. * Load a scene
  105353. * @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)
  105354. * @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)
  105355. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105356. * @param onSuccess a callback with the scene when import succeeds
  105357. * @param onProgress a callback with a progress event for each file being loaded
  105358. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105359. * @param pluginExtension the extension used to determine the plugin
  105360. * @returns The loaded plugin
  105361. */
  105362. 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>;
  105363. /**
  105364. * Load a scene
  105365. * @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)
  105366. * @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)
  105367. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105368. * @param onProgress a callback with a progress event for each file being loaded
  105369. * @param pluginExtension the extension used to determine the plugin
  105370. * @returns The loaded scene
  105371. */
  105372. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105373. /**
  105374. * Append a scene
  105375. * @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)
  105376. * @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)
  105377. * @param scene is the instance of BABYLON.Scene to append to
  105378. * @param onSuccess a callback with the scene when import succeeds
  105379. * @param onProgress a callback with a progress event for each file being loaded
  105380. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105381. * @param pluginExtension the extension used to determine the plugin
  105382. * @returns The loaded plugin
  105383. */
  105384. 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>;
  105385. /**
  105386. * Append a scene
  105387. * @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)
  105388. * @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)
  105389. * @param scene is the instance of BABYLON.Scene to append to
  105390. * @param onProgress a callback with a progress event for each file being loaded
  105391. * @param pluginExtension the extension used to determine the plugin
  105392. * @returns The given scene
  105393. */
  105394. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105395. /**
  105396. * Load a scene into an asset container
  105397. * @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)
  105398. * @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)
  105399. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105400. * @param onSuccess a callback with the scene when import succeeds
  105401. * @param onProgress a callback with a progress event for each file being loaded
  105402. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105403. * @param pluginExtension the extension used to determine the plugin
  105404. * @returns The loaded plugin
  105405. */
  105406. 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>;
  105407. /**
  105408. * Load a scene into an asset container
  105409. * @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)
  105410. * @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)
  105411. * @param scene is the instance of Scene to append to
  105412. * @param onProgress a callback with a progress event for each file being loaded
  105413. * @param pluginExtension the extension used to determine the plugin
  105414. * @returns The loaded asset container
  105415. */
  105416. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105417. }
  105418. }
  105419. declare module BABYLON {
  105420. /**
  105421. * Google Daydream controller
  105422. */
  105423. export class DaydreamController extends WebVRController {
  105424. /**
  105425. * Base Url for the controller model.
  105426. */
  105427. static MODEL_BASE_URL: string;
  105428. /**
  105429. * File name for the controller model.
  105430. */
  105431. static MODEL_FILENAME: string;
  105432. /**
  105433. * Gamepad Id prefix used to identify Daydream Controller.
  105434. */
  105435. static readonly GAMEPAD_ID_PREFIX: string;
  105436. /**
  105437. * Creates a new DaydreamController from a gamepad
  105438. * @param vrGamepad the gamepad that the controller should be created from
  105439. */
  105440. constructor(vrGamepad: any);
  105441. /**
  105442. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105443. * @param scene scene in which to add meshes
  105444. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105445. */
  105446. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105447. /**
  105448. * Called once for each button that changed state since the last frame
  105449. * @param buttonIdx Which button index changed
  105450. * @param state New state of the button
  105451. * @param changes Which properties on the state changed since last frame
  105452. */
  105453. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105454. }
  105455. }
  105456. declare module BABYLON {
  105457. /**
  105458. * Gear VR Controller
  105459. */
  105460. export class GearVRController extends WebVRController {
  105461. /**
  105462. * Base Url for the controller model.
  105463. */
  105464. static MODEL_BASE_URL: string;
  105465. /**
  105466. * File name for the controller model.
  105467. */
  105468. static MODEL_FILENAME: string;
  105469. /**
  105470. * Gamepad Id prefix used to identify this controller.
  105471. */
  105472. static readonly GAMEPAD_ID_PREFIX: string;
  105473. private readonly _buttonIndexToObservableNameMap;
  105474. /**
  105475. * Creates a new GearVRController 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. * Generic Controller
  105497. */
  105498. export class GenericController extends WebVRController {
  105499. /**
  105500. * Base Url for the controller model.
  105501. */
  105502. static readonly MODEL_BASE_URL: string;
  105503. /**
  105504. * File name for the controller model.
  105505. */
  105506. static readonly MODEL_FILENAME: string;
  105507. /**
  105508. * Creates a new GenericController from a gamepad
  105509. * @param vrGamepad the gamepad that the controller should be created from
  105510. */
  105511. constructor(vrGamepad: any);
  105512. /**
  105513. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105514. * @param scene scene in which to add meshes
  105515. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105516. */
  105517. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105518. /**
  105519. * Called once for each button that changed state since the last frame
  105520. * @param buttonIdx Which button index changed
  105521. * @param state New state of the button
  105522. * @param changes Which properties on the state changed since last frame
  105523. */
  105524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105525. }
  105526. }
  105527. declare module BABYLON {
  105528. /**
  105529. * Oculus Touch Controller
  105530. */
  105531. export class OculusTouchController extends WebVRController {
  105532. /**
  105533. * Base Url for the controller model.
  105534. */
  105535. static MODEL_BASE_URL: string;
  105536. /**
  105537. * File name for the left controller model.
  105538. */
  105539. static MODEL_LEFT_FILENAME: string;
  105540. /**
  105541. * File name for the right controller model.
  105542. */
  105543. static MODEL_RIGHT_FILENAME: string;
  105544. /**
  105545. * Base Url for the Quest controller model.
  105546. */
  105547. static QUEST_MODEL_BASE_URL: string;
  105548. /**
  105549. * @hidden
  105550. * If the controllers are running on a device that needs the updated Quest controller models
  105551. */
  105552. static _IsQuest: boolean;
  105553. /**
  105554. * Fired when the secondary trigger on this controller is modified
  105555. */
  105556. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105557. /**
  105558. * Fired when the thumb rest on this controller is modified
  105559. */
  105560. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105561. /**
  105562. * Creates a new OculusTouchController from a gamepad
  105563. * @param vrGamepad the gamepad that the controller should be created from
  105564. */
  105565. constructor(vrGamepad: any);
  105566. /**
  105567. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105568. * @param scene scene in which to add meshes
  105569. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105570. */
  105571. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105572. /**
  105573. * Fired when the A button on this controller is modified
  105574. */
  105575. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105576. /**
  105577. * Fired when the B button on this controller is modified
  105578. */
  105579. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105580. /**
  105581. * Fired when the X button on this controller is modified
  105582. */
  105583. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105584. /**
  105585. * Fired when the Y button on this controller is modified
  105586. */
  105587. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105588. /**
  105589. * Called once for each button that changed state since the last frame
  105590. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105591. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105592. * 2) secondary trigger (same)
  105593. * 3) A (right) X (left), touch, pressed = value
  105594. * 4) B / Y
  105595. * 5) thumb rest
  105596. * @param buttonIdx Which button index changed
  105597. * @param state New state of the button
  105598. * @param changes Which properties on the state changed since last frame
  105599. */
  105600. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105601. }
  105602. }
  105603. declare module BABYLON {
  105604. /**
  105605. * Vive Controller
  105606. */
  105607. export class ViveController extends WebVRController {
  105608. /**
  105609. * Base Url for the controller model.
  105610. */
  105611. static MODEL_BASE_URL: string;
  105612. /**
  105613. * File name for the controller model.
  105614. */
  105615. static MODEL_FILENAME: string;
  105616. /**
  105617. * Creates a new ViveController from a gamepad
  105618. * @param vrGamepad the gamepad that the controller should be created from
  105619. */
  105620. constructor(vrGamepad: any);
  105621. /**
  105622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105623. * @param scene scene in which to add meshes
  105624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105625. */
  105626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105627. /**
  105628. * Fired when the left button on this controller is modified
  105629. */
  105630. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105631. /**
  105632. * Fired when the right button on this controller is modified
  105633. */
  105634. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105635. /**
  105636. * Fired when the menu button on this controller is modified
  105637. */
  105638. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105639. /**
  105640. * Called once for each button that changed state since the last frame
  105641. * Vive mapping:
  105642. * 0: touchpad
  105643. * 1: trigger
  105644. * 2: left AND right buttons
  105645. * 3: menu button
  105646. * @param buttonIdx Which button index changed
  105647. * @param state New state of the button
  105648. * @param changes Which properties on the state changed since last frame
  105649. */
  105650. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105651. }
  105652. }
  105653. declare module BABYLON {
  105654. /**
  105655. * Defines the WindowsMotionController object that the state of the windows motion controller
  105656. */
  105657. export class WindowsMotionController extends WebVRController {
  105658. /**
  105659. * The base url used to load the left and right controller models
  105660. */
  105661. static MODEL_BASE_URL: string;
  105662. /**
  105663. * The name of the left controller model file
  105664. */
  105665. static MODEL_LEFT_FILENAME: string;
  105666. /**
  105667. * The name of the right controller model file
  105668. */
  105669. static MODEL_RIGHT_FILENAME: string;
  105670. /**
  105671. * The controller name prefix for this controller type
  105672. */
  105673. static readonly GAMEPAD_ID_PREFIX: string;
  105674. /**
  105675. * The controller id pattern for this controller type
  105676. */
  105677. private static readonly GAMEPAD_ID_PATTERN;
  105678. private _loadedMeshInfo;
  105679. private readonly _mapping;
  105680. /**
  105681. * Fired when the trackpad on this controller is clicked
  105682. */
  105683. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105684. /**
  105685. * Fired when the trackpad on this controller is modified
  105686. */
  105687. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105688. /**
  105689. * The current x and y values of this controller's trackpad
  105690. */
  105691. trackpad: StickValues;
  105692. /**
  105693. * Creates a new WindowsMotionController from a gamepad
  105694. * @param vrGamepad the gamepad that the controller should be created from
  105695. */
  105696. constructor(vrGamepad: any);
  105697. /**
  105698. * Fired when the trigger on this controller is modified
  105699. */
  105700. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105701. /**
  105702. * Fired when the menu button on this controller is modified
  105703. */
  105704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105705. /**
  105706. * Fired when the grip button on this controller is modified
  105707. */
  105708. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105709. /**
  105710. * Fired when the thumbstick button on this controller is modified
  105711. */
  105712. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105713. /**
  105714. * Fired when the touchpad button on this controller is modified
  105715. */
  105716. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105717. /**
  105718. * Fired when the touchpad values on this controller are modified
  105719. */
  105720. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105721. private _updateTrackpad;
  105722. /**
  105723. * Called once per frame by the engine.
  105724. */
  105725. update(): void;
  105726. /**
  105727. * Called once for each button that changed state since the last frame
  105728. * @param buttonIdx Which button index changed
  105729. * @param state New state of the button
  105730. * @param changes Which properties on the state changed since last frame
  105731. */
  105732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105733. /**
  105734. * Moves the buttons on the controller mesh based on their current state
  105735. * @param buttonName the name of the button to move
  105736. * @param buttonValue the value of the button which determines the buttons new position
  105737. */
  105738. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105739. /**
  105740. * Moves the axis on the controller mesh based on its current state
  105741. * @param axis the index of the axis
  105742. * @param axisValue the value of the axis which determines the meshes new position
  105743. * @hidden
  105744. */
  105745. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105746. /**
  105747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105748. * @param scene scene in which to add meshes
  105749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105750. */
  105751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105752. /**
  105753. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105754. * can be transformed by button presses and axes values, based on this._mapping.
  105755. *
  105756. * @param scene scene in which the meshes exist
  105757. * @param meshes list of meshes that make up the controller model to process
  105758. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105759. */
  105760. private processModel;
  105761. private createMeshInfo;
  105762. /**
  105763. * Gets the ray of the controller in the direction the controller is pointing
  105764. * @param length the length the resulting ray should be
  105765. * @returns a ray in the direction the controller is pointing
  105766. */
  105767. getForwardRay(length?: number): Ray;
  105768. /**
  105769. * Disposes of the controller
  105770. */
  105771. dispose(): void;
  105772. }
  105773. }
  105774. declare module BABYLON {
  105775. /**
  105776. * Class containing static functions to help procedurally build meshes
  105777. */
  105778. export class PolyhedronBuilder {
  105779. /**
  105780. * Creates a polyhedron mesh
  105781. * * 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
  105782. * * The parameter `size` (positive float, default 1) sets the polygon size
  105783. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105784. * * 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`
  105785. * * 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
  105786. * * 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)`)
  105787. * * 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
  105788. * * 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
  105789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105792. * @param name defines the name of the mesh
  105793. * @param options defines the options used to create the mesh
  105794. * @param scene defines the hosting scene
  105795. * @returns the polyhedron mesh
  105796. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105797. */
  105798. static CreatePolyhedron(name: string, options: {
  105799. type?: number;
  105800. size?: number;
  105801. sizeX?: number;
  105802. sizeY?: number;
  105803. sizeZ?: number;
  105804. custom?: any;
  105805. faceUV?: Vector4[];
  105806. faceColors?: Color4[];
  105807. flat?: boolean;
  105808. updatable?: boolean;
  105809. sideOrientation?: number;
  105810. frontUVs?: Vector4;
  105811. backUVs?: Vector4;
  105812. }, scene?: Nullable<Scene>): Mesh;
  105813. }
  105814. }
  105815. declare module BABYLON {
  105816. /**
  105817. * Gizmo that enables scaling a mesh along 3 axis
  105818. */
  105819. export class ScaleGizmo extends Gizmo {
  105820. /**
  105821. * Internal gizmo used for interactions on the x axis
  105822. */
  105823. xGizmo: AxisScaleGizmo;
  105824. /**
  105825. * Internal gizmo used for interactions on the y axis
  105826. */
  105827. yGizmo: AxisScaleGizmo;
  105828. /**
  105829. * Internal gizmo used for interactions on the z axis
  105830. */
  105831. zGizmo: AxisScaleGizmo;
  105832. /**
  105833. * Internal gizmo used to scale all axis equally
  105834. */
  105835. uniformScaleGizmo: AxisScaleGizmo;
  105836. private _meshAttached;
  105837. private _updateGizmoRotationToMatchAttachedMesh;
  105838. private _snapDistance;
  105839. private _scaleRatio;
  105840. private _uniformScalingMesh;
  105841. private _octahedron;
  105842. /** Fires an event when any of it's sub gizmos are dragged */
  105843. onDragStartObservable: Observable<unknown>;
  105844. /** Fires an event when any of it's sub gizmos are released from dragging */
  105845. onDragEndObservable: Observable<unknown>;
  105846. attachedMesh: Nullable<AbstractMesh>;
  105847. /**
  105848. * Creates a ScaleGizmo
  105849. * @param gizmoLayer The utility layer the gizmo will be added to
  105850. */
  105851. constructor(gizmoLayer?: UtilityLayerRenderer);
  105852. updateGizmoRotationToMatchAttachedMesh: boolean;
  105853. /**
  105854. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105855. */
  105856. snapDistance: number;
  105857. /**
  105858. * Ratio for the scale of the gizmo (Default: 1)
  105859. */
  105860. scaleRatio: number;
  105861. /**
  105862. * Disposes of the gizmo
  105863. */
  105864. dispose(): void;
  105865. }
  105866. }
  105867. declare module BABYLON {
  105868. /**
  105869. * Single axis scale gizmo
  105870. */
  105871. export class AxisScaleGizmo extends Gizmo {
  105872. /**
  105873. * Drag behavior responsible for the gizmos dragging interactions
  105874. */
  105875. dragBehavior: PointerDragBehavior;
  105876. private _pointerObserver;
  105877. /**
  105878. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105879. */
  105880. snapDistance: number;
  105881. /**
  105882. * Event that fires each time the gizmo snaps to a new location.
  105883. * * snapDistance is the the change in distance
  105884. */
  105885. onSnapObservable: Observable<{
  105886. snapDistance: number;
  105887. }>;
  105888. /**
  105889. * If the scaling operation should be done on all axis (default: false)
  105890. */
  105891. uniformScaling: boolean;
  105892. private _isEnabled;
  105893. private _parent;
  105894. private _arrow;
  105895. private _coloredMaterial;
  105896. private _hoverMaterial;
  105897. /**
  105898. * Creates an AxisScaleGizmo
  105899. * @param gizmoLayer The utility layer the gizmo will be added to
  105900. * @param dragAxis The axis which the gizmo will be able to scale on
  105901. * @param color The color of the gizmo
  105902. */
  105903. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105904. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105905. /**
  105906. * If the gizmo is enabled
  105907. */
  105908. isEnabled: boolean;
  105909. /**
  105910. * Disposes of the gizmo
  105911. */
  105912. dispose(): void;
  105913. /**
  105914. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105915. * @param mesh The mesh to replace the default mesh of the gizmo
  105916. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105917. */
  105918. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105919. }
  105920. }
  105921. declare module BABYLON {
  105922. /**
  105923. * Bounding box gizmo
  105924. */
  105925. export class BoundingBoxGizmo extends Gizmo {
  105926. private _lineBoundingBox;
  105927. private _rotateSpheresParent;
  105928. private _scaleBoxesParent;
  105929. private _boundingDimensions;
  105930. private _renderObserver;
  105931. private _pointerObserver;
  105932. private _scaleDragSpeed;
  105933. private _tmpQuaternion;
  105934. private _tmpVector;
  105935. private _tmpRotationMatrix;
  105936. /**
  105937. * 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)
  105938. */
  105939. ignoreChildren: boolean;
  105940. /**
  105941. * 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)
  105942. */
  105943. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105944. /**
  105945. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105946. */
  105947. rotationSphereSize: number;
  105948. /**
  105949. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105950. */
  105951. scaleBoxSize: number;
  105952. /**
  105953. * 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)
  105954. */
  105955. fixedDragMeshScreenSize: boolean;
  105956. /**
  105957. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105958. */
  105959. fixedDragMeshScreenSizeDistanceFactor: number;
  105960. /**
  105961. * Fired when a rotation sphere or scale box is dragged
  105962. */
  105963. onDragStartObservable: Observable<{}>;
  105964. /**
  105965. * Fired when a scale box is dragged
  105966. */
  105967. onScaleBoxDragObservable: Observable<{}>;
  105968. /**
  105969. * Fired when a scale box drag is ended
  105970. */
  105971. onScaleBoxDragEndObservable: Observable<{}>;
  105972. /**
  105973. * Fired when a rotation sphere is dragged
  105974. */
  105975. onRotationSphereDragObservable: Observable<{}>;
  105976. /**
  105977. * Fired when a rotation sphere drag is ended
  105978. */
  105979. onRotationSphereDragEndObservable: Observable<{}>;
  105980. /**
  105981. * 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)
  105982. */
  105983. scalePivot: Nullable<Vector3>;
  105984. /**
  105985. * Mesh used as a pivot to rotate the attached mesh
  105986. */
  105987. private _anchorMesh;
  105988. private _existingMeshScale;
  105989. private _dragMesh;
  105990. private pointerDragBehavior;
  105991. private coloredMaterial;
  105992. private hoverColoredMaterial;
  105993. /**
  105994. * Sets the color of the bounding box gizmo
  105995. * @param color the color to set
  105996. */
  105997. setColor(color: Color3): void;
  105998. /**
  105999. * Creates an BoundingBoxGizmo
  106000. * @param gizmoLayer The utility layer the gizmo will be added to
  106001. * @param color The color of the gizmo
  106002. */
  106003. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  106004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106005. private _selectNode;
  106006. /**
  106007. * Updates the bounding box information for the Gizmo
  106008. */
  106009. updateBoundingBox(): void;
  106010. private _updateRotationSpheres;
  106011. private _updateScaleBoxes;
  106012. /**
  106013. * Enables rotation on the specified axis and disables rotation on the others
  106014. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  106015. */
  106016. setEnabledRotationAxis(axis: string): void;
  106017. /**
  106018. * Enables/disables scaling
  106019. * @param enable if scaling should be enabled
  106020. */
  106021. setEnabledScaling(enable: boolean): void;
  106022. private _updateDummy;
  106023. /**
  106024. * Enables a pointer drag behavior on the bounding box of the gizmo
  106025. */
  106026. enableDragBehavior(): void;
  106027. /**
  106028. * Disposes of the gizmo
  106029. */
  106030. dispose(): void;
  106031. /**
  106032. * 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)
  106033. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  106034. * @returns the bounding box mesh with the passed in mesh as a child
  106035. */
  106036. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  106037. /**
  106038. * CustomMeshes are not supported by this gizmo
  106039. * @param mesh The mesh to replace the default mesh of the gizmo
  106040. */
  106041. setCustomMesh(mesh: Mesh): void;
  106042. }
  106043. }
  106044. declare module BABYLON {
  106045. /**
  106046. * Single plane rotation gizmo
  106047. */
  106048. export class PlaneRotationGizmo extends Gizmo {
  106049. /**
  106050. * Drag behavior responsible for the gizmos dragging interactions
  106051. */
  106052. dragBehavior: PointerDragBehavior;
  106053. private _pointerObserver;
  106054. /**
  106055. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  106056. */
  106057. snapDistance: number;
  106058. /**
  106059. * Event that fires each time the gizmo snaps to a new location.
  106060. * * snapDistance is the the change in distance
  106061. */
  106062. onSnapObservable: Observable<{
  106063. snapDistance: number;
  106064. }>;
  106065. private _isEnabled;
  106066. private _parent;
  106067. /**
  106068. * Creates a PlaneRotationGizmo
  106069. * @param gizmoLayer The utility layer the gizmo will be added to
  106070. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  106071. * @param color The color of the gizmo
  106072. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106073. */
  106074. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  106075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106076. /**
  106077. * If the gizmo is enabled
  106078. */
  106079. isEnabled: boolean;
  106080. /**
  106081. * Disposes of the gizmo
  106082. */
  106083. dispose(): void;
  106084. }
  106085. }
  106086. declare module BABYLON {
  106087. /**
  106088. * Gizmo that enables rotating a mesh along 3 axis
  106089. */
  106090. export class RotationGizmo extends Gizmo {
  106091. /**
  106092. * Internal gizmo used for interactions on the x axis
  106093. */
  106094. xGizmo: PlaneRotationGizmo;
  106095. /**
  106096. * Internal gizmo used for interactions on the y axis
  106097. */
  106098. yGizmo: PlaneRotationGizmo;
  106099. /**
  106100. * Internal gizmo used for interactions on the z axis
  106101. */
  106102. zGizmo: PlaneRotationGizmo;
  106103. /** Fires an event when any of it's sub gizmos are dragged */
  106104. onDragStartObservable: Observable<unknown>;
  106105. /** Fires an event when any of it's sub gizmos are released from dragging */
  106106. onDragEndObservable: Observable<unknown>;
  106107. private _meshAttached;
  106108. attachedMesh: Nullable<AbstractMesh>;
  106109. /**
  106110. * Creates a RotationGizmo
  106111. * @param gizmoLayer The utility layer the gizmo will be added to
  106112. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106113. */
  106114. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106115. updateGizmoRotationToMatchAttachedMesh: boolean;
  106116. /**
  106117. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106118. */
  106119. snapDistance: number;
  106120. /**
  106121. * Ratio for the scale of the gizmo (Default: 1)
  106122. */
  106123. scaleRatio: number;
  106124. /**
  106125. * Disposes of the gizmo
  106126. */
  106127. dispose(): void;
  106128. /**
  106129. * CustomMeshes are not supported by this gizmo
  106130. * @param mesh The mesh to replace the default mesh of the gizmo
  106131. */
  106132. setCustomMesh(mesh: Mesh): void;
  106133. }
  106134. }
  106135. declare module BABYLON {
  106136. /**
  106137. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106138. */
  106139. export class GizmoManager implements IDisposable {
  106140. private scene;
  106141. /**
  106142. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106143. */
  106144. gizmos: {
  106145. positionGizmo: Nullable<PositionGizmo>;
  106146. rotationGizmo: Nullable<RotationGizmo>;
  106147. scaleGizmo: Nullable<ScaleGizmo>;
  106148. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106149. };
  106150. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106151. clearGizmoOnEmptyPointerEvent: boolean;
  106152. /** Fires an event when the manager is attached to a mesh */
  106153. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106154. private _gizmosEnabled;
  106155. private _pointerObserver;
  106156. private _attachedMesh;
  106157. private _boundingBoxColor;
  106158. private _defaultUtilityLayer;
  106159. private _defaultKeepDepthUtilityLayer;
  106160. /**
  106161. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106162. */
  106163. boundingBoxDragBehavior: SixDofDragBehavior;
  106164. /**
  106165. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106166. */
  106167. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106168. /**
  106169. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106170. */
  106171. usePointerToAttachGizmos: boolean;
  106172. /**
  106173. * Utility layer that the bounding box gizmo belongs to
  106174. */
  106175. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106176. /**
  106177. * Utility layer that all gizmos besides bounding box belong to
  106178. */
  106179. readonly utilityLayer: UtilityLayerRenderer;
  106180. /**
  106181. * Instatiates a gizmo manager
  106182. * @param scene the scene to overlay the gizmos on top of
  106183. */
  106184. constructor(scene: Scene);
  106185. /**
  106186. * Attaches a set of gizmos to the specified mesh
  106187. * @param mesh The mesh the gizmo's should be attached to
  106188. */
  106189. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106190. /**
  106191. * If the position gizmo is enabled
  106192. */
  106193. positionGizmoEnabled: boolean;
  106194. /**
  106195. * If the rotation gizmo is enabled
  106196. */
  106197. rotationGizmoEnabled: boolean;
  106198. /**
  106199. * If the scale gizmo is enabled
  106200. */
  106201. scaleGizmoEnabled: boolean;
  106202. /**
  106203. * If the boundingBox gizmo is enabled
  106204. */
  106205. boundingBoxGizmoEnabled: boolean;
  106206. /**
  106207. * Disposes of the gizmo manager
  106208. */
  106209. dispose(): void;
  106210. }
  106211. }
  106212. declare module BABYLON {
  106213. /**
  106214. * A directional light is defined by a direction (what a surprise!).
  106215. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106216. * 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.
  106217. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106218. */
  106219. export class DirectionalLight extends ShadowLight {
  106220. private _shadowFrustumSize;
  106221. /**
  106222. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106223. */
  106224. /**
  106225. * Specifies a fix frustum size for the shadow generation.
  106226. */
  106227. shadowFrustumSize: number;
  106228. private _shadowOrthoScale;
  106229. /**
  106230. * Gets the shadow projection scale against the optimal computed one.
  106231. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106232. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106233. */
  106234. /**
  106235. * Sets the shadow projection scale against the optimal computed one.
  106236. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106237. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106238. */
  106239. shadowOrthoScale: number;
  106240. /**
  106241. * Automatically compute the projection matrix to best fit (including all the casters)
  106242. * on each frame.
  106243. */
  106244. autoUpdateExtends: boolean;
  106245. private _orthoLeft;
  106246. private _orthoRight;
  106247. private _orthoTop;
  106248. private _orthoBottom;
  106249. /**
  106250. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106251. * The directional light is emitted from everywhere in the given direction.
  106252. * It can cast shadows.
  106253. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106254. * @param name The friendly name of the light
  106255. * @param direction The direction of the light
  106256. * @param scene The scene the light belongs to
  106257. */
  106258. constructor(name: string, direction: Vector3, scene: Scene);
  106259. /**
  106260. * Returns the string "DirectionalLight".
  106261. * @return The class name
  106262. */
  106263. getClassName(): string;
  106264. /**
  106265. * Returns the integer 1.
  106266. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106267. */
  106268. getTypeID(): number;
  106269. /**
  106270. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106271. * Returns the DirectionalLight Shadow projection matrix.
  106272. */
  106273. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106274. /**
  106275. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106276. * Returns the DirectionalLight Shadow projection matrix.
  106277. */
  106278. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106279. /**
  106280. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106281. * Returns the DirectionalLight Shadow projection matrix.
  106282. */
  106283. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106284. protected _buildUniformLayout(): void;
  106285. /**
  106286. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106287. * @param effect The effect to update
  106288. * @param lightIndex The index of the light in the effect to update
  106289. * @returns The directional light
  106290. */
  106291. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106292. /**
  106293. * Gets the minZ used for shadow according to both the scene and the light.
  106294. *
  106295. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106296. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106297. * @param activeCamera The camera we are returning the min for
  106298. * @returns the depth min z
  106299. */
  106300. getDepthMinZ(activeCamera: Camera): number;
  106301. /**
  106302. * Gets the maxZ used for shadow according to both the scene and the light.
  106303. *
  106304. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106305. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106306. * @param activeCamera The camera we are returning the max for
  106307. * @returns the depth max z
  106308. */
  106309. getDepthMaxZ(activeCamera: Camera): number;
  106310. /**
  106311. * Prepares the list of defines specific to the light type.
  106312. * @param defines the list of defines
  106313. * @param lightIndex defines the index of the light for the effect
  106314. */
  106315. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106316. }
  106317. }
  106318. declare module BABYLON {
  106319. /**
  106320. * Class containing static functions to help procedurally build meshes
  106321. */
  106322. export class HemisphereBuilder {
  106323. /**
  106324. * Creates a hemisphere mesh
  106325. * @param name defines the name of the mesh
  106326. * @param options defines the options used to create the mesh
  106327. * @param scene defines the hosting scene
  106328. * @returns the hemisphere mesh
  106329. */
  106330. static CreateHemisphere(name: string, options: {
  106331. segments?: number;
  106332. diameter?: number;
  106333. sideOrientation?: number;
  106334. }, scene: any): Mesh;
  106335. }
  106336. }
  106337. declare module BABYLON {
  106338. /**
  106339. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106340. * These values define a cone of light starting from the position, emitting toward the direction.
  106341. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106342. * and the exponent defines the speed of the decay of the light with distance (reach).
  106343. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106344. */
  106345. export class SpotLight extends ShadowLight {
  106346. private _angle;
  106347. private _innerAngle;
  106348. private _cosHalfAngle;
  106349. private _lightAngleScale;
  106350. private _lightAngleOffset;
  106351. /**
  106352. * Gets the cone angle of the spot light in Radians.
  106353. */
  106354. /**
  106355. * Sets the cone angle of the spot light in Radians.
  106356. */
  106357. angle: number;
  106358. /**
  106359. * Only used in gltf falloff mode, this defines the angle where
  106360. * the directional falloff will start before cutting at angle which could be seen
  106361. * as outer angle.
  106362. */
  106363. /**
  106364. * Only used in gltf falloff mode, this defines the angle where
  106365. * the directional falloff will start before cutting at angle which could be seen
  106366. * as outer angle.
  106367. */
  106368. innerAngle: number;
  106369. private _shadowAngleScale;
  106370. /**
  106371. * Allows scaling the angle of the light for shadow generation only.
  106372. */
  106373. /**
  106374. * Allows scaling the angle of the light for shadow generation only.
  106375. */
  106376. shadowAngleScale: number;
  106377. /**
  106378. * The light decay speed with the distance from the emission spot.
  106379. */
  106380. exponent: number;
  106381. private _projectionTextureMatrix;
  106382. /**
  106383. * Allows reading the projecton texture
  106384. */
  106385. readonly projectionTextureMatrix: Matrix;
  106386. protected _projectionTextureLightNear: number;
  106387. /**
  106388. * Gets the near clip of the Spotlight for texture projection.
  106389. */
  106390. /**
  106391. * Sets the near clip of the Spotlight for texture projection.
  106392. */
  106393. projectionTextureLightNear: number;
  106394. protected _projectionTextureLightFar: number;
  106395. /**
  106396. * Gets the far clip of the Spotlight for texture projection.
  106397. */
  106398. /**
  106399. * Sets the far clip of the Spotlight for texture projection.
  106400. */
  106401. projectionTextureLightFar: number;
  106402. protected _projectionTextureUpDirection: Vector3;
  106403. /**
  106404. * Gets the Up vector of the Spotlight for texture projection.
  106405. */
  106406. /**
  106407. * Sets the Up vector of the Spotlight for texture projection.
  106408. */
  106409. projectionTextureUpDirection: Vector3;
  106410. private _projectionTexture;
  106411. /**
  106412. * Gets the projection texture of the light.
  106413. */
  106414. /**
  106415. * Sets the projection texture of the light.
  106416. */
  106417. projectionTexture: Nullable<BaseTexture>;
  106418. private _projectionTextureViewLightDirty;
  106419. private _projectionTextureProjectionLightDirty;
  106420. private _projectionTextureDirty;
  106421. private _projectionTextureViewTargetVector;
  106422. private _projectionTextureViewLightMatrix;
  106423. private _projectionTextureProjectionLightMatrix;
  106424. private _projectionTextureScalingMatrix;
  106425. /**
  106426. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106427. * It can cast shadows.
  106428. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106429. * @param name The light friendly name
  106430. * @param position The position of the spot light in the scene
  106431. * @param direction The direction of the light in the scene
  106432. * @param angle The cone angle of the light in Radians
  106433. * @param exponent The light decay speed with the distance from the emission spot
  106434. * @param scene The scene the lights belongs to
  106435. */
  106436. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106437. /**
  106438. * Returns the string "SpotLight".
  106439. * @returns the class name
  106440. */
  106441. getClassName(): string;
  106442. /**
  106443. * Returns the integer 2.
  106444. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106445. */
  106446. getTypeID(): number;
  106447. /**
  106448. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106449. */
  106450. protected _setDirection(value: Vector3): void;
  106451. /**
  106452. * Overrides the position setter to recompute the projection texture view light Matrix.
  106453. */
  106454. protected _setPosition(value: Vector3): void;
  106455. /**
  106456. * 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.
  106457. * Returns the SpotLight.
  106458. */
  106459. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106460. protected _computeProjectionTextureViewLightMatrix(): void;
  106461. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106462. /**
  106463. * Main function for light texture projection matrix computing.
  106464. */
  106465. protected _computeProjectionTextureMatrix(): void;
  106466. protected _buildUniformLayout(): void;
  106467. private _computeAngleValues;
  106468. /**
  106469. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106470. * @param effect The effect to update
  106471. * @param lightIndex The index of the light in the effect to update
  106472. * @returns The spot light
  106473. */
  106474. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106475. /**
  106476. * Disposes the light and the associated resources.
  106477. */
  106478. dispose(): void;
  106479. /**
  106480. * Prepares the list of defines specific to the light type.
  106481. * @param defines the list of defines
  106482. * @param lightIndex defines the index of the light for the effect
  106483. */
  106484. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106485. }
  106486. }
  106487. declare module BABYLON {
  106488. /**
  106489. * Gizmo that enables viewing a light
  106490. */
  106491. export class LightGizmo extends Gizmo {
  106492. private _lightMesh;
  106493. private _material;
  106494. private cachedPosition;
  106495. private cachedForward;
  106496. /**
  106497. * Creates a LightGizmo
  106498. * @param gizmoLayer The utility layer the gizmo will be added to
  106499. */
  106500. constructor(gizmoLayer?: UtilityLayerRenderer);
  106501. private _light;
  106502. /**
  106503. * The light that the gizmo is attached to
  106504. */
  106505. light: Nullable<Light>;
  106506. /**
  106507. * @hidden
  106508. * Updates the gizmo to match the attached mesh's position/rotation
  106509. */
  106510. protected _update(): void;
  106511. private static _Scale;
  106512. /**
  106513. * Creates the lines for a light mesh
  106514. */
  106515. private static _createLightLines;
  106516. /**
  106517. * Disposes of the light gizmo
  106518. */
  106519. dispose(): void;
  106520. private static _CreateHemisphericLightMesh;
  106521. private static _CreatePointLightMesh;
  106522. private static _CreateSpotLightMesh;
  106523. private static _CreateDirectionalLightMesh;
  106524. }
  106525. }
  106526. declare module BABYLON {
  106527. /** @hidden */
  106528. export var backgroundFragmentDeclaration: {
  106529. name: string;
  106530. shader: string;
  106531. };
  106532. }
  106533. declare module BABYLON {
  106534. /** @hidden */
  106535. export var backgroundUboDeclaration: {
  106536. name: string;
  106537. shader: string;
  106538. };
  106539. }
  106540. declare module BABYLON {
  106541. /** @hidden */
  106542. export var backgroundPixelShader: {
  106543. name: string;
  106544. shader: string;
  106545. };
  106546. }
  106547. declare module BABYLON {
  106548. /** @hidden */
  106549. export var backgroundVertexDeclaration: {
  106550. name: string;
  106551. shader: string;
  106552. };
  106553. }
  106554. declare module BABYLON {
  106555. /** @hidden */
  106556. export var backgroundVertexShader: {
  106557. name: string;
  106558. shader: string;
  106559. };
  106560. }
  106561. declare module BABYLON {
  106562. /**
  106563. * Background material used to create an efficient environement around your scene.
  106564. */
  106565. export class BackgroundMaterial extends PushMaterial {
  106566. /**
  106567. * Standard reflectance value at parallel view angle.
  106568. */
  106569. static StandardReflectance0: number;
  106570. /**
  106571. * Standard reflectance value at grazing angle.
  106572. */
  106573. static StandardReflectance90: number;
  106574. protected _primaryColor: Color3;
  106575. /**
  106576. * Key light Color (multiply against the environement texture)
  106577. */
  106578. primaryColor: Color3;
  106579. protected __perceptualColor: Nullable<Color3>;
  106580. /**
  106581. * Experimental Internal Use Only.
  106582. *
  106583. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106584. * This acts as a helper to set the primary color to a more "human friendly" value.
  106585. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106586. * output color as close as possible from the chosen value.
  106587. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106588. * part of lighting setup.)
  106589. */
  106590. _perceptualColor: Nullable<Color3>;
  106591. protected _primaryColorShadowLevel: float;
  106592. /**
  106593. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106594. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106595. */
  106596. primaryColorShadowLevel: float;
  106597. protected _primaryColorHighlightLevel: float;
  106598. /**
  106599. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106600. * The primary color is used at the level chosen to define what the white area would look.
  106601. */
  106602. primaryColorHighlightLevel: float;
  106603. protected _reflectionTexture: Nullable<BaseTexture>;
  106604. /**
  106605. * Reflection Texture used in the material.
  106606. * Should be author in a specific way for the best result (refer to the documentation).
  106607. */
  106608. reflectionTexture: Nullable<BaseTexture>;
  106609. protected _reflectionBlur: float;
  106610. /**
  106611. * Reflection Texture level of blur.
  106612. *
  106613. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106614. * texture twice.
  106615. */
  106616. reflectionBlur: float;
  106617. protected _diffuseTexture: Nullable<BaseTexture>;
  106618. /**
  106619. * Diffuse Texture used in the material.
  106620. * Should be author in a specific way for the best result (refer to the documentation).
  106621. */
  106622. diffuseTexture: Nullable<BaseTexture>;
  106623. protected _shadowLights: Nullable<IShadowLight[]>;
  106624. /**
  106625. * Specify the list of lights casting shadow on the material.
  106626. * All scene shadow lights will be included if null.
  106627. */
  106628. shadowLights: Nullable<IShadowLight[]>;
  106629. protected _shadowLevel: float;
  106630. /**
  106631. * Helps adjusting the shadow to a softer level if required.
  106632. * 0 means black shadows and 1 means no shadows.
  106633. */
  106634. shadowLevel: float;
  106635. protected _sceneCenter: Vector3;
  106636. /**
  106637. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106638. * It is usually zero but might be interesting to modify according to your setup.
  106639. */
  106640. sceneCenter: Vector3;
  106641. protected _opacityFresnel: boolean;
  106642. /**
  106643. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106644. * This helps ensuring a nice transition when the camera goes under the ground.
  106645. */
  106646. opacityFresnel: boolean;
  106647. protected _reflectionFresnel: boolean;
  106648. /**
  106649. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106650. * This helps adding a mirror texture on the ground.
  106651. */
  106652. reflectionFresnel: boolean;
  106653. protected _reflectionFalloffDistance: number;
  106654. /**
  106655. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106656. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106657. */
  106658. reflectionFalloffDistance: number;
  106659. protected _reflectionAmount: number;
  106660. /**
  106661. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106662. */
  106663. reflectionAmount: number;
  106664. protected _reflectionReflectance0: number;
  106665. /**
  106666. * This specifies the weight of the reflection at grazing angle.
  106667. */
  106668. reflectionReflectance0: number;
  106669. protected _reflectionReflectance90: number;
  106670. /**
  106671. * This specifies the weight of the reflection at a perpendicular point of view.
  106672. */
  106673. reflectionReflectance90: number;
  106674. /**
  106675. * Sets the reflection reflectance fresnel values according to the default standard
  106676. * empirically know to work well :-)
  106677. */
  106678. reflectionStandardFresnelWeight: number;
  106679. protected _useRGBColor: boolean;
  106680. /**
  106681. * Helps to directly use the maps channels instead of their level.
  106682. */
  106683. useRGBColor: boolean;
  106684. protected _enableNoise: boolean;
  106685. /**
  106686. * This helps reducing the banding effect that could occur on the background.
  106687. */
  106688. enableNoise: boolean;
  106689. /**
  106690. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106691. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106692. * Recommended to be keep at 1.0 except for special cases.
  106693. */
  106694. fovMultiplier: number;
  106695. private _fovMultiplier;
  106696. /**
  106697. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106698. */
  106699. useEquirectangularFOV: boolean;
  106700. private _maxSimultaneousLights;
  106701. /**
  106702. * Number of Simultaneous lights allowed on the material.
  106703. */
  106704. maxSimultaneousLights: int;
  106705. /**
  106706. * Default configuration related to image processing available in the Background Material.
  106707. */
  106708. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106709. /**
  106710. * Keep track of the image processing observer to allow dispose and replace.
  106711. */
  106712. private _imageProcessingObserver;
  106713. /**
  106714. * Attaches a new image processing configuration to the PBR Material.
  106715. * @param configuration (if null the scene configuration will be use)
  106716. */
  106717. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106718. /**
  106719. * Gets the image processing configuration used either in this material.
  106720. */
  106721. /**
  106722. * Sets the Default image processing configuration used either in the this material.
  106723. *
  106724. * If sets to null, the scene one is in use.
  106725. */
  106726. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106727. /**
  106728. * Gets wether the color curves effect is enabled.
  106729. */
  106730. /**
  106731. * Sets wether the color curves effect is enabled.
  106732. */
  106733. cameraColorCurvesEnabled: boolean;
  106734. /**
  106735. * Gets wether the color grading effect is enabled.
  106736. */
  106737. /**
  106738. * Gets wether the color grading effect is enabled.
  106739. */
  106740. cameraColorGradingEnabled: boolean;
  106741. /**
  106742. * Gets wether tonemapping is enabled or not.
  106743. */
  106744. /**
  106745. * Sets wether tonemapping is enabled or not
  106746. */
  106747. cameraToneMappingEnabled: boolean;
  106748. /**
  106749. * The camera exposure used on this material.
  106750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106751. * This corresponds to a photographic exposure.
  106752. */
  106753. /**
  106754. * The camera exposure used on this material.
  106755. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106756. * This corresponds to a photographic exposure.
  106757. */
  106758. cameraExposure: float;
  106759. /**
  106760. * Gets The camera contrast used on this material.
  106761. */
  106762. /**
  106763. * Sets The camera contrast used on this material.
  106764. */
  106765. cameraContrast: float;
  106766. /**
  106767. * Gets the Color Grading 2D Lookup Texture.
  106768. */
  106769. /**
  106770. * Sets the Color Grading 2D Lookup Texture.
  106771. */
  106772. cameraColorGradingTexture: Nullable<BaseTexture>;
  106773. /**
  106774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106776. * 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;
  106777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106778. */
  106779. /**
  106780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106782. * 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;
  106783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106784. */
  106785. cameraColorCurves: Nullable<ColorCurves>;
  106786. /**
  106787. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106788. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106789. */
  106790. switchToBGR: boolean;
  106791. private _renderTargets;
  106792. private _reflectionControls;
  106793. private _white;
  106794. private _primaryShadowColor;
  106795. private _primaryHighlightColor;
  106796. /**
  106797. * Instantiates a Background Material in the given scene
  106798. * @param name The friendly name of the material
  106799. * @param scene The scene to add the material to
  106800. */
  106801. constructor(name: string, scene: Scene);
  106802. /**
  106803. * Gets a boolean indicating that current material needs to register RTT
  106804. */
  106805. readonly hasRenderTargetTextures: boolean;
  106806. /**
  106807. * The entire material has been created in order to prevent overdraw.
  106808. * @returns false
  106809. */
  106810. needAlphaTesting(): boolean;
  106811. /**
  106812. * The entire material has been created in order to prevent overdraw.
  106813. * @returns true if blending is enable
  106814. */
  106815. needAlphaBlending(): boolean;
  106816. /**
  106817. * Checks wether the material is ready to be rendered for a given mesh.
  106818. * @param mesh The mesh to render
  106819. * @param subMesh The submesh to check against
  106820. * @param useInstances Specify wether or not the material is used with instances
  106821. * @returns true if all the dependencies are ready (Textures, Effects...)
  106822. */
  106823. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106824. /**
  106825. * Compute the primary color according to the chosen perceptual color.
  106826. */
  106827. private _computePrimaryColorFromPerceptualColor;
  106828. /**
  106829. * Compute the highlights and shadow colors according to their chosen levels.
  106830. */
  106831. private _computePrimaryColors;
  106832. /**
  106833. * Build the uniform buffer used in the material.
  106834. */
  106835. buildUniformLayout(): void;
  106836. /**
  106837. * Unbind the material.
  106838. */
  106839. unbind(): void;
  106840. /**
  106841. * Bind only the world matrix to the material.
  106842. * @param world The world matrix to bind.
  106843. */
  106844. bindOnlyWorldMatrix(world: Matrix): void;
  106845. /**
  106846. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106847. * @param world The world matrix to bind.
  106848. * @param subMesh The submesh to bind for.
  106849. */
  106850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106851. /**
  106852. * Dispose the material.
  106853. * @param forceDisposeEffect Force disposal of the associated effect.
  106854. * @param forceDisposeTextures Force disposal of the associated textures.
  106855. */
  106856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106857. /**
  106858. * Clones the material.
  106859. * @param name The cloned name.
  106860. * @returns The cloned material.
  106861. */
  106862. clone(name: string): BackgroundMaterial;
  106863. /**
  106864. * Serializes the current material to its JSON representation.
  106865. * @returns The JSON representation.
  106866. */
  106867. serialize(): any;
  106868. /**
  106869. * Gets the class name of the material
  106870. * @returns "BackgroundMaterial"
  106871. */
  106872. getClassName(): string;
  106873. /**
  106874. * Parse a JSON input to create back a background material.
  106875. * @param source The JSON data to parse
  106876. * @param scene The scene to create the parsed material in
  106877. * @param rootUrl The root url of the assets the material depends upon
  106878. * @returns the instantiated BackgroundMaterial.
  106879. */
  106880. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106881. }
  106882. }
  106883. declare module BABYLON {
  106884. /**
  106885. * Represents the different options available during the creation of
  106886. * a Environment helper.
  106887. *
  106888. * This can control the default ground, skybox and image processing setup of your scene.
  106889. */
  106890. export interface IEnvironmentHelperOptions {
  106891. /**
  106892. * Specifies wether or not to create a ground.
  106893. * True by default.
  106894. */
  106895. createGround: boolean;
  106896. /**
  106897. * Specifies the ground size.
  106898. * 15 by default.
  106899. */
  106900. groundSize: number;
  106901. /**
  106902. * The texture used on the ground for the main color.
  106903. * Comes from the BabylonJS CDN by default.
  106904. *
  106905. * Remarks: Can be either a texture or a url.
  106906. */
  106907. groundTexture: string | BaseTexture;
  106908. /**
  106909. * The color mixed in the ground texture by default.
  106910. * BabylonJS clearColor by default.
  106911. */
  106912. groundColor: Color3;
  106913. /**
  106914. * Specifies the ground opacity.
  106915. * 1 by default.
  106916. */
  106917. groundOpacity: number;
  106918. /**
  106919. * Enables the ground to receive shadows.
  106920. * True by default.
  106921. */
  106922. enableGroundShadow: boolean;
  106923. /**
  106924. * Helps preventing the shadow to be fully black on the ground.
  106925. * 0.5 by default.
  106926. */
  106927. groundShadowLevel: number;
  106928. /**
  106929. * Creates a mirror texture attach to the ground.
  106930. * false by default.
  106931. */
  106932. enableGroundMirror: boolean;
  106933. /**
  106934. * Specifies the ground mirror size ratio.
  106935. * 0.3 by default as the default kernel is 64.
  106936. */
  106937. groundMirrorSizeRatio: number;
  106938. /**
  106939. * Specifies the ground mirror blur kernel size.
  106940. * 64 by default.
  106941. */
  106942. groundMirrorBlurKernel: number;
  106943. /**
  106944. * Specifies the ground mirror visibility amount.
  106945. * 1 by default
  106946. */
  106947. groundMirrorAmount: number;
  106948. /**
  106949. * Specifies the ground mirror reflectance weight.
  106950. * This uses the standard weight of the background material to setup the fresnel effect
  106951. * of the mirror.
  106952. * 1 by default.
  106953. */
  106954. groundMirrorFresnelWeight: number;
  106955. /**
  106956. * Specifies the ground mirror Falloff distance.
  106957. * This can helps reducing the size of the reflection.
  106958. * 0 by Default.
  106959. */
  106960. groundMirrorFallOffDistance: number;
  106961. /**
  106962. * Specifies the ground mirror texture type.
  106963. * Unsigned Int by Default.
  106964. */
  106965. groundMirrorTextureType: number;
  106966. /**
  106967. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106968. * the shown objects.
  106969. */
  106970. groundYBias: number;
  106971. /**
  106972. * Specifies wether or not to create a skybox.
  106973. * True by default.
  106974. */
  106975. createSkybox: boolean;
  106976. /**
  106977. * Specifies the skybox size.
  106978. * 20 by default.
  106979. */
  106980. skyboxSize: number;
  106981. /**
  106982. * The texture used on the skybox for the main color.
  106983. * Comes from the BabylonJS CDN by default.
  106984. *
  106985. * Remarks: Can be either a texture or a url.
  106986. */
  106987. skyboxTexture: string | BaseTexture;
  106988. /**
  106989. * The color mixed in the skybox texture by default.
  106990. * BabylonJS clearColor by default.
  106991. */
  106992. skyboxColor: Color3;
  106993. /**
  106994. * The background rotation around the Y axis of the scene.
  106995. * This helps aligning the key lights of your scene with the background.
  106996. * 0 by default.
  106997. */
  106998. backgroundYRotation: number;
  106999. /**
  107000. * Compute automatically the size of the elements to best fit with the scene.
  107001. */
  107002. sizeAuto: boolean;
  107003. /**
  107004. * Default position of the rootMesh if autoSize is not true.
  107005. */
  107006. rootPosition: Vector3;
  107007. /**
  107008. * Sets up the image processing in the scene.
  107009. * true by default.
  107010. */
  107011. setupImageProcessing: boolean;
  107012. /**
  107013. * The texture used as your environment texture in the scene.
  107014. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  107015. *
  107016. * Remarks: Can be either a texture or a url.
  107017. */
  107018. environmentTexture: string | BaseTexture;
  107019. /**
  107020. * The value of the exposure to apply to the scene.
  107021. * 0.6 by default if setupImageProcessing is true.
  107022. */
  107023. cameraExposure: number;
  107024. /**
  107025. * The value of the contrast to apply to the scene.
  107026. * 1.6 by default if setupImageProcessing is true.
  107027. */
  107028. cameraContrast: number;
  107029. /**
  107030. * Specifies wether or not tonemapping should be enabled in the scene.
  107031. * true by default if setupImageProcessing is true.
  107032. */
  107033. toneMappingEnabled: boolean;
  107034. }
  107035. /**
  107036. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  107037. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  107038. * It also helps with the default setup of your imageProcessing configuration.
  107039. */
  107040. export class EnvironmentHelper {
  107041. /**
  107042. * Default ground texture URL.
  107043. */
  107044. private static _groundTextureCDNUrl;
  107045. /**
  107046. * Default skybox texture URL.
  107047. */
  107048. private static _skyboxTextureCDNUrl;
  107049. /**
  107050. * Default environment texture URL.
  107051. */
  107052. private static _environmentTextureCDNUrl;
  107053. /**
  107054. * Creates the default options for the helper.
  107055. */
  107056. private static _getDefaultOptions;
  107057. private _rootMesh;
  107058. /**
  107059. * Gets the root mesh created by the helper.
  107060. */
  107061. readonly rootMesh: Mesh;
  107062. private _skybox;
  107063. /**
  107064. * Gets the skybox created by the helper.
  107065. */
  107066. readonly skybox: Nullable<Mesh>;
  107067. private _skyboxTexture;
  107068. /**
  107069. * Gets the skybox texture created by the helper.
  107070. */
  107071. readonly skyboxTexture: Nullable<BaseTexture>;
  107072. private _skyboxMaterial;
  107073. /**
  107074. * Gets the skybox material created by the helper.
  107075. */
  107076. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  107077. private _ground;
  107078. /**
  107079. * Gets the ground mesh created by the helper.
  107080. */
  107081. readonly ground: Nullable<Mesh>;
  107082. private _groundTexture;
  107083. /**
  107084. * Gets the ground texture created by the helper.
  107085. */
  107086. readonly groundTexture: Nullable<BaseTexture>;
  107087. private _groundMirror;
  107088. /**
  107089. * Gets the ground mirror created by the helper.
  107090. */
  107091. readonly groundMirror: Nullable<MirrorTexture>;
  107092. /**
  107093. * Gets the ground mirror render list to helps pushing the meshes
  107094. * you wish in the ground reflection.
  107095. */
  107096. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107097. private _groundMaterial;
  107098. /**
  107099. * Gets the ground material created by the helper.
  107100. */
  107101. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107102. /**
  107103. * Stores the creation options.
  107104. */
  107105. private readonly _scene;
  107106. private _options;
  107107. /**
  107108. * This observable will be notified with any error during the creation of the environment,
  107109. * mainly texture creation errors.
  107110. */
  107111. onErrorObservable: Observable<{
  107112. message?: string;
  107113. exception?: any;
  107114. }>;
  107115. /**
  107116. * constructor
  107117. * @param options Defines the options we want to customize the helper
  107118. * @param scene The scene to add the material to
  107119. */
  107120. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107121. /**
  107122. * Updates the background according to the new options
  107123. * @param options
  107124. */
  107125. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107126. /**
  107127. * Sets the primary color of all the available elements.
  107128. * @param color the main color to affect to the ground and the background
  107129. */
  107130. setMainColor(color: Color3): void;
  107131. /**
  107132. * Setup the image processing according to the specified options.
  107133. */
  107134. private _setupImageProcessing;
  107135. /**
  107136. * Setup the environment texture according to the specified options.
  107137. */
  107138. private _setupEnvironmentTexture;
  107139. /**
  107140. * Setup the background according to the specified options.
  107141. */
  107142. private _setupBackground;
  107143. /**
  107144. * Get the scene sizes according to the setup.
  107145. */
  107146. private _getSceneSize;
  107147. /**
  107148. * Setup the ground according to the specified options.
  107149. */
  107150. private _setupGround;
  107151. /**
  107152. * Setup the ground material according to the specified options.
  107153. */
  107154. private _setupGroundMaterial;
  107155. /**
  107156. * Setup the ground diffuse texture according to the specified options.
  107157. */
  107158. private _setupGroundDiffuseTexture;
  107159. /**
  107160. * Setup the ground mirror texture according to the specified options.
  107161. */
  107162. private _setupGroundMirrorTexture;
  107163. /**
  107164. * Setup the ground to receive the mirror texture.
  107165. */
  107166. private _setupMirrorInGroundMaterial;
  107167. /**
  107168. * Setup the skybox according to the specified options.
  107169. */
  107170. private _setupSkybox;
  107171. /**
  107172. * Setup the skybox material according to the specified options.
  107173. */
  107174. private _setupSkyboxMaterial;
  107175. /**
  107176. * Setup the skybox reflection texture according to the specified options.
  107177. */
  107178. private _setupSkyboxReflectionTexture;
  107179. private _errorHandler;
  107180. /**
  107181. * Dispose all the elements created by the Helper.
  107182. */
  107183. dispose(): void;
  107184. }
  107185. }
  107186. declare module BABYLON {
  107187. /**
  107188. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107189. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107190. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107191. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107192. */
  107193. export class PhotoDome extends TransformNode {
  107194. /**
  107195. * Define the image as a Monoscopic panoramic 360 image.
  107196. */
  107197. static readonly MODE_MONOSCOPIC: number;
  107198. /**
  107199. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107200. */
  107201. static readonly MODE_TOPBOTTOM: number;
  107202. /**
  107203. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107204. */
  107205. static readonly MODE_SIDEBYSIDE: number;
  107206. private _useDirectMapping;
  107207. /**
  107208. * The texture being displayed on the sphere
  107209. */
  107210. protected _photoTexture: Texture;
  107211. /**
  107212. * Gets or sets the texture being displayed on the sphere
  107213. */
  107214. photoTexture: Texture;
  107215. /**
  107216. * Observable raised when an error occured while loading the 360 image
  107217. */
  107218. onLoadErrorObservable: Observable<string>;
  107219. /**
  107220. * The skybox material
  107221. */
  107222. protected _material: BackgroundMaterial;
  107223. /**
  107224. * The surface used for the skybox
  107225. */
  107226. protected _mesh: Mesh;
  107227. /**
  107228. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107229. * Also see the options.resolution property.
  107230. */
  107231. fovMultiplier: number;
  107232. private _imageMode;
  107233. /**
  107234. * Gets or set the current video mode for the video. It can be:
  107235. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107236. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107237. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107238. */
  107239. imageMode: number;
  107240. /**
  107241. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107242. * @param name Element's name, child elements will append suffixes for their own names.
  107243. * @param urlsOfPhoto defines the url of the photo to display
  107244. * @param options defines an object containing optional or exposed sub element properties
  107245. * @param onError defines a callback called when an error occured while loading the texture
  107246. */
  107247. constructor(name: string, urlOfPhoto: string, options: {
  107248. resolution?: number;
  107249. size?: number;
  107250. useDirectMapping?: boolean;
  107251. faceForward?: boolean;
  107252. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107253. private _onBeforeCameraRenderObserver;
  107254. private _changeImageMode;
  107255. /**
  107256. * Releases resources associated with this node.
  107257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107259. */
  107260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107261. }
  107262. }
  107263. declare module BABYLON {
  107264. /** @hidden */
  107265. export var rgbdDecodePixelShader: {
  107266. name: string;
  107267. shader: string;
  107268. };
  107269. }
  107270. declare module BABYLON {
  107271. /**
  107272. * Class used to host texture specific utilities
  107273. */
  107274. export class BRDFTextureTools {
  107275. /**
  107276. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107277. * @param texture the texture to expand.
  107278. */
  107279. private static _ExpandDefaultBRDFTexture;
  107280. /**
  107281. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107282. * @param scene defines the hosting scene
  107283. * @returns the environment BRDF texture
  107284. */
  107285. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107286. private static _environmentBRDFBase64Texture;
  107287. }
  107288. }
  107289. declare module BABYLON {
  107290. /**
  107291. * @hidden
  107292. */
  107293. export interface IMaterialClearCoatDefines {
  107294. CLEARCOAT: boolean;
  107295. CLEARCOAT_DEFAULTIOR: boolean;
  107296. CLEARCOAT_TEXTURE: boolean;
  107297. CLEARCOAT_TEXTUREDIRECTUV: number;
  107298. CLEARCOAT_BUMP: boolean;
  107299. CLEARCOAT_BUMPDIRECTUV: number;
  107300. CLEARCOAT_TINT: boolean;
  107301. CLEARCOAT_TINT_TEXTURE: boolean;
  107302. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107303. /** @hidden */
  107304. _areTexturesDirty: boolean;
  107305. }
  107306. /**
  107307. * Define the code related to the clear coat parameters of the pbr material.
  107308. */
  107309. export class PBRClearCoatConfiguration {
  107310. /**
  107311. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107312. * The default fits with a polyurethane material.
  107313. */
  107314. private static readonly _DefaultIndexOfRefraction;
  107315. private _isEnabled;
  107316. /**
  107317. * Defines if the clear coat is enabled in the material.
  107318. */
  107319. isEnabled: boolean;
  107320. /**
  107321. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107322. */
  107323. intensity: number;
  107324. /**
  107325. * Defines the clear coat layer roughness.
  107326. */
  107327. roughness: number;
  107328. private _indexOfRefraction;
  107329. /**
  107330. * Defines the index of refraction of the clear coat.
  107331. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107332. * The default fits with a polyurethane material.
  107333. * Changing the default value is more performance intensive.
  107334. */
  107335. indexOfRefraction: number;
  107336. private _texture;
  107337. /**
  107338. * Stores the clear coat values in a texture.
  107339. */
  107340. texture: Nullable<BaseTexture>;
  107341. private _bumpTexture;
  107342. /**
  107343. * Define the clear coat specific bump texture.
  107344. */
  107345. bumpTexture: Nullable<BaseTexture>;
  107346. private _isTintEnabled;
  107347. /**
  107348. * Defines if the clear coat tint is enabled in the material.
  107349. */
  107350. isTintEnabled: boolean;
  107351. /**
  107352. * Defines the clear coat tint of the material.
  107353. * This is only use if tint is enabled
  107354. */
  107355. tintColor: Color3;
  107356. /**
  107357. * Defines the distance at which the tint color should be found in the
  107358. * clear coat media.
  107359. * This is only use if tint is enabled
  107360. */
  107361. tintColorAtDistance: number;
  107362. /**
  107363. * Defines the clear coat layer thickness.
  107364. * This is only use if tint is enabled
  107365. */
  107366. tintThickness: number;
  107367. private _tintTexture;
  107368. /**
  107369. * Stores the clear tint values in a texture.
  107370. * rgb is tint
  107371. * a is a thickness factor
  107372. */
  107373. tintTexture: Nullable<BaseTexture>;
  107374. /** @hidden */
  107375. private _internalMarkAllSubMeshesAsTexturesDirty;
  107376. /** @hidden */
  107377. _markAllSubMeshesAsTexturesDirty(): void;
  107378. /**
  107379. * Instantiate a new istance of clear coat configuration.
  107380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107381. */
  107382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107383. /**
  107384. * Gets wehter the submesh is ready to be used or not.
  107385. * @param defines the list of "defines" to update.
  107386. * @param scene defines the scene the material belongs to.
  107387. * @param engine defines the engine the material belongs to.
  107388. * @param disableBumpMap defines wether the material disables bump or not.
  107389. * @returns - boolean indicating that the submesh is ready or not.
  107390. */
  107391. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107392. /**
  107393. * Checks to see if a texture is used in the material.
  107394. * @param defines the list of "defines" to update.
  107395. * @param scene defines the scene to the material belongs to.
  107396. */
  107397. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107398. /**
  107399. * Binds the material data.
  107400. * @param uniformBuffer defines the Uniform buffer to fill in.
  107401. * @param scene defines the scene the material belongs to.
  107402. * @param engine defines the engine the material belongs to.
  107403. * @param disableBumpMap defines wether the material disables bump or not.
  107404. * @param isFrozen defines wether the material is frozen or not.
  107405. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107406. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107407. */
  107408. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107409. /**
  107410. * Checks to see if a texture is used in the material.
  107411. * @param texture - Base texture to use.
  107412. * @returns - Boolean specifying if a texture is used in the material.
  107413. */
  107414. hasTexture(texture: BaseTexture): boolean;
  107415. /**
  107416. * Returns an array of the actively used textures.
  107417. * @param activeTextures Array of BaseTextures
  107418. */
  107419. getActiveTextures(activeTextures: BaseTexture[]): void;
  107420. /**
  107421. * Returns the animatable textures.
  107422. * @param animatables Array of animatable textures.
  107423. */
  107424. getAnimatables(animatables: IAnimatable[]): void;
  107425. /**
  107426. * Disposes the resources of the material.
  107427. * @param forceDisposeTextures - Forces the disposal of all textures.
  107428. */
  107429. dispose(forceDisposeTextures?: boolean): void;
  107430. /**
  107431. * Get the current class name of the texture useful for serialization or dynamic coding.
  107432. * @returns "PBRClearCoatConfiguration"
  107433. */
  107434. getClassName(): string;
  107435. /**
  107436. * Add fallbacks to the effect fallbacks list.
  107437. * @param defines defines the Base texture to use.
  107438. * @param fallbacks defines the current fallback list.
  107439. * @param currentRank defines the current fallback rank.
  107440. * @returns the new fallback rank.
  107441. */
  107442. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107443. /**
  107444. * Add the required uniforms to the current list.
  107445. * @param uniforms defines the current uniform list.
  107446. */
  107447. static AddUniforms(uniforms: string[]): void;
  107448. /**
  107449. * Add the required samplers to the current list.
  107450. * @param samplers defines the current sampler list.
  107451. */
  107452. static AddSamplers(samplers: string[]): void;
  107453. /**
  107454. * Add the required uniforms to the current buffer.
  107455. * @param uniformBuffer defines the current uniform buffer.
  107456. */
  107457. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107458. /**
  107459. * Makes a duplicate of the current configuration into another one.
  107460. * @param clearCoatConfiguration define the config where to copy the info
  107461. */
  107462. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107463. /**
  107464. * Serializes this clear coat configuration.
  107465. * @returns - An object with the serialized config.
  107466. */
  107467. serialize(): any;
  107468. /**
  107469. * Parses a anisotropy Configuration from a serialized object.
  107470. * @param source - Serialized object.
  107471. * @param scene Defines the scene we are parsing for
  107472. * @param rootUrl Defines the rootUrl to load from
  107473. */
  107474. parse(source: any, scene: Scene, rootUrl: string): void;
  107475. }
  107476. }
  107477. declare module BABYLON {
  107478. /**
  107479. * @hidden
  107480. */
  107481. export interface IMaterialAnisotropicDefines {
  107482. ANISOTROPIC: boolean;
  107483. ANISOTROPIC_TEXTURE: boolean;
  107484. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107485. MAINUV1: boolean;
  107486. _areTexturesDirty: boolean;
  107487. _needUVs: boolean;
  107488. }
  107489. /**
  107490. * Define the code related to the anisotropic parameters of the pbr material.
  107491. */
  107492. export class PBRAnisotropicConfiguration {
  107493. private _isEnabled;
  107494. /**
  107495. * Defines if the anisotropy is enabled in the material.
  107496. */
  107497. isEnabled: boolean;
  107498. /**
  107499. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107500. */
  107501. intensity: number;
  107502. /**
  107503. * Defines if the effect is along the tangents, bitangents or in between.
  107504. * By default, the effect is "strectching" the highlights along the tangents.
  107505. */
  107506. direction: Vector2;
  107507. private _texture;
  107508. /**
  107509. * Stores the anisotropy values in a texture.
  107510. * rg is direction (like normal from -1 to 1)
  107511. * b is a intensity
  107512. */
  107513. texture: Nullable<BaseTexture>;
  107514. /** @hidden */
  107515. private _internalMarkAllSubMeshesAsTexturesDirty;
  107516. /** @hidden */
  107517. _markAllSubMeshesAsTexturesDirty(): void;
  107518. /**
  107519. * Instantiate a new istance of anisotropy configuration.
  107520. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107521. */
  107522. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107523. /**
  107524. * Specifies that the submesh is ready to be used.
  107525. * @param defines the list of "defines" to update.
  107526. * @param scene defines the scene the material belongs to.
  107527. * @returns - boolean indicating that the submesh is ready or not.
  107528. */
  107529. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107530. /**
  107531. * Checks to see if a texture is used in the material.
  107532. * @param defines the list of "defines" to update.
  107533. * @param mesh the mesh we are preparing the defines for.
  107534. * @param scene defines the scene the material belongs to.
  107535. */
  107536. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107537. /**
  107538. * Binds the material data.
  107539. * @param uniformBuffer defines the Uniform buffer to fill in.
  107540. * @param scene defines the scene the material belongs to.
  107541. * @param isFrozen defines wether the material is frozen or not.
  107542. */
  107543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107544. /**
  107545. * Checks to see if a texture is used in the material.
  107546. * @param texture - Base texture to use.
  107547. * @returns - Boolean specifying if a texture is used in the material.
  107548. */
  107549. hasTexture(texture: BaseTexture): boolean;
  107550. /**
  107551. * Returns an array of the actively used textures.
  107552. * @param activeTextures Array of BaseTextures
  107553. */
  107554. getActiveTextures(activeTextures: BaseTexture[]): void;
  107555. /**
  107556. * Returns the animatable textures.
  107557. * @param animatables Array of animatable textures.
  107558. */
  107559. getAnimatables(animatables: IAnimatable[]): void;
  107560. /**
  107561. * Disposes the resources of the material.
  107562. * @param forceDisposeTextures - Forces the disposal of all textures.
  107563. */
  107564. dispose(forceDisposeTextures?: boolean): void;
  107565. /**
  107566. * Get the current class name of the texture useful for serialization or dynamic coding.
  107567. * @returns "PBRAnisotropicConfiguration"
  107568. */
  107569. getClassName(): string;
  107570. /**
  107571. * Add fallbacks to the effect fallbacks list.
  107572. * @param defines defines the Base texture to use.
  107573. * @param fallbacks defines the current fallback list.
  107574. * @param currentRank defines the current fallback rank.
  107575. * @returns the new fallback rank.
  107576. */
  107577. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107578. /**
  107579. * Add the required uniforms to the current list.
  107580. * @param uniforms defines the current uniform list.
  107581. */
  107582. static AddUniforms(uniforms: string[]): void;
  107583. /**
  107584. * Add the required uniforms to the current buffer.
  107585. * @param uniformBuffer defines the current uniform buffer.
  107586. */
  107587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107588. /**
  107589. * Add the required samplers to the current list.
  107590. * @param samplers defines the current sampler list.
  107591. */
  107592. static AddSamplers(samplers: string[]): void;
  107593. /**
  107594. * Makes a duplicate of the current configuration into another one.
  107595. * @param anisotropicConfiguration define the config where to copy the info
  107596. */
  107597. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107598. /**
  107599. * Serializes this anisotropy configuration.
  107600. * @returns - An object with the serialized config.
  107601. */
  107602. serialize(): any;
  107603. /**
  107604. * Parses a anisotropy Configuration from a serialized object.
  107605. * @param source - Serialized object.
  107606. * @param scene Defines the scene we are parsing for
  107607. * @param rootUrl Defines the rootUrl to load from
  107608. */
  107609. parse(source: any, scene: Scene, rootUrl: string): void;
  107610. }
  107611. }
  107612. declare module BABYLON {
  107613. /**
  107614. * @hidden
  107615. */
  107616. export interface IMaterialBRDFDefines {
  107617. BRDF_V_HEIGHT_CORRELATED: boolean;
  107618. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107619. SPHERICAL_HARMONICS: boolean;
  107620. /** @hidden */
  107621. _areMiscDirty: boolean;
  107622. }
  107623. /**
  107624. * Define the code related to the BRDF parameters of the pbr material.
  107625. */
  107626. export class PBRBRDFConfiguration {
  107627. /**
  107628. * Default value used for the energy conservation.
  107629. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107630. */
  107631. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107632. /**
  107633. * Default value used for the Smith Visibility Height Correlated mode.
  107634. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107635. */
  107636. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107637. /**
  107638. * Default value used for the IBL diffuse part.
  107639. * This can help switching back to the polynomials mode globally which is a tiny bit
  107640. * less GPU intensive at the drawback of a lower quality.
  107641. */
  107642. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107643. private _useEnergyConservation;
  107644. /**
  107645. * Defines if the material uses energy conservation.
  107646. */
  107647. useEnergyConservation: boolean;
  107648. private _useSmithVisibilityHeightCorrelated;
  107649. /**
  107650. * LEGACY Mode set to false
  107651. * Defines if the material uses height smith correlated visibility term.
  107652. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107653. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107654. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107655. * Not relying on height correlated will also disable energy conservation.
  107656. */
  107657. useSmithVisibilityHeightCorrelated: boolean;
  107658. private _useSphericalHarmonics;
  107659. /**
  107660. * LEGACY Mode set to false
  107661. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107662. * diffuse part of the IBL.
  107663. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107664. * to the ground truth.
  107665. */
  107666. useSphericalHarmonics: boolean;
  107667. /** @hidden */
  107668. private _internalMarkAllSubMeshesAsMiscDirty;
  107669. /** @hidden */
  107670. _markAllSubMeshesAsMiscDirty(): void;
  107671. /**
  107672. * Instantiate a new istance of clear coat configuration.
  107673. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107674. */
  107675. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107676. /**
  107677. * Checks to see if a texture is used in the material.
  107678. * @param defines the list of "defines" to update.
  107679. */
  107680. prepareDefines(defines: IMaterialBRDFDefines): void;
  107681. /**
  107682. * Get the current class name of the texture useful for serialization or dynamic coding.
  107683. * @returns "PBRClearCoatConfiguration"
  107684. */
  107685. getClassName(): string;
  107686. /**
  107687. * Makes a duplicate of the current configuration into another one.
  107688. * @param brdfConfiguration define the config where to copy the info
  107689. */
  107690. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107691. /**
  107692. * Serializes this BRDF configuration.
  107693. * @returns - An object with the serialized config.
  107694. */
  107695. serialize(): any;
  107696. /**
  107697. * Parses a anisotropy Configuration from a serialized object.
  107698. * @param source - Serialized object.
  107699. * @param scene Defines the scene we are parsing for
  107700. * @param rootUrl Defines the rootUrl to load from
  107701. */
  107702. parse(source: any, scene: Scene, rootUrl: string): void;
  107703. }
  107704. }
  107705. declare module BABYLON {
  107706. /**
  107707. * @hidden
  107708. */
  107709. export interface IMaterialSheenDefines {
  107710. SHEEN: boolean;
  107711. SHEEN_TEXTURE: boolean;
  107712. SHEEN_TEXTUREDIRECTUV: number;
  107713. SHEEN_LINKWITHALBEDO: boolean;
  107714. /** @hidden */
  107715. _areTexturesDirty: boolean;
  107716. }
  107717. /**
  107718. * Define the code related to the Sheen parameters of the pbr material.
  107719. */
  107720. export class PBRSheenConfiguration {
  107721. private _isEnabled;
  107722. /**
  107723. * Defines if the material uses sheen.
  107724. */
  107725. isEnabled: boolean;
  107726. private _linkSheenWithAlbedo;
  107727. /**
  107728. * Defines if the sheen is linked to the sheen color.
  107729. */
  107730. linkSheenWithAlbedo: boolean;
  107731. /**
  107732. * Defines the sheen intensity.
  107733. */
  107734. intensity: number;
  107735. /**
  107736. * Defines the sheen color.
  107737. */
  107738. color: Color3;
  107739. private _texture;
  107740. /**
  107741. * Stores the sheen tint values in a texture.
  107742. * rgb is tint
  107743. * a is a intensity
  107744. */
  107745. texture: Nullable<BaseTexture>;
  107746. /** @hidden */
  107747. private _internalMarkAllSubMeshesAsTexturesDirty;
  107748. /** @hidden */
  107749. _markAllSubMeshesAsTexturesDirty(): void;
  107750. /**
  107751. * Instantiate a new istance of clear coat configuration.
  107752. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107753. */
  107754. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107755. /**
  107756. * Specifies that the submesh is ready to be used.
  107757. * @param defines the list of "defines" to update.
  107758. * @param scene defines the scene the material belongs to.
  107759. * @returns - boolean indicating that the submesh is ready or not.
  107760. */
  107761. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107762. /**
  107763. * Checks to see if a texture is used in the material.
  107764. * @param defines the list of "defines" to update.
  107765. * @param scene defines the scene the material belongs to.
  107766. */
  107767. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107768. /**
  107769. * Binds the material data.
  107770. * @param uniformBuffer defines the Uniform buffer to fill in.
  107771. * @param scene defines the scene the material belongs to.
  107772. * @param isFrozen defines wether the material is frozen or not.
  107773. */
  107774. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107775. /**
  107776. * Checks to see if a texture is used in the material.
  107777. * @param texture - Base texture to use.
  107778. * @returns - Boolean specifying if a texture is used in the material.
  107779. */
  107780. hasTexture(texture: BaseTexture): boolean;
  107781. /**
  107782. * Returns an array of the actively used textures.
  107783. * @param activeTextures Array of BaseTextures
  107784. */
  107785. getActiveTextures(activeTextures: BaseTexture[]): void;
  107786. /**
  107787. * Returns the animatable textures.
  107788. * @param animatables Array of animatable textures.
  107789. */
  107790. getAnimatables(animatables: IAnimatable[]): void;
  107791. /**
  107792. * Disposes the resources of the material.
  107793. * @param forceDisposeTextures - Forces the disposal of all textures.
  107794. */
  107795. dispose(forceDisposeTextures?: boolean): void;
  107796. /**
  107797. * Get the current class name of the texture useful for serialization or dynamic coding.
  107798. * @returns "PBRSheenConfiguration"
  107799. */
  107800. getClassName(): string;
  107801. /**
  107802. * Add fallbacks to the effect fallbacks list.
  107803. * @param defines defines the Base texture to use.
  107804. * @param fallbacks defines the current fallback list.
  107805. * @param currentRank defines the current fallback rank.
  107806. * @returns the new fallback rank.
  107807. */
  107808. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107809. /**
  107810. * Add the required uniforms to the current list.
  107811. * @param uniforms defines the current uniform list.
  107812. */
  107813. static AddUniforms(uniforms: string[]): void;
  107814. /**
  107815. * Add the required uniforms to the current buffer.
  107816. * @param uniformBuffer defines the current uniform buffer.
  107817. */
  107818. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107819. /**
  107820. * Add the required samplers to the current list.
  107821. * @param samplers defines the current sampler list.
  107822. */
  107823. static AddSamplers(samplers: string[]): void;
  107824. /**
  107825. * Makes a duplicate of the current configuration into another one.
  107826. * @param sheenConfiguration define the config where to copy the info
  107827. */
  107828. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107829. /**
  107830. * Serializes this BRDF configuration.
  107831. * @returns - An object with the serialized config.
  107832. */
  107833. serialize(): any;
  107834. /**
  107835. * Parses a anisotropy Configuration from a serialized object.
  107836. * @param source - Serialized object.
  107837. * @param scene Defines the scene we are parsing for
  107838. * @param rootUrl Defines the rootUrl to load from
  107839. */
  107840. parse(source: any, scene: Scene, rootUrl: string): void;
  107841. }
  107842. }
  107843. declare module BABYLON {
  107844. /**
  107845. * @hidden
  107846. */
  107847. export interface IMaterialSubSurfaceDefines {
  107848. SUBSURFACE: boolean;
  107849. SS_REFRACTION: boolean;
  107850. SS_TRANSLUCENCY: boolean;
  107851. SS_SCATERRING: boolean;
  107852. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107853. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107854. SS_REFRACTIONMAP_3D: boolean;
  107855. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107856. SS_LODINREFRACTIONALPHA: boolean;
  107857. SS_GAMMAREFRACTION: boolean;
  107858. SS_RGBDREFRACTION: boolean;
  107859. SS_LINEARSPECULARREFRACTION: boolean;
  107860. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107861. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107862. /** @hidden */
  107863. _areTexturesDirty: boolean;
  107864. }
  107865. /**
  107866. * Define the code related to the sub surface parameters of the pbr material.
  107867. */
  107868. export class PBRSubSurfaceConfiguration {
  107869. private _isRefractionEnabled;
  107870. /**
  107871. * Defines if the refraction is enabled in the material.
  107872. */
  107873. isRefractionEnabled: boolean;
  107874. private _isTranslucencyEnabled;
  107875. /**
  107876. * Defines if the translucency is enabled in the material.
  107877. */
  107878. isTranslucencyEnabled: boolean;
  107879. private _isScatteringEnabled;
  107880. /**
  107881. * Defines the refraction intensity of the material.
  107882. * The refraction when enabled replaces the Diffuse part of the material.
  107883. * The intensity helps transitionning between diffuse and refraction.
  107884. */
  107885. refractionIntensity: number;
  107886. /**
  107887. * Defines the translucency intensity of the material.
  107888. * When translucency has been enabled, this defines how much of the "translucency"
  107889. * is addded to the diffuse part of the material.
  107890. */
  107891. translucencyIntensity: number;
  107892. /**
  107893. * Defines the scattering intensity of the material.
  107894. * When scattering has been enabled, this defines how much of the "scattered light"
  107895. * is addded to the diffuse part of the material.
  107896. */
  107897. scatteringIntensity: number;
  107898. private _thicknessTexture;
  107899. /**
  107900. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107901. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107902. * 0 would mean minimumThickness
  107903. * 1 would mean maximumThickness
  107904. * The other channels might be use as a mask to vary the different effects intensity.
  107905. */
  107906. thicknessTexture: Nullable<BaseTexture>;
  107907. private _refractionTexture;
  107908. /**
  107909. * Defines the texture to use for refraction.
  107910. */
  107911. refractionTexture: Nullable<BaseTexture>;
  107912. private _indexOfRefraction;
  107913. /**
  107914. * Defines the index of refraction used in the material.
  107915. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107916. */
  107917. indexOfRefraction: number;
  107918. private _invertRefractionY;
  107919. /**
  107920. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107921. */
  107922. invertRefractionY: boolean;
  107923. private _linkRefractionWithTransparency;
  107924. /**
  107925. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107926. * Materials half opaque for instance using refraction could benefit from this control.
  107927. */
  107928. linkRefractionWithTransparency: boolean;
  107929. /**
  107930. * Defines the minimum thickness stored in the thickness map.
  107931. * If no thickness map is defined, this value will be used to simulate thickness.
  107932. */
  107933. minimumThickness: number;
  107934. /**
  107935. * Defines the maximum thickness stored in the thickness map.
  107936. */
  107937. maximumThickness: number;
  107938. /**
  107939. * Defines the volume tint of the material.
  107940. * This is used for both translucency and scattering.
  107941. */
  107942. tintColor: Color3;
  107943. /**
  107944. * Defines the distance at which the tint color should be found in the media.
  107945. * This is used for refraction only.
  107946. */
  107947. tintColorAtDistance: number;
  107948. /**
  107949. * Defines how far each channel transmit through the media.
  107950. * It is defined as a color to simplify it selection.
  107951. */
  107952. diffusionDistance: Color3;
  107953. private _useMaskFromThicknessTexture;
  107954. /**
  107955. * Stores the intensity of the different subsurface effects in the thickness texture.
  107956. * * the green channel is the translucency intensity.
  107957. * * the blue channel is the scattering intensity.
  107958. * * the alpha channel is the refraction intensity.
  107959. */
  107960. useMaskFromThicknessTexture: boolean;
  107961. /** @hidden */
  107962. private _internalMarkAllSubMeshesAsTexturesDirty;
  107963. /** @hidden */
  107964. _markAllSubMeshesAsTexturesDirty(): void;
  107965. /**
  107966. * Instantiate a new istance of sub surface configuration.
  107967. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107968. */
  107969. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107970. /**
  107971. * Gets wehter the submesh is ready to be used or not.
  107972. * @param defines the list of "defines" to update.
  107973. * @param scene defines the scene the material belongs to.
  107974. * @returns - boolean indicating that the submesh is ready or not.
  107975. */
  107976. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107977. /**
  107978. * Checks to see if a texture is used in the material.
  107979. * @param defines the list of "defines" to update.
  107980. * @param scene defines the scene to the material belongs to.
  107981. */
  107982. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107983. /**
  107984. * Binds the material data.
  107985. * @param uniformBuffer defines the Uniform buffer to fill in.
  107986. * @param scene defines the scene the material belongs to.
  107987. * @param engine defines the engine the material belongs to.
  107988. * @param isFrozen defines wether the material is frozen or not.
  107989. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107990. */
  107991. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107992. /**
  107993. * Unbinds the material from the mesh.
  107994. * @param activeEffect defines the effect that should be unbound from.
  107995. * @returns true if unbound, otherwise false
  107996. */
  107997. unbind(activeEffect: Effect): boolean;
  107998. /**
  107999. * Returns the texture used for refraction or null if none is used.
  108000. * @param scene defines the scene the material belongs to.
  108001. * @returns - Refraction texture if present. If no refraction texture and refraction
  108002. * is linked with transparency, returns environment texture. Otherwise, returns null.
  108003. */
  108004. private _getRefractionTexture;
  108005. /**
  108006. * Returns true if alpha blending should be disabled.
  108007. */
  108008. readonly disableAlphaBlending: boolean;
  108009. /**
  108010. * Fills the list of render target textures.
  108011. * @param renderTargets the list of render targets to update
  108012. */
  108013. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  108014. /**
  108015. * Checks to see if a texture is used in the material.
  108016. * @param texture - Base texture to use.
  108017. * @returns - Boolean specifying if a texture is used in the material.
  108018. */
  108019. hasTexture(texture: BaseTexture): boolean;
  108020. /**
  108021. * Gets a boolean indicating that current material needs to register RTT
  108022. * @returns true if this uses a render target otherwise false.
  108023. */
  108024. hasRenderTargetTextures(): boolean;
  108025. /**
  108026. * Returns an array of the actively used textures.
  108027. * @param activeTextures Array of BaseTextures
  108028. */
  108029. getActiveTextures(activeTextures: BaseTexture[]): void;
  108030. /**
  108031. * Returns the animatable textures.
  108032. * @param animatables Array of animatable textures.
  108033. */
  108034. getAnimatables(animatables: IAnimatable[]): void;
  108035. /**
  108036. * Disposes the resources of the material.
  108037. * @param forceDisposeTextures - Forces the disposal of all textures.
  108038. */
  108039. dispose(forceDisposeTextures?: boolean): void;
  108040. /**
  108041. * Get the current class name of the texture useful for serialization or dynamic coding.
  108042. * @returns "PBRSubSurfaceConfiguration"
  108043. */
  108044. getClassName(): string;
  108045. /**
  108046. * Add fallbacks to the effect fallbacks list.
  108047. * @param defines defines the Base texture to use.
  108048. * @param fallbacks defines the current fallback list.
  108049. * @param currentRank defines the current fallback rank.
  108050. * @returns the new fallback rank.
  108051. */
  108052. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108053. /**
  108054. * Add the required uniforms to the current list.
  108055. * @param uniforms defines the current uniform list.
  108056. */
  108057. static AddUniforms(uniforms: string[]): void;
  108058. /**
  108059. * Add the required samplers to the current list.
  108060. * @param samplers defines the current sampler list.
  108061. */
  108062. static AddSamplers(samplers: string[]): void;
  108063. /**
  108064. * Add the required uniforms to the current buffer.
  108065. * @param uniformBuffer defines the current uniform buffer.
  108066. */
  108067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108068. /**
  108069. * Makes a duplicate of the current configuration into another one.
  108070. * @param configuration define the config where to copy the info
  108071. */
  108072. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  108073. /**
  108074. * Serializes this Sub Surface configuration.
  108075. * @returns - An object with the serialized config.
  108076. */
  108077. serialize(): any;
  108078. /**
  108079. * Parses a anisotropy Configuration from a serialized object.
  108080. * @param source - Serialized object.
  108081. * @param scene Defines the scene we are parsing for
  108082. * @param rootUrl Defines the rootUrl to load from
  108083. */
  108084. parse(source: any, scene: Scene, rootUrl: string): void;
  108085. }
  108086. }
  108087. declare module BABYLON {
  108088. /** @hidden */
  108089. export var pbrFragmentDeclaration: {
  108090. name: string;
  108091. shader: string;
  108092. };
  108093. }
  108094. declare module BABYLON {
  108095. /** @hidden */
  108096. export var pbrUboDeclaration: {
  108097. name: string;
  108098. shader: string;
  108099. };
  108100. }
  108101. declare module BABYLON {
  108102. /** @hidden */
  108103. export var pbrFragmentExtraDeclaration: {
  108104. name: string;
  108105. shader: string;
  108106. };
  108107. }
  108108. declare module BABYLON {
  108109. /** @hidden */
  108110. export var pbrFragmentSamplersDeclaration: {
  108111. name: string;
  108112. shader: string;
  108113. };
  108114. }
  108115. declare module BABYLON {
  108116. /** @hidden */
  108117. export var pbrHelperFunctions: {
  108118. name: string;
  108119. shader: string;
  108120. };
  108121. }
  108122. declare module BABYLON {
  108123. /** @hidden */
  108124. export var harmonicsFunctions: {
  108125. name: string;
  108126. shader: string;
  108127. };
  108128. }
  108129. declare module BABYLON {
  108130. /** @hidden */
  108131. export var pbrDirectLightingSetupFunctions: {
  108132. name: string;
  108133. shader: string;
  108134. };
  108135. }
  108136. declare module BABYLON {
  108137. /** @hidden */
  108138. export var pbrDirectLightingFalloffFunctions: {
  108139. name: string;
  108140. shader: string;
  108141. };
  108142. }
  108143. declare module BABYLON {
  108144. /** @hidden */
  108145. export var pbrBRDFFunctions: {
  108146. name: string;
  108147. shader: string;
  108148. };
  108149. }
  108150. declare module BABYLON {
  108151. /** @hidden */
  108152. export var pbrDirectLightingFunctions: {
  108153. name: string;
  108154. shader: string;
  108155. };
  108156. }
  108157. declare module BABYLON {
  108158. /** @hidden */
  108159. export var pbrIBLFunctions: {
  108160. name: string;
  108161. shader: string;
  108162. };
  108163. }
  108164. declare module BABYLON {
  108165. /** @hidden */
  108166. export var pbrDebug: {
  108167. name: string;
  108168. shader: string;
  108169. };
  108170. }
  108171. declare module BABYLON {
  108172. /** @hidden */
  108173. export var pbrPixelShader: {
  108174. name: string;
  108175. shader: string;
  108176. };
  108177. }
  108178. declare module BABYLON {
  108179. /** @hidden */
  108180. export var pbrVertexDeclaration: {
  108181. name: string;
  108182. shader: string;
  108183. };
  108184. }
  108185. declare module BABYLON {
  108186. /** @hidden */
  108187. export var pbrVertexShader: {
  108188. name: string;
  108189. shader: string;
  108190. };
  108191. }
  108192. declare module BABYLON {
  108193. /**
  108194. * Manages the defines for the PBR Material.
  108195. * @hidden
  108196. */
  108197. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108198. PBR: boolean;
  108199. MAINUV1: boolean;
  108200. MAINUV2: boolean;
  108201. UV1: boolean;
  108202. UV2: boolean;
  108203. ALBEDO: boolean;
  108204. ALBEDODIRECTUV: number;
  108205. VERTEXCOLOR: boolean;
  108206. AMBIENT: boolean;
  108207. AMBIENTDIRECTUV: number;
  108208. AMBIENTINGRAYSCALE: boolean;
  108209. OPACITY: boolean;
  108210. VERTEXALPHA: boolean;
  108211. OPACITYDIRECTUV: number;
  108212. OPACITYRGB: boolean;
  108213. ALPHATEST: boolean;
  108214. DEPTHPREPASS: boolean;
  108215. ALPHABLEND: boolean;
  108216. ALPHAFROMALBEDO: boolean;
  108217. ALPHATESTVALUE: string;
  108218. SPECULAROVERALPHA: boolean;
  108219. RADIANCEOVERALPHA: boolean;
  108220. ALPHAFRESNEL: boolean;
  108221. LINEARALPHAFRESNEL: boolean;
  108222. PREMULTIPLYALPHA: boolean;
  108223. EMISSIVE: boolean;
  108224. EMISSIVEDIRECTUV: number;
  108225. REFLECTIVITY: boolean;
  108226. REFLECTIVITYDIRECTUV: number;
  108227. SPECULARTERM: boolean;
  108228. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108229. MICROSURFACEAUTOMATIC: boolean;
  108230. LODBASEDMICROSFURACE: boolean;
  108231. MICROSURFACEMAP: boolean;
  108232. MICROSURFACEMAPDIRECTUV: number;
  108233. METALLICWORKFLOW: boolean;
  108234. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108235. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108236. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108237. AOSTOREINMETALMAPRED: boolean;
  108238. ENVIRONMENTBRDF: boolean;
  108239. ENVIRONMENTBRDF_RGBD: boolean;
  108240. NORMAL: boolean;
  108241. TANGENT: boolean;
  108242. BUMP: boolean;
  108243. BUMPDIRECTUV: number;
  108244. OBJECTSPACE_NORMALMAP: boolean;
  108245. PARALLAX: boolean;
  108246. PARALLAXOCCLUSION: boolean;
  108247. NORMALXYSCALE: boolean;
  108248. LIGHTMAP: boolean;
  108249. LIGHTMAPDIRECTUV: number;
  108250. USELIGHTMAPASSHADOWMAP: boolean;
  108251. GAMMALIGHTMAP: boolean;
  108252. REFLECTION: boolean;
  108253. REFLECTIONMAP_3D: boolean;
  108254. REFLECTIONMAP_SPHERICAL: boolean;
  108255. REFLECTIONMAP_PLANAR: boolean;
  108256. REFLECTIONMAP_CUBIC: boolean;
  108257. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108258. REFLECTIONMAP_PROJECTION: boolean;
  108259. REFLECTIONMAP_SKYBOX: boolean;
  108260. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108261. REFLECTIONMAP_EXPLICIT: boolean;
  108262. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108263. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108264. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108265. INVERTCUBICMAP: boolean;
  108266. USESPHERICALFROMREFLECTIONMAP: boolean;
  108267. USEIRRADIANCEMAP: boolean;
  108268. SPHERICAL_HARMONICS: boolean;
  108269. USESPHERICALINVERTEX: boolean;
  108270. REFLECTIONMAP_OPPOSITEZ: boolean;
  108271. LODINREFLECTIONALPHA: boolean;
  108272. GAMMAREFLECTION: boolean;
  108273. RGBDREFLECTION: boolean;
  108274. LINEARSPECULARREFLECTION: boolean;
  108275. RADIANCEOCCLUSION: boolean;
  108276. HORIZONOCCLUSION: boolean;
  108277. INSTANCES: boolean;
  108278. NUM_BONE_INFLUENCERS: number;
  108279. BonesPerMesh: number;
  108280. BONETEXTURE: boolean;
  108281. NONUNIFORMSCALING: boolean;
  108282. MORPHTARGETS: boolean;
  108283. MORPHTARGETS_NORMAL: boolean;
  108284. MORPHTARGETS_TANGENT: boolean;
  108285. MORPHTARGETS_UV: boolean;
  108286. NUM_MORPH_INFLUENCERS: number;
  108287. IMAGEPROCESSING: boolean;
  108288. VIGNETTE: boolean;
  108289. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108290. VIGNETTEBLENDMODEOPAQUE: boolean;
  108291. TONEMAPPING: boolean;
  108292. TONEMAPPING_ACES: boolean;
  108293. CONTRAST: boolean;
  108294. COLORCURVES: boolean;
  108295. COLORGRADING: boolean;
  108296. COLORGRADING3D: boolean;
  108297. SAMPLER3DGREENDEPTH: boolean;
  108298. SAMPLER3DBGRMAP: boolean;
  108299. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108300. EXPOSURE: boolean;
  108301. MULTIVIEW: boolean;
  108302. USEPHYSICALLIGHTFALLOFF: boolean;
  108303. USEGLTFLIGHTFALLOFF: boolean;
  108304. TWOSIDEDLIGHTING: boolean;
  108305. SHADOWFLOAT: boolean;
  108306. CLIPPLANE: boolean;
  108307. CLIPPLANE2: boolean;
  108308. CLIPPLANE3: boolean;
  108309. CLIPPLANE4: boolean;
  108310. POINTSIZE: boolean;
  108311. FOG: boolean;
  108312. LOGARITHMICDEPTH: boolean;
  108313. FORCENORMALFORWARD: boolean;
  108314. SPECULARAA: boolean;
  108315. CLEARCOAT: boolean;
  108316. CLEARCOAT_DEFAULTIOR: boolean;
  108317. CLEARCOAT_TEXTURE: boolean;
  108318. CLEARCOAT_TEXTUREDIRECTUV: number;
  108319. CLEARCOAT_BUMP: boolean;
  108320. CLEARCOAT_BUMPDIRECTUV: number;
  108321. CLEARCOAT_TINT: boolean;
  108322. CLEARCOAT_TINT_TEXTURE: boolean;
  108323. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108324. ANISOTROPIC: boolean;
  108325. ANISOTROPIC_TEXTURE: boolean;
  108326. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108327. BRDF_V_HEIGHT_CORRELATED: boolean;
  108328. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108329. SHEEN: boolean;
  108330. SHEEN_TEXTURE: boolean;
  108331. SHEEN_TEXTUREDIRECTUV: number;
  108332. SHEEN_LINKWITHALBEDO: boolean;
  108333. SUBSURFACE: boolean;
  108334. SS_REFRACTION: boolean;
  108335. SS_TRANSLUCENCY: boolean;
  108336. SS_SCATERRING: boolean;
  108337. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108338. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108339. SS_REFRACTIONMAP_3D: boolean;
  108340. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108341. SS_LODINREFRACTIONALPHA: boolean;
  108342. SS_GAMMAREFRACTION: boolean;
  108343. SS_RGBDREFRACTION: boolean;
  108344. SS_LINEARSPECULARREFRACTION: boolean;
  108345. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108346. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108347. UNLIT: boolean;
  108348. DEBUGMODE: number;
  108349. /**
  108350. * Initializes the PBR Material defines.
  108351. */
  108352. constructor();
  108353. /**
  108354. * Resets the PBR Material defines.
  108355. */
  108356. reset(): void;
  108357. }
  108358. /**
  108359. * The Physically based material base class of BJS.
  108360. *
  108361. * This offers the main features of a standard PBR material.
  108362. * For more information, please refer to the documentation :
  108363. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108364. */
  108365. export abstract class PBRBaseMaterial extends PushMaterial {
  108366. /**
  108367. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108368. */
  108369. static readonly PBRMATERIAL_OPAQUE: number;
  108370. /**
  108371. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108372. */
  108373. static readonly PBRMATERIAL_ALPHATEST: number;
  108374. /**
  108375. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108376. */
  108377. static readonly PBRMATERIAL_ALPHABLEND: number;
  108378. /**
  108379. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108380. * They are also discarded below the alpha cutoff threshold to improve performances.
  108381. */
  108382. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108383. /**
  108384. * Defines the default value of how much AO map is occluding the analytical lights
  108385. * (point spot...).
  108386. */
  108387. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108388. /**
  108389. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108390. */
  108391. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108392. /**
  108393. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108394. * to enhance interoperability with other engines.
  108395. */
  108396. static readonly LIGHTFALLOFF_GLTF: number;
  108397. /**
  108398. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108399. * to enhance interoperability with other materials.
  108400. */
  108401. static readonly LIGHTFALLOFF_STANDARD: number;
  108402. /**
  108403. * Intensity of the direct lights e.g. the four lights available in your scene.
  108404. * This impacts both the direct diffuse and specular highlights.
  108405. */
  108406. protected _directIntensity: number;
  108407. /**
  108408. * Intensity of the emissive part of the material.
  108409. * This helps controlling the emissive effect without modifying the emissive color.
  108410. */
  108411. protected _emissiveIntensity: number;
  108412. /**
  108413. * Intensity of the environment e.g. how much the environment will light the object
  108414. * either through harmonics for rough material or through the refelction for shiny ones.
  108415. */
  108416. protected _environmentIntensity: number;
  108417. /**
  108418. * This is a special control allowing the reduction of the specular highlights coming from the
  108419. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108420. */
  108421. protected _specularIntensity: number;
  108422. /**
  108423. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108424. */
  108425. private _lightingInfos;
  108426. /**
  108427. * Debug Control allowing disabling the bump map on this material.
  108428. */
  108429. protected _disableBumpMap: boolean;
  108430. /**
  108431. * AKA Diffuse Texture in standard nomenclature.
  108432. */
  108433. protected _albedoTexture: Nullable<BaseTexture>;
  108434. /**
  108435. * AKA Occlusion Texture in other nomenclature.
  108436. */
  108437. protected _ambientTexture: Nullable<BaseTexture>;
  108438. /**
  108439. * AKA Occlusion Texture Intensity in other nomenclature.
  108440. */
  108441. protected _ambientTextureStrength: number;
  108442. /**
  108443. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108444. * 1 means it completely occludes it
  108445. * 0 mean it has no impact
  108446. */
  108447. protected _ambientTextureImpactOnAnalyticalLights: number;
  108448. /**
  108449. * Stores the alpha values in a texture.
  108450. */
  108451. protected _opacityTexture: Nullable<BaseTexture>;
  108452. /**
  108453. * Stores the reflection values in a texture.
  108454. */
  108455. protected _reflectionTexture: Nullable<BaseTexture>;
  108456. /**
  108457. * Stores the emissive values in a texture.
  108458. */
  108459. protected _emissiveTexture: Nullable<BaseTexture>;
  108460. /**
  108461. * AKA Specular texture in other nomenclature.
  108462. */
  108463. protected _reflectivityTexture: Nullable<BaseTexture>;
  108464. /**
  108465. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108466. */
  108467. protected _metallicTexture: Nullable<BaseTexture>;
  108468. /**
  108469. * Specifies the metallic scalar of the metallic/roughness workflow.
  108470. * Can also be used to scale the metalness values of the metallic texture.
  108471. */
  108472. protected _metallic: Nullable<number>;
  108473. /**
  108474. * Specifies the roughness scalar of the metallic/roughness workflow.
  108475. * Can also be used to scale the roughness values of the metallic texture.
  108476. */
  108477. protected _roughness: Nullable<number>;
  108478. /**
  108479. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108480. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108481. */
  108482. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108483. /**
  108484. * Stores surface normal data used to displace a mesh in a texture.
  108485. */
  108486. protected _bumpTexture: Nullable<BaseTexture>;
  108487. /**
  108488. * Stores the pre-calculated light information of a mesh in a texture.
  108489. */
  108490. protected _lightmapTexture: Nullable<BaseTexture>;
  108491. /**
  108492. * The color of a material in ambient lighting.
  108493. */
  108494. protected _ambientColor: Color3;
  108495. /**
  108496. * AKA Diffuse Color in other nomenclature.
  108497. */
  108498. protected _albedoColor: Color3;
  108499. /**
  108500. * AKA Specular Color in other nomenclature.
  108501. */
  108502. protected _reflectivityColor: Color3;
  108503. /**
  108504. * The color applied when light is reflected from a material.
  108505. */
  108506. protected _reflectionColor: Color3;
  108507. /**
  108508. * The color applied when light is emitted from a material.
  108509. */
  108510. protected _emissiveColor: Color3;
  108511. /**
  108512. * AKA Glossiness in other nomenclature.
  108513. */
  108514. protected _microSurface: number;
  108515. /**
  108516. * Specifies that the material will use the light map as a show map.
  108517. */
  108518. protected _useLightmapAsShadowmap: boolean;
  108519. /**
  108520. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108521. * makes the reflect vector face the model (under horizon).
  108522. */
  108523. protected _useHorizonOcclusion: boolean;
  108524. /**
  108525. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108526. * too much the area relying on ambient texture to define their ambient occlusion.
  108527. */
  108528. protected _useRadianceOcclusion: boolean;
  108529. /**
  108530. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108531. */
  108532. protected _useAlphaFromAlbedoTexture: boolean;
  108533. /**
  108534. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108535. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108536. */
  108537. protected _useSpecularOverAlpha: boolean;
  108538. /**
  108539. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108540. */
  108541. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108542. /**
  108543. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108544. */
  108545. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108546. /**
  108547. * Specifies if the metallic texture contains the roughness information in its green channel.
  108548. */
  108549. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108550. /**
  108551. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108552. */
  108553. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108554. /**
  108555. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108556. */
  108557. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108558. /**
  108559. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108560. */
  108561. protected _useAmbientInGrayScale: boolean;
  108562. /**
  108563. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108564. * The material will try to infer what glossiness each pixel should be.
  108565. */
  108566. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108567. /**
  108568. * Defines the falloff type used in this material.
  108569. * It by default is Physical.
  108570. */
  108571. protected _lightFalloff: number;
  108572. /**
  108573. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108574. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108575. */
  108576. protected _useRadianceOverAlpha: boolean;
  108577. /**
  108578. * Allows using an object space normal map (instead of tangent space).
  108579. */
  108580. protected _useObjectSpaceNormalMap: boolean;
  108581. /**
  108582. * Allows using the bump map in parallax mode.
  108583. */
  108584. protected _useParallax: boolean;
  108585. /**
  108586. * Allows using the bump map in parallax occlusion mode.
  108587. */
  108588. protected _useParallaxOcclusion: boolean;
  108589. /**
  108590. * Controls the scale bias of the parallax mode.
  108591. */
  108592. protected _parallaxScaleBias: number;
  108593. /**
  108594. * If sets to true, disables all the lights affecting the material.
  108595. */
  108596. protected _disableLighting: boolean;
  108597. /**
  108598. * Number of Simultaneous lights allowed on the material.
  108599. */
  108600. protected _maxSimultaneousLights: number;
  108601. /**
  108602. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108603. */
  108604. protected _invertNormalMapX: boolean;
  108605. /**
  108606. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108607. */
  108608. protected _invertNormalMapY: boolean;
  108609. /**
  108610. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108611. */
  108612. protected _twoSidedLighting: boolean;
  108613. /**
  108614. * Defines the alpha limits in alpha test mode.
  108615. */
  108616. protected _alphaCutOff: number;
  108617. /**
  108618. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108619. */
  108620. protected _forceAlphaTest: boolean;
  108621. /**
  108622. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108623. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108624. */
  108625. protected _useAlphaFresnel: boolean;
  108626. /**
  108627. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108628. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108629. */
  108630. protected _useLinearAlphaFresnel: boolean;
  108631. /**
  108632. * The transparency mode of the material.
  108633. */
  108634. protected _transparencyMode: Nullable<number>;
  108635. /**
  108636. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108637. * from cos thetav and roughness:
  108638. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108639. */
  108640. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108641. /**
  108642. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108643. */
  108644. protected _forceIrradianceInFragment: boolean;
  108645. /**
  108646. * Force normal to face away from face.
  108647. */
  108648. protected _forceNormalForward: boolean;
  108649. /**
  108650. * Enables specular anti aliasing in the PBR shader.
  108651. * It will both interacts on the Geometry for analytical and IBL lighting.
  108652. * It also prefilter the roughness map based on the bump values.
  108653. */
  108654. protected _enableSpecularAntiAliasing: boolean;
  108655. /**
  108656. * Default configuration related to image processing available in the PBR Material.
  108657. */
  108658. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108659. /**
  108660. * Keep track of the image processing observer to allow dispose and replace.
  108661. */
  108662. private _imageProcessingObserver;
  108663. /**
  108664. * Attaches a new image processing configuration to the PBR Material.
  108665. * @param configuration
  108666. */
  108667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108668. /**
  108669. * Stores the available render targets.
  108670. */
  108671. private _renderTargets;
  108672. /**
  108673. * Sets the global ambient color for the material used in lighting calculations.
  108674. */
  108675. private _globalAmbientColor;
  108676. /**
  108677. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108678. */
  108679. private _useLogarithmicDepth;
  108680. /**
  108681. * If set to true, no lighting calculations will be applied.
  108682. */
  108683. private _unlit;
  108684. private _debugMode;
  108685. /**
  108686. * @hidden
  108687. * This is reserved for the inspector.
  108688. * Defines the material debug mode.
  108689. * It helps seeing only some components of the material while troubleshooting.
  108690. */
  108691. debugMode: number;
  108692. /**
  108693. * @hidden
  108694. * This is reserved for the inspector.
  108695. * Specify from where on screen the debug mode should start.
  108696. * The value goes from -1 (full screen) to 1 (not visible)
  108697. * It helps with side by side comparison against the final render
  108698. * This defaults to -1
  108699. */
  108700. private debugLimit;
  108701. /**
  108702. * @hidden
  108703. * This is reserved for the inspector.
  108704. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108705. * You can use the factor to better multiply the final value.
  108706. */
  108707. private debugFactor;
  108708. /**
  108709. * Defines the clear coat layer parameters for the material.
  108710. */
  108711. readonly clearCoat: PBRClearCoatConfiguration;
  108712. /**
  108713. * Defines the anisotropic parameters for the material.
  108714. */
  108715. readonly anisotropy: PBRAnisotropicConfiguration;
  108716. /**
  108717. * Defines the BRDF parameters for the material.
  108718. */
  108719. readonly brdf: PBRBRDFConfiguration;
  108720. /**
  108721. * Defines the Sheen parameters for the material.
  108722. */
  108723. readonly sheen: PBRSheenConfiguration;
  108724. /**
  108725. * Defines the SubSurface parameters for the material.
  108726. */
  108727. readonly subSurface: PBRSubSurfaceConfiguration;
  108728. /**
  108729. * Custom callback helping to override the default shader used in the material.
  108730. */
  108731. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108732. /**
  108733. * Instantiates a new PBRMaterial instance.
  108734. *
  108735. * @param name The material name
  108736. * @param scene The scene the material will be use in.
  108737. */
  108738. constructor(name: string, scene: Scene);
  108739. /**
  108740. * Gets a boolean indicating that current material needs to register RTT
  108741. */
  108742. readonly hasRenderTargetTextures: boolean;
  108743. /**
  108744. * Gets the name of the material class.
  108745. */
  108746. getClassName(): string;
  108747. /**
  108748. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108749. */
  108750. /**
  108751. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108752. */
  108753. useLogarithmicDepth: boolean;
  108754. /**
  108755. * Gets the current transparency mode.
  108756. */
  108757. /**
  108758. * Sets the transparency mode of the material.
  108759. *
  108760. * | Value | Type | Description |
  108761. * | ----- | ----------------------------------- | ----------- |
  108762. * | 0 | OPAQUE | |
  108763. * | 1 | ALPHATEST | |
  108764. * | 2 | ALPHABLEND | |
  108765. * | 3 | ALPHATESTANDBLEND | |
  108766. *
  108767. */
  108768. transparencyMode: Nullable<number>;
  108769. /**
  108770. * Returns true if alpha blending should be disabled.
  108771. */
  108772. private readonly _disableAlphaBlending;
  108773. /**
  108774. * Specifies whether or not this material should be rendered in alpha blend mode.
  108775. */
  108776. needAlphaBlending(): boolean;
  108777. /**
  108778. * Specifies if the mesh will require alpha blending.
  108779. * @param mesh - BJS mesh.
  108780. */
  108781. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108782. /**
  108783. * Specifies whether or not this material should be rendered in alpha test mode.
  108784. */
  108785. needAlphaTesting(): boolean;
  108786. /**
  108787. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108788. */
  108789. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108790. /**
  108791. * Gets the texture used for the alpha test.
  108792. */
  108793. getAlphaTestTexture(): Nullable<BaseTexture>;
  108794. /**
  108795. * Specifies that the submesh is ready to be used.
  108796. * @param mesh - BJS mesh.
  108797. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108798. * @param useInstances - Specifies that instances should be used.
  108799. * @returns - boolean indicating that the submesh is ready or not.
  108800. */
  108801. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108802. /**
  108803. * Specifies if the material uses metallic roughness workflow.
  108804. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108805. */
  108806. isMetallicWorkflow(): boolean;
  108807. private _prepareEffect;
  108808. private _prepareDefines;
  108809. /**
  108810. * Force shader compilation
  108811. */
  108812. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108813. clipPlane: boolean;
  108814. }>): void;
  108815. /**
  108816. * Initializes the uniform buffer layout for the shader.
  108817. */
  108818. buildUniformLayout(): void;
  108819. /**
  108820. * Unbinds the material from the mesh
  108821. */
  108822. unbind(): void;
  108823. /**
  108824. * Binds the submesh data.
  108825. * @param world - The world matrix.
  108826. * @param mesh - The BJS mesh.
  108827. * @param subMesh - A submesh of the BJS mesh.
  108828. */
  108829. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108830. /**
  108831. * Returns the animatable textures.
  108832. * @returns - Array of animatable textures.
  108833. */
  108834. getAnimatables(): IAnimatable[];
  108835. /**
  108836. * Returns the texture used for reflections.
  108837. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108838. */
  108839. private _getReflectionTexture;
  108840. /**
  108841. * Returns an array of the actively used textures.
  108842. * @returns - Array of BaseTextures
  108843. */
  108844. getActiveTextures(): BaseTexture[];
  108845. /**
  108846. * Checks to see if a texture is used in the material.
  108847. * @param texture - Base texture to use.
  108848. * @returns - Boolean specifying if a texture is used in the material.
  108849. */
  108850. hasTexture(texture: BaseTexture): boolean;
  108851. /**
  108852. * Disposes the resources of the material.
  108853. * @param forceDisposeEffect - Forces the disposal of effects.
  108854. * @param forceDisposeTextures - Forces the disposal of all textures.
  108855. */
  108856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108857. }
  108858. }
  108859. declare module BABYLON {
  108860. /**
  108861. * The Physically based material of BJS.
  108862. *
  108863. * This offers the main features of a standard PBR material.
  108864. * For more information, please refer to the documentation :
  108865. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108866. */
  108867. export class PBRMaterial extends PBRBaseMaterial {
  108868. /**
  108869. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108870. */
  108871. static readonly PBRMATERIAL_OPAQUE: number;
  108872. /**
  108873. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108874. */
  108875. static readonly PBRMATERIAL_ALPHATEST: number;
  108876. /**
  108877. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108878. */
  108879. static readonly PBRMATERIAL_ALPHABLEND: number;
  108880. /**
  108881. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108882. * They are also discarded below the alpha cutoff threshold to improve performances.
  108883. */
  108884. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108885. /**
  108886. * Defines the default value of how much AO map is occluding the analytical lights
  108887. * (point spot...).
  108888. */
  108889. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108890. /**
  108891. * Intensity of the direct lights e.g. the four lights available in your scene.
  108892. * This impacts both the direct diffuse and specular highlights.
  108893. */
  108894. directIntensity: number;
  108895. /**
  108896. * Intensity of the emissive part of the material.
  108897. * This helps controlling the emissive effect without modifying the emissive color.
  108898. */
  108899. emissiveIntensity: number;
  108900. /**
  108901. * Intensity of the environment e.g. how much the environment will light the object
  108902. * either through harmonics for rough material or through the refelction for shiny ones.
  108903. */
  108904. environmentIntensity: number;
  108905. /**
  108906. * This is a special control allowing the reduction of the specular highlights coming from the
  108907. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108908. */
  108909. specularIntensity: number;
  108910. /**
  108911. * Debug Control allowing disabling the bump map on this material.
  108912. */
  108913. disableBumpMap: boolean;
  108914. /**
  108915. * AKA Diffuse Texture in standard nomenclature.
  108916. */
  108917. albedoTexture: BaseTexture;
  108918. /**
  108919. * AKA Occlusion Texture in other nomenclature.
  108920. */
  108921. ambientTexture: BaseTexture;
  108922. /**
  108923. * AKA Occlusion Texture Intensity in other nomenclature.
  108924. */
  108925. ambientTextureStrength: number;
  108926. /**
  108927. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108928. * 1 means it completely occludes it
  108929. * 0 mean it has no impact
  108930. */
  108931. ambientTextureImpactOnAnalyticalLights: number;
  108932. /**
  108933. * Stores the alpha values in a texture.
  108934. */
  108935. opacityTexture: BaseTexture;
  108936. /**
  108937. * Stores the reflection values in a texture.
  108938. */
  108939. reflectionTexture: Nullable<BaseTexture>;
  108940. /**
  108941. * Stores the emissive values in a texture.
  108942. */
  108943. emissiveTexture: BaseTexture;
  108944. /**
  108945. * AKA Specular texture in other nomenclature.
  108946. */
  108947. reflectivityTexture: BaseTexture;
  108948. /**
  108949. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108950. */
  108951. metallicTexture: BaseTexture;
  108952. /**
  108953. * Specifies the metallic scalar of the metallic/roughness workflow.
  108954. * Can also be used to scale the metalness values of the metallic texture.
  108955. */
  108956. metallic: Nullable<number>;
  108957. /**
  108958. * Specifies the roughness scalar of the metallic/roughness workflow.
  108959. * Can also be used to scale the roughness values of the metallic texture.
  108960. */
  108961. roughness: Nullable<number>;
  108962. /**
  108963. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108964. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108965. */
  108966. microSurfaceTexture: BaseTexture;
  108967. /**
  108968. * Stores surface normal data used to displace a mesh in a texture.
  108969. */
  108970. bumpTexture: BaseTexture;
  108971. /**
  108972. * Stores the pre-calculated light information of a mesh in a texture.
  108973. */
  108974. lightmapTexture: BaseTexture;
  108975. /**
  108976. * Stores the refracted light information in a texture.
  108977. */
  108978. refractionTexture: Nullable<BaseTexture>;
  108979. /**
  108980. * The color of a material in ambient lighting.
  108981. */
  108982. ambientColor: Color3;
  108983. /**
  108984. * AKA Diffuse Color in other nomenclature.
  108985. */
  108986. albedoColor: Color3;
  108987. /**
  108988. * AKA Specular Color in other nomenclature.
  108989. */
  108990. reflectivityColor: Color3;
  108991. /**
  108992. * The color reflected from the material.
  108993. */
  108994. reflectionColor: Color3;
  108995. /**
  108996. * The color emitted from the material.
  108997. */
  108998. emissiveColor: Color3;
  108999. /**
  109000. * AKA Glossiness in other nomenclature.
  109001. */
  109002. microSurface: number;
  109003. /**
  109004. * source material index of refraction (IOR)' / 'destination material IOR.
  109005. */
  109006. indexOfRefraction: number;
  109007. /**
  109008. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109009. */
  109010. invertRefractionY: boolean;
  109011. /**
  109012. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109013. * Materials half opaque for instance using refraction could benefit from this control.
  109014. */
  109015. linkRefractionWithTransparency: boolean;
  109016. /**
  109017. * If true, the light map contains occlusion information instead of lighting info.
  109018. */
  109019. useLightmapAsShadowmap: boolean;
  109020. /**
  109021. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  109022. */
  109023. useAlphaFromAlbedoTexture: boolean;
  109024. /**
  109025. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  109026. */
  109027. forceAlphaTest: boolean;
  109028. /**
  109029. * Defines the alpha limits in alpha test mode.
  109030. */
  109031. alphaCutOff: number;
  109032. /**
  109033. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109034. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109035. */
  109036. useSpecularOverAlpha: boolean;
  109037. /**
  109038. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  109039. */
  109040. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  109041. /**
  109042. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  109043. */
  109044. useRoughnessFromMetallicTextureAlpha: boolean;
  109045. /**
  109046. * Specifies if the metallic texture contains the roughness information in its green channel.
  109047. */
  109048. useRoughnessFromMetallicTextureGreen: boolean;
  109049. /**
  109050. * Specifies if the metallic texture contains the metallness information in its blue channel.
  109051. */
  109052. useMetallnessFromMetallicTextureBlue: boolean;
  109053. /**
  109054. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  109055. */
  109056. useAmbientOcclusionFromMetallicTextureRed: boolean;
  109057. /**
  109058. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  109059. */
  109060. useAmbientInGrayScale: boolean;
  109061. /**
  109062. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  109063. * The material will try to infer what glossiness each pixel should be.
  109064. */
  109065. useAutoMicroSurfaceFromReflectivityMap: boolean;
  109066. /**
  109067. * BJS is using an harcoded light falloff based on a manually sets up range.
  109068. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109069. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109070. */
  109071. /**
  109072. * BJS is using an harcoded light falloff based on a manually sets up range.
  109073. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  109074. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  109075. */
  109076. usePhysicalLightFalloff: boolean;
  109077. /**
  109078. * In order to support the falloff compatibility with gltf, a special mode has been added
  109079. * to reproduce the gltf light falloff.
  109080. */
  109081. /**
  109082. * In order to support the falloff compatibility with gltf, a special mode has been added
  109083. * to reproduce the gltf light falloff.
  109084. */
  109085. useGLTFLightFalloff: boolean;
  109086. /**
  109087. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109088. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109089. */
  109090. useRadianceOverAlpha: boolean;
  109091. /**
  109092. * Allows using an object space normal map (instead of tangent space).
  109093. */
  109094. useObjectSpaceNormalMap: boolean;
  109095. /**
  109096. * Allows using the bump map in parallax mode.
  109097. */
  109098. useParallax: boolean;
  109099. /**
  109100. * Allows using the bump map in parallax occlusion mode.
  109101. */
  109102. useParallaxOcclusion: boolean;
  109103. /**
  109104. * Controls the scale bias of the parallax mode.
  109105. */
  109106. parallaxScaleBias: number;
  109107. /**
  109108. * If sets to true, disables all the lights affecting the material.
  109109. */
  109110. disableLighting: boolean;
  109111. /**
  109112. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109113. */
  109114. forceIrradianceInFragment: boolean;
  109115. /**
  109116. * Number of Simultaneous lights allowed on the material.
  109117. */
  109118. maxSimultaneousLights: number;
  109119. /**
  109120. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109121. */
  109122. invertNormalMapX: boolean;
  109123. /**
  109124. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109125. */
  109126. invertNormalMapY: boolean;
  109127. /**
  109128. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109129. */
  109130. twoSidedLighting: boolean;
  109131. /**
  109132. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109133. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109134. */
  109135. useAlphaFresnel: boolean;
  109136. /**
  109137. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109138. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109139. */
  109140. useLinearAlphaFresnel: boolean;
  109141. /**
  109142. * Let user defines the brdf lookup texture used for IBL.
  109143. * A default 8bit version is embedded but you could point at :
  109144. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109145. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109146. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109147. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109148. */
  109149. environmentBRDFTexture: Nullable<BaseTexture>;
  109150. /**
  109151. * Force normal to face away from face.
  109152. */
  109153. forceNormalForward: boolean;
  109154. /**
  109155. * Enables specular anti aliasing in the PBR shader.
  109156. * It will both interacts on the Geometry for analytical and IBL lighting.
  109157. * It also prefilter the roughness map based on the bump values.
  109158. */
  109159. enableSpecularAntiAliasing: boolean;
  109160. /**
  109161. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109162. * makes the reflect vector face the model (under horizon).
  109163. */
  109164. useHorizonOcclusion: boolean;
  109165. /**
  109166. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109167. * too much the area relying on ambient texture to define their ambient occlusion.
  109168. */
  109169. useRadianceOcclusion: boolean;
  109170. /**
  109171. * If set to true, no lighting calculations will be applied.
  109172. */
  109173. unlit: boolean;
  109174. /**
  109175. * Gets the image processing configuration used either in this material.
  109176. */
  109177. /**
  109178. * Sets the Default image processing configuration used either in the this material.
  109179. *
  109180. * If sets to null, the scene one is in use.
  109181. */
  109182. imageProcessingConfiguration: ImageProcessingConfiguration;
  109183. /**
  109184. * Gets wether the color curves effect is enabled.
  109185. */
  109186. /**
  109187. * Sets wether the color curves effect is enabled.
  109188. */
  109189. cameraColorCurvesEnabled: boolean;
  109190. /**
  109191. * Gets wether the color grading effect is enabled.
  109192. */
  109193. /**
  109194. * Gets wether the color grading effect is enabled.
  109195. */
  109196. cameraColorGradingEnabled: boolean;
  109197. /**
  109198. * Gets wether tonemapping is enabled or not.
  109199. */
  109200. /**
  109201. * Sets wether tonemapping is enabled or not
  109202. */
  109203. cameraToneMappingEnabled: boolean;
  109204. /**
  109205. * The camera exposure used on this material.
  109206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109207. * This corresponds to a photographic exposure.
  109208. */
  109209. /**
  109210. * The camera exposure used on this material.
  109211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109212. * This corresponds to a photographic exposure.
  109213. */
  109214. cameraExposure: number;
  109215. /**
  109216. * Gets The camera contrast used on this material.
  109217. */
  109218. /**
  109219. * Sets The camera contrast used on this material.
  109220. */
  109221. cameraContrast: number;
  109222. /**
  109223. * Gets the Color Grading 2D Lookup Texture.
  109224. */
  109225. /**
  109226. * Sets the Color Grading 2D Lookup Texture.
  109227. */
  109228. cameraColorGradingTexture: Nullable<BaseTexture>;
  109229. /**
  109230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109232. * 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;
  109233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109234. */
  109235. /**
  109236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109238. * 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;
  109239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109240. */
  109241. cameraColorCurves: Nullable<ColorCurves>;
  109242. /**
  109243. * Instantiates a new PBRMaterial instance.
  109244. *
  109245. * @param name The material name
  109246. * @param scene The scene the material will be use in.
  109247. */
  109248. constructor(name: string, scene: Scene);
  109249. /**
  109250. * Returns the name of this material class.
  109251. */
  109252. getClassName(): string;
  109253. /**
  109254. * Makes a duplicate of the current material.
  109255. * @param name - name to use for the new material.
  109256. */
  109257. clone(name: string): PBRMaterial;
  109258. /**
  109259. * Serializes this PBR Material.
  109260. * @returns - An object with the serialized material.
  109261. */
  109262. serialize(): any;
  109263. /**
  109264. * Parses a PBR Material from a serialized object.
  109265. * @param source - Serialized object.
  109266. * @param scene - BJS scene instance.
  109267. * @param rootUrl - url for the scene object
  109268. * @returns - PBRMaterial
  109269. */
  109270. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109271. }
  109272. }
  109273. declare module BABYLON {
  109274. /**
  109275. * Direct draw surface info
  109276. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109277. */
  109278. export interface DDSInfo {
  109279. /**
  109280. * Width of the texture
  109281. */
  109282. width: number;
  109283. /**
  109284. * Width of the texture
  109285. */
  109286. height: number;
  109287. /**
  109288. * Number of Mipmaps for the texture
  109289. * @see https://en.wikipedia.org/wiki/Mipmap
  109290. */
  109291. mipmapCount: number;
  109292. /**
  109293. * If the textures format is a known fourCC format
  109294. * @see https://www.fourcc.org/
  109295. */
  109296. isFourCC: boolean;
  109297. /**
  109298. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109299. */
  109300. isRGB: boolean;
  109301. /**
  109302. * If the texture is a lumincance format
  109303. */
  109304. isLuminance: boolean;
  109305. /**
  109306. * If this is a cube texture
  109307. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109308. */
  109309. isCube: boolean;
  109310. /**
  109311. * If the texture is a compressed format eg. FOURCC_DXT1
  109312. */
  109313. isCompressed: boolean;
  109314. /**
  109315. * The dxgiFormat of the texture
  109316. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109317. */
  109318. dxgiFormat: number;
  109319. /**
  109320. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109321. */
  109322. textureType: number;
  109323. /**
  109324. * Sphericle polynomial created for the dds texture
  109325. */
  109326. sphericalPolynomial?: SphericalPolynomial;
  109327. }
  109328. /**
  109329. * Class used to provide DDS decompression tools
  109330. */
  109331. export class DDSTools {
  109332. /**
  109333. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109334. */
  109335. static StoreLODInAlphaChannel: boolean;
  109336. /**
  109337. * Gets DDS information from an array buffer
  109338. * @param arrayBuffer defines the array buffer to read data from
  109339. * @returns the DDS information
  109340. */
  109341. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109342. private static _FloatView;
  109343. private static _Int32View;
  109344. private static _ToHalfFloat;
  109345. private static _FromHalfFloat;
  109346. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109347. private static _GetHalfFloatRGBAArrayBuffer;
  109348. private static _GetFloatRGBAArrayBuffer;
  109349. private static _GetFloatAsUIntRGBAArrayBuffer;
  109350. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109351. private static _GetRGBAArrayBuffer;
  109352. private static _ExtractLongWordOrder;
  109353. private static _GetRGBArrayBuffer;
  109354. private static _GetLuminanceArrayBuffer;
  109355. /**
  109356. * Uploads DDS Levels to a Babylon Texture
  109357. * @hidden
  109358. */
  109359. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109360. }
  109361. interface Engine {
  109362. /**
  109363. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109364. * @param rootUrl defines the url where the file to load is located
  109365. * @param scene defines the current scene
  109366. * @param lodScale defines scale to apply to the mip map selection
  109367. * @param lodOffset defines offset to apply to the mip map selection
  109368. * @param onLoad defines an optional callback raised when the texture is loaded
  109369. * @param onError defines an optional callback raised if there is an issue to load the texture
  109370. * @param format defines the format of the data
  109371. * @param forcedExtension defines the extension to use to pick the right loader
  109372. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109373. * @returns the cube texture as an InternalTexture
  109374. */
  109375. 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;
  109376. }
  109377. }
  109378. declare module BABYLON {
  109379. /**
  109380. * Implementation of the DDS Texture Loader.
  109381. * @hidden
  109382. */
  109383. export class _DDSTextureLoader implements IInternalTextureLoader {
  109384. /**
  109385. * Defines wether the loader supports cascade loading the different faces.
  109386. */
  109387. readonly supportCascades: boolean;
  109388. /**
  109389. * This returns if the loader support the current file information.
  109390. * @param extension defines the file extension of the file being loaded
  109391. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109392. * @param fallback defines the fallback internal texture if any
  109393. * @param isBase64 defines whether the texture is encoded as a base64
  109394. * @param isBuffer defines whether the texture data are stored as a buffer
  109395. * @returns true if the loader can load the specified file
  109396. */
  109397. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109398. /**
  109399. * Transform the url before loading if required.
  109400. * @param rootUrl the url of the texture
  109401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109402. * @returns the transformed texture
  109403. */
  109404. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109405. /**
  109406. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109407. * @param rootUrl the url of the texture
  109408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109409. * @returns the fallback texture
  109410. */
  109411. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109412. /**
  109413. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109414. * @param data contains the texture data
  109415. * @param texture defines the BabylonJS internal texture
  109416. * @param createPolynomials will be true if polynomials have been requested
  109417. * @param onLoad defines the callback to trigger once the texture is ready
  109418. * @param onError defines the callback to trigger in case of error
  109419. */
  109420. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109421. /**
  109422. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109423. * @param data contains the texture data
  109424. * @param texture defines the BabylonJS internal texture
  109425. * @param callback defines the method to call once ready to upload
  109426. */
  109427. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109428. }
  109429. }
  109430. declare module BABYLON {
  109431. /** @hidden */
  109432. export var rgbdEncodePixelShader: {
  109433. name: string;
  109434. shader: string;
  109435. };
  109436. }
  109437. declare module BABYLON {
  109438. /**
  109439. * Raw texture data and descriptor sufficient for WebGL texture upload
  109440. */
  109441. export interface EnvironmentTextureInfo {
  109442. /**
  109443. * Version of the environment map
  109444. */
  109445. version: number;
  109446. /**
  109447. * Width of image
  109448. */
  109449. width: number;
  109450. /**
  109451. * Irradiance information stored in the file.
  109452. */
  109453. irradiance: any;
  109454. /**
  109455. * Specular information stored in the file.
  109456. */
  109457. specular: any;
  109458. }
  109459. /**
  109460. * Sets of helpers addressing the serialization and deserialization of environment texture
  109461. * stored in a BabylonJS env file.
  109462. * Those files are usually stored as .env files.
  109463. */
  109464. export class EnvironmentTextureTools {
  109465. /**
  109466. * Magic number identifying the env file.
  109467. */
  109468. private static _MagicBytes;
  109469. /**
  109470. * Gets the environment info from an env file.
  109471. * @param data The array buffer containing the .env bytes.
  109472. * @returns the environment file info (the json header) if successfully parsed.
  109473. */
  109474. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109475. /**
  109476. * Creates an environment texture from a loaded cube texture.
  109477. * @param texture defines the cube texture to convert in env file
  109478. * @return a promise containing the environment data if succesfull.
  109479. */
  109480. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109481. /**
  109482. * Creates a JSON representation of the spherical data.
  109483. * @param texture defines the texture containing the polynomials
  109484. * @return the JSON representation of the spherical info
  109485. */
  109486. private static _CreateEnvTextureIrradiance;
  109487. /**
  109488. * Uploads the texture info contained in the env file to the GPU.
  109489. * @param texture defines the internal texture to upload to
  109490. * @param arrayBuffer defines the buffer cotaining the data to load
  109491. * @param info defines the texture info retrieved through the GetEnvInfo method
  109492. * @returns a promise
  109493. */
  109494. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109495. /**
  109496. * Uploads the levels of image data to the GPU.
  109497. * @param texture defines the internal texture to upload to
  109498. * @param imageData defines the array buffer views of image data [mipmap][face]
  109499. * @returns a promise
  109500. */
  109501. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109502. /**
  109503. * Uploads spherical polynomials information to the texture.
  109504. * @param texture defines the texture we are trying to upload the information to
  109505. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109506. */
  109507. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109508. /** @hidden */
  109509. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109510. }
  109511. }
  109512. declare module BABYLON {
  109513. /**
  109514. * Implementation of the ENV Texture Loader.
  109515. * @hidden
  109516. */
  109517. export class _ENVTextureLoader implements IInternalTextureLoader {
  109518. /**
  109519. * Defines wether the loader supports cascade loading the different faces.
  109520. */
  109521. readonly supportCascades: boolean;
  109522. /**
  109523. * This returns if the loader support the current file information.
  109524. * @param extension defines the file extension of the file being loaded
  109525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109526. * @param fallback defines the fallback internal texture if any
  109527. * @param isBase64 defines whether the texture is encoded as a base64
  109528. * @param isBuffer defines whether the texture data are stored as a buffer
  109529. * @returns true if the loader can load the specified file
  109530. */
  109531. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109532. /**
  109533. * Transform the url before loading if required.
  109534. * @param rootUrl the url of the texture
  109535. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109536. * @returns the transformed texture
  109537. */
  109538. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109539. /**
  109540. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109541. * @param rootUrl the url of the texture
  109542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109543. * @returns the fallback texture
  109544. */
  109545. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109546. /**
  109547. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109548. * @param data contains the texture data
  109549. * @param texture defines the BabylonJS internal texture
  109550. * @param createPolynomials will be true if polynomials have been requested
  109551. * @param onLoad defines the callback to trigger once the texture is ready
  109552. * @param onError defines the callback to trigger in case of error
  109553. */
  109554. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109555. /**
  109556. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109557. * @param data contains the texture data
  109558. * @param texture defines the BabylonJS internal texture
  109559. * @param callback defines the method to call once ready to upload
  109560. */
  109561. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109562. }
  109563. }
  109564. declare module BABYLON {
  109565. /**
  109566. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109567. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109568. */
  109569. export class KhronosTextureContainer {
  109570. /** contents of the KTX container file */
  109571. arrayBuffer: any;
  109572. private static HEADER_LEN;
  109573. private static COMPRESSED_2D;
  109574. private static COMPRESSED_3D;
  109575. private static TEX_2D;
  109576. private static TEX_3D;
  109577. /**
  109578. * Gets the openGL type
  109579. */
  109580. glType: number;
  109581. /**
  109582. * Gets the openGL type size
  109583. */
  109584. glTypeSize: number;
  109585. /**
  109586. * Gets the openGL format
  109587. */
  109588. glFormat: number;
  109589. /**
  109590. * Gets the openGL internal format
  109591. */
  109592. glInternalFormat: number;
  109593. /**
  109594. * Gets the base internal format
  109595. */
  109596. glBaseInternalFormat: number;
  109597. /**
  109598. * Gets image width in pixel
  109599. */
  109600. pixelWidth: number;
  109601. /**
  109602. * Gets image height in pixel
  109603. */
  109604. pixelHeight: number;
  109605. /**
  109606. * Gets image depth in pixels
  109607. */
  109608. pixelDepth: number;
  109609. /**
  109610. * Gets the number of array elements
  109611. */
  109612. numberOfArrayElements: number;
  109613. /**
  109614. * Gets the number of faces
  109615. */
  109616. numberOfFaces: number;
  109617. /**
  109618. * Gets the number of mipmap levels
  109619. */
  109620. numberOfMipmapLevels: number;
  109621. /**
  109622. * Gets the bytes of key value data
  109623. */
  109624. bytesOfKeyValueData: number;
  109625. /**
  109626. * Gets the load type
  109627. */
  109628. loadType: number;
  109629. /**
  109630. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109631. */
  109632. isInvalid: boolean;
  109633. /**
  109634. * Creates a new KhronosTextureContainer
  109635. * @param arrayBuffer contents of the KTX container file
  109636. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109637. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109638. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109639. */
  109640. constructor(
  109641. /** contents of the KTX container file */
  109642. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109643. /**
  109644. * Uploads KTX content to a Babylon Texture.
  109645. * It is assumed that the texture has already been created & is currently bound
  109646. * @hidden
  109647. */
  109648. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109649. private _upload2DCompressedLevels;
  109650. }
  109651. }
  109652. declare module BABYLON {
  109653. /**
  109654. * Implementation of the KTX Texture Loader.
  109655. * @hidden
  109656. */
  109657. export class _KTXTextureLoader implements IInternalTextureLoader {
  109658. /**
  109659. * Defines wether the loader supports cascade loading the different faces.
  109660. */
  109661. readonly supportCascades: boolean;
  109662. /**
  109663. * This returns if the loader support the current file information.
  109664. * @param extension defines the file extension of the file being loaded
  109665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109666. * @param fallback defines the fallback internal texture if any
  109667. * @param isBase64 defines whether the texture is encoded as a base64
  109668. * @param isBuffer defines whether the texture data are stored as a buffer
  109669. * @returns true if the loader can load the specified file
  109670. */
  109671. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109672. /**
  109673. * Transform the url before loading if required.
  109674. * @param rootUrl the url of the texture
  109675. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109676. * @returns the transformed texture
  109677. */
  109678. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109679. /**
  109680. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109681. * @param rootUrl the url of the texture
  109682. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109683. * @returns the fallback texture
  109684. */
  109685. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109686. /**
  109687. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109688. * @param data contains the texture data
  109689. * @param texture defines the BabylonJS internal texture
  109690. * @param createPolynomials will be true if polynomials have been requested
  109691. * @param onLoad defines the callback to trigger once the texture is ready
  109692. * @param onError defines the callback to trigger in case of error
  109693. */
  109694. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109695. /**
  109696. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109697. * @param data contains the texture data
  109698. * @param texture defines the BabylonJS internal texture
  109699. * @param callback defines the method to call once ready to upload
  109700. */
  109701. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109702. }
  109703. }
  109704. declare module BABYLON {
  109705. /** @hidden */
  109706. export var _forceSceneHelpersToBundle: boolean;
  109707. interface Scene {
  109708. /**
  109709. * Creates a default light for the scene.
  109710. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109711. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109712. */
  109713. createDefaultLight(replace?: boolean): void;
  109714. /**
  109715. * Creates a default camera for the scene.
  109716. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109717. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109718. * @param replace has default false, when true replaces the active camera in the scene
  109719. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109720. */
  109721. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109722. /**
  109723. * Creates a default camera and a default light.
  109724. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109725. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109726. * @param replace has the default false, when true replaces the active camera/light in the scene
  109727. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109728. */
  109729. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109730. /**
  109731. * Creates a new sky box
  109732. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109733. * @param environmentTexture defines the texture to use as environment texture
  109734. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109735. * @param scale defines the overall scale of the skybox
  109736. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109737. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109738. * @returns a new mesh holding the sky box
  109739. */
  109740. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109741. /**
  109742. * Creates a new environment
  109743. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109744. * @param options defines the options you can use to configure the environment
  109745. * @returns the new EnvironmentHelper
  109746. */
  109747. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109748. /**
  109749. * Creates a new VREXperienceHelper
  109750. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109751. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109752. * @returns a new VREXperienceHelper
  109753. */
  109754. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109755. /**
  109756. * Creates a new XREXperienceHelper
  109757. * @see http://doc.babylonjs.com/how_to/webxr
  109758. * @returns a promise for a new XREXperienceHelper
  109759. */
  109760. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109761. }
  109762. }
  109763. declare module BABYLON {
  109764. /**
  109765. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109766. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109767. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109768. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109769. */
  109770. export class VideoDome extends TransformNode {
  109771. /**
  109772. * Define the video source as a Monoscopic panoramic 360 video.
  109773. */
  109774. static readonly MODE_MONOSCOPIC: number;
  109775. /**
  109776. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109777. */
  109778. static readonly MODE_TOPBOTTOM: number;
  109779. /**
  109780. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109781. */
  109782. static readonly MODE_SIDEBYSIDE: number;
  109783. private _useDirectMapping;
  109784. /**
  109785. * The video texture being displayed on the sphere
  109786. */
  109787. protected _videoTexture: VideoTexture;
  109788. /**
  109789. * Gets the video texture being displayed on the sphere
  109790. */
  109791. readonly videoTexture: VideoTexture;
  109792. /**
  109793. * The skybox material
  109794. */
  109795. protected _material: BackgroundMaterial;
  109796. /**
  109797. * The surface used for the skybox
  109798. */
  109799. protected _mesh: Mesh;
  109800. /**
  109801. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109802. * Also see the options.resolution property.
  109803. */
  109804. fovMultiplier: number;
  109805. private _videoMode;
  109806. /**
  109807. * Gets or set the current video mode for the video. It can be:
  109808. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109809. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109810. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109811. */
  109812. videoMode: number;
  109813. /**
  109814. * Oberserver used in Stereoscopic VR Mode.
  109815. */
  109816. private _onBeforeCameraRenderObserver;
  109817. /**
  109818. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109819. * @param name Element's name, child elements will append suffixes for their own names.
  109820. * @param urlsOrVideo defines the url(s) or the video element to use
  109821. * @param options An object containing optional or exposed sub element properties
  109822. */
  109823. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109824. resolution?: number;
  109825. clickToPlay?: boolean;
  109826. autoPlay?: boolean;
  109827. loop?: boolean;
  109828. size?: number;
  109829. poster?: string;
  109830. faceForward?: boolean;
  109831. useDirectMapping?: boolean;
  109832. }, scene: Scene);
  109833. private _changeVideoMode;
  109834. /**
  109835. * Releases resources associated with this node.
  109836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109838. */
  109839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109840. }
  109841. }
  109842. declare module BABYLON {
  109843. /**
  109844. * This class can be used to get instrumentation data from a Babylon engine
  109845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109846. */
  109847. export class EngineInstrumentation implements IDisposable {
  109848. /**
  109849. * Define the instrumented engine.
  109850. */
  109851. engine: Engine;
  109852. private _captureGPUFrameTime;
  109853. private _gpuFrameTimeToken;
  109854. private _gpuFrameTime;
  109855. private _captureShaderCompilationTime;
  109856. private _shaderCompilationTime;
  109857. private _onBeginFrameObserver;
  109858. private _onEndFrameObserver;
  109859. private _onBeforeShaderCompilationObserver;
  109860. private _onAfterShaderCompilationObserver;
  109861. /**
  109862. * Gets the perf counter used for GPU frame time
  109863. */
  109864. readonly gpuFrameTimeCounter: PerfCounter;
  109865. /**
  109866. * Gets the GPU frame time capture status
  109867. */
  109868. /**
  109869. * Enable or disable the GPU frame time capture
  109870. */
  109871. captureGPUFrameTime: boolean;
  109872. /**
  109873. * Gets the perf counter used for shader compilation time
  109874. */
  109875. readonly shaderCompilationTimeCounter: PerfCounter;
  109876. /**
  109877. * Gets the shader compilation time capture status
  109878. */
  109879. /**
  109880. * Enable or disable the shader compilation time capture
  109881. */
  109882. captureShaderCompilationTime: boolean;
  109883. /**
  109884. * Instantiates a new engine instrumentation.
  109885. * This class can be used to get instrumentation data from a Babylon engine
  109886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109887. * @param engine Defines the engine to instrument
  109888. */
  109889. constructor(
  109890. /**
  109891. * Define the instrumented engine.
  109892. */
  109893. engine: Engine);
  109894. /**
  109895. * Dispose and release associated resources.
  109896. */
  109897. dispose(): void;
  109898. }
  109899. }
  109900. declare module BABYLON {
  109901. /**
  109902. * This class can be used to get instrumentation data from a Babylon engine
  109903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109904. */
  109905. export class SceneInstrumentation implements IDisposable {
  109906. /**
  109907. * Defines the scene to instrument
  109908. */
  109909. scene: Scene;
  109910. private _captureActiveMeshesEvaluationTime;
  109911. private _activeMeshesEvaluationTime;
  109912. private _captureRenderTargetsRenderTime;
  109913. private _renderTargetsRenderTime;
  109914. private _captureFrameTime;
  109915. private _frameTime;
  109916. private _captureRenderTime;
  109917. private _renderTime;
  109918. private _captureInterFrameTime;
  109919. private _interFrameTime;
  109920. private _captureParticlesRenderTime;
  109921. private _particlesRenderTime;
  109922. private _captureSpritesRenderTime;
  109923. private _spritesRenderTime;
  109924. private _capturePhysicsTime;
  109925. private _physicsTime;
  109926. private _captureAnimationsTime;
  109927. private _animationsTime;
  109928. private _captureCameraRenderTime;
  109929. private _cameraRenderTime;
  109930. private _onBeforeActiveMeshesEvaluationObserver;
  109931. private _onAfterActiveMeshesEvaluationObserver;
  109932. private _onBeforeRenderTargetsRenderObserver;
  109933. private _onAfterRenderTargetsRenderObserver;
  109934. private _onAfterRenderObserver;
  109935. private _onBeforeDrawPhaseObserver;
  109936. private _onAfterDrawPhaseObserver;
  109937. private _onBeforeAnimationsObserver;
  109938. private _onBeforeParticlesRenderingObserver;
  109939. private _onAfterParticlesRenderingObserver;
  109940. private _onBeforeSpritesRenderingObserver;
  109941. private _onAfterSpritesRenderingObserver;
  109942. private _onBeforePhysicsObserver;
  109943. private _onAfterPhysicsObserver;
  109944. private _onAfterAnimationsObserver;
  109945. private _onBeforeCameraRenderObserver;
  109946. private _onAfterCameraRenderObserver;
  109947. /**
  109948. * Gets the perf counter used for active meshes evaluation time
  109949. */
  109950. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109951. /**
  109952. * Gets the active meshes evaluation time capture status
  109953. */
  109954. /**
  109955. * Enable or disable the active meshes evaluation time capture
  109956. */
  109957. captureActiveMeshesEvaluationTime: boolean;
  109958. /**
  109959. * Gets the perf counter used for render targets render time
  109960. */
  109961. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109962. /**
  109963. * Gets the render targets render time capture status
  109964. */
  109965. /**
  109966. * Enable or disable the render targets render time capture
  109967. */
  109968. captureRenderTargetsRenderTime: boolean;
  109969. /**
  109970. * Gets the perf counter used for particles render time
  109971. */
  109972. readonly particlesRenderTimeCounter: PerfCounter;
  109973. /**
  109974. * Gets the particles render time capture status
  109975. */
  109976. /**
  109977. * Enable or disable the particles render time capture
  109978. */
  109979. captureParticlesRenderTime: boolean;
  109980. /**
  109981. * Gets the perf counter used for sprites render time
  109982. */
  109983. readonly spritesRenderTimeCounter: PerfCounter;
  109984. /**
  109985. * Gets the sprites render time capture status
  109986. */
  109987. /**
  109988. * Enable or disable the sprites render time capture
  109989. */
  109990. captureSpritesRenderTime: boolean;
  109991. /**
  109992. * Gets the perf counter used for physics time
  109993. */
  109994. readonly physicsTimeCounter: PerfCounter;
  109995. /**
  109996. * Gets the physics time capture status
  109997. */
  109998. /**
  109999. * Enable or disable the physics time capture
  110000. */
  110001. capturePhysicsTime: boolean;
  110002. /**
  110003. * Gets the perf counter used for animations time
  110004. */
  110005. readonly animationsTimeCounter: PerfCounter;
  110006. /**
  110007. * Gets the animations time capture status
  110008. */
  110009. /**
  110010. * Enable or disable the animations time capture
  110011. */
  110012. captureAnimationsTime: boolean;
  110013. /**
  110014. * Gets the perf counter used for frame time capture
  110015. */
  110016. readonly frameTimeCounter: PerfCounter;
  110017. /**
  110018. * Gets the frame time capture status
  110019. */
  110020. /**
  110021. * Enable or disable the frame time capture
  110022. */
  110023. captureFrameTime: boolean;
  110024. /**
  110025. * Gets the perf counter used for inter-frames time capture
  110026. */
  110027. readonly interFrameTimeCounter: PerfCounter;
  110028. /**
  110029. * Gets the inter-frames time capture status
  110030. */
  110031. /**
  110032. * Enable or disable the inter-frames time capture
  110033. */
  110034. captureInterFrameTime: boolean;
  110035. /**
  110036. * Gets the perf counter used for render time capture
  110037. */
  110038. readonly renderTimeCounter: PerfCounter;
  110039. /**
  110040. * Gets the render time capture status
  110041. */
  110042. /**
  110043. * Enable or disable the render time capture
  110044. */
  110045. captureRenderTime: boolean;
  110046. /**
  110047. * Gets the perf counter used for camera render time capture
  110048. */
  110049. readonly cameraRenderTimeCounter: PerfCounter;
  110050. /**
  110051. * Gets the camera render time capture status
  110052. */
  110053. /**
  110054. * Enable or disable the camera render time capture
  110055. */
  110056. captureCameraRenderTime: boolean;
  110057. /**
  110058. * Gets the perf counter used for draw calls
  110059. */
  110060. readonly drawCallsCounter: PerfCounter;
  110061. /**
  110062. * Instantiates a new scene instrumentation.
  110063. * This class can be used to get instrumentation data from a Babylon engine
  110064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  110065. * @param scene Defines the scene to instrument
  110066. */
  110067. constructor(
  110068. /**
  110069. * Defines the scene to instrument
  110070. */
  110071. scene: Scene);
  110072. /**
  110073. * Dispose and release associated resources.
  110074. */
  110075. dispose(): void;
  110076. }
  110077. }
  110078. declare module BABYLON {
  110079. /** @hidden */
  110080. export var glowMapGenerationPixelShader: {
  110081. name: string;
  110082. shader: string;
  110083. };
  110084. }
  110085. declare module BABYLON {
  110086. /** @hidden */
  110087. export var glowMapGenerationVertexShader: {
  110088. name: string;
  110089. shader: string;
  110090. };
  110091. }
  110092. declare module BABYLON {
  110093. /**
  110094. * Effect layer options. This helps customizing the behaviour
  110095. * of the effect layer.
  110096. */
  110097. export interface IEffectLayerOptions {
  110098. /**
  110099. * Multiplication factor apply to the canvas size to compute the render target size
  110100. * used to generated the objects (the smaller the faster).
  110101. */
  110102. mainTextureRatio: number;
  110103. /**
  110104. * Enforces a fixed size texture to ensure effect stability across devices.
  110105. */
  110106. mainTextureFixedSize?: number;
  110107. /**
  110108. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110109. */
  110110. alphaBlendingMode: number;
  110111. /**
  110112. * The camera attached to the layer.
  110113. */
  110114. camera: Nullable<Camera>;
  110115. /**
  110116. * The rendering group to draw the layer in.
  110117. */
  110118. renderingGroupId: number;
  110119. }
  110120. /**
  110121. * The effect layer Helps adding post process effect blended with the main pass.
  110122. *
  110123. * This can be for instance use to generate glow or higlight effects on the scene.
  110124. *
  110125. * The effect layer class can not be used directly and is intented to inherited from to be
  110126. * customized per effects.
  110127. */
  110128. export abstract class EffectLayer {
  110129. private _vertexBuffers;
  110130. private _indexBuffer;
  110131. private _cachedDefines;
  110132. private _effectLayerMapGenerationEffect;
  110133. private _effectLayerOptions;
  110134. private _mergeEffect;
  110135. protected _scene: Scene;
  110136. protected _engine: Engine;
  110137. protected _maxSize: number;
  110138. protected _mainTextureDesiredSize: ISize;
  110139. protected _mainTexture: RenderTargetTexture;
  110140. protected _shouldRender: boolean;
  110141. protected _postProcesses: PostProcess[];
  110142. protected _textures: BaseTexture[];
  110143. protected _emissiveTextureAndColor: {
  110144. texture: Nullable<BaseTexture>;
  110145. color: Color4;
  110146. };
  110147. /**
  110148. * The name of the layer
  110149. */
  110150. name: string;
  110151. /**
  110152. * The clear color of the texture used to generate the glow map.
  110153. */
  110154. neutralColor: Color4;
  110155. /**
  110156. * Specifies wether the highlight layer is enabled or not.
  110157. */
  110158. isEnabled: boolean;
  110159. /**
  110160. * Gets the camera attached to the layer.
  110161. */
  110162. readonly camera: Nullable<Camera>;
  110163. /**
  110164. * Gets the rendering group id the layer should render in.
  110165. */
  110166. renderingGroupId: number;
  110167. /**
  110168. * An event triggered when the effect layer has been disposed.
  110169. */
  110170. onDisposeObservable: Observable<EffectLayer>;
  110171. /**
  110172. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110173. */
  110174. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110175. /**
  110176. * An event triggered when the generated texture is being merged in the scene.
  110177. */
  110178. onBeforeComposeObservable: Observable<EffectLayer>;
  110179. /**
  110180. * An event triggered when the generated texture has been merged in the scene.
  110181. */
  110182. onAfterComposeObservable: Observable<EffectLayer>;
  110183. /**
  110184. * An event triggered when the efffect layer changes its size.
  110185. */
  110186. onSizeChangedObservable: Observable<EffectLayer>;
  110187. /** @hidden */
  110188. static _SceneComponentInitialization: (scene: Scene) => void;
  110189. /**
  110190. * Instantiates a new effect Layer and references it in the scene.
  110191. * @param name The name of the layer
  110192. * @param scene The scene to use the layer in
  110193. */
  110194. constructor(
  110195. /** The Friendly of the effect in the scene */
  110196. name: string, scene: Scene);
  110197. /**
  110198. * Get the effect name of the layer.
  110199. * @return The effect name
  110200. */
  110201. abstract getEffectName(): string;
  110202. /**
  110203. * Checks for the readiness of the element composing the layer.
  110204. * @param subMesh the mesh to check for
  110205. * @param useInstances specify wether or not to use instances to render the mesh
  110206. * @return true if ready otherwise, false
  110207. */
  110208. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110209. /**
  110210. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110211. * @returns true if the effect requires stencil during the main canvas render pass.
  110212. */
  110213. abstract needStencil(): boolean;
  110214. /**
  110215. * Create the merge effect. This is the shader use to blit the information back
  110216. * to the main canvas at the end of the scene rendering.
  110217. * @returns The effect containing the shader used to merge the effect on the main canvas
  110218. */
  110219. protected abstract _createMergeEffect(): Effect;
  110220. /**
  110221. * Creates the render target textures and post processes used in the effect layer.
  110222. */
  110223. protected abstract _createTextureAndPostProcesses(): void;
  110224. /**
  110225. * Implementation specific of rendering the generating effect on the main canvas.
  110226. * @param effect The effect used to render through
  110227. */
  110228. protected abstract _internalRender(effect: Effect): void;
  110229. /**
  110230. * Sets the required values for both the emissive texture and and the main color.
  110231. */
  110232. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110233. /**
  110234. * Free any resources and references associated to a mesh.
  110235. * Internal use
  110236. * @param mesh The mesh to free.
  110237. */
  110238. abstract _disposeMesh(mesh: Mesh): void;
  110239. /**
  110240. * Serializes this layer (Glow or Highlight for example)
  110241. * @returns a serialized layer object
  110242. */
  110243. abstract serialize?(): any;
  110244. /**
  110245. * Initializes the effect layer with the required options.
  110246. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110247. */
  110248. protected _init(options: Partial<IEffectLayerOptions>): void;
  110249. /**
  110250. * Generates the index buffer of the full screen quad blending to the main canvas.
  110251. */
  110252. private _generateIndexBuffer;
  110253. /**
  110254. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110255. */
  110256. private _generateVertexBuffer;
  110257. /**
  110258. * Sets the main texture desired size which is the closest power of two
  110259. * of the engine canvas size.
  110260. */
  110261. private _setMainTextureSize;
  110262. /**
  110263. * Creates the main texture for the effect layer.
  110264. */
  110265. protected _createMainTexture(): void;
  110266. /**
  110267. * Adds specific effects defines.
  110268. * @param defines The defines to add specifics to.
  110269. */
  110270. protected _addCustomEffectDefines(defines: string[]): void;
  110271. /**
  110272. * Checks for the readiness of the element composing the layer.
  110273. * @param subMesh the mesh to check for
  110274. * @param useInstances specify wether or not to use instances to render the mesh
  110275. * @param emissiveTexture the associated emissive texture used to generate the glow
  110276. * @return true if ready otherwise, false
  110277. */
  110278. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110279. /**
  110280. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110281. */
  110282. render(): void;
  110283. /**
  110284. * Determine if a given mesh will be used in the current effect.
  110285. * @param mesh mesh to test
  110286. * @returns true if the mesh will be used
  110287. */
  110288. hasMesh(mesh: AbstractMesh): boolean;
  110289. /**
  110290. * Returns true if the layer contains information to display, otherwise false.
  110291. * @returns true if the glow layer should be rendered
  110292. */
  110293. shouldRender(): boolean;
  110294. /**
  110295. * Returns true if the mesh should render, otherwise false.
  110296. * @param mesh The mesh to render
  110297. * @returns true if it should render otherwise false
  110298. */
  110299. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110300. /**
  110301. * Returns true if the mesh can be rendered, otherwise false.
  110302. * @param mesh The mesh to render
  110303. * @param material The material used on the mesh
  110304. * @returns true if it can be rendered otherwise false
  110305. */
  110306. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110307. /**
  110308. * Returns true if the mesh should render, otherwise false.
  110309. * @param mesh The mesh to render
  110310. * @returns true if it should render otherwise false
  110311. */
  110312. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110313. /**
  110314. * Renders the submesh passed in parameter to the generation map.
  110315. */
  110316. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110317. /**
  110318. * Rebuild the required buffers.
  110319. * @hidden Internal use only.
  110320. */
  110321. _rebuild(): void;
  110322. /**
  110323. * Dispose only the render target textures and post process.
  110324. */
  110325. private _disposeTextureAndPostProcesses;
  110326. /**
  110327. * Dispose the highlight layer and free resources.
  110328. */
  110329. dispose(): void;
  110330. /**
  110331. * Gets the class name of the effect layer
  110332. * @returns the string with the class name of the effect layer
  110333. */
  110334. getClassName(): string;
  110335. /**
  110336. * Creates an effect layer from parsed effect layer data
  110337. * @param parsedEffectLayer defines effect layer data
  110338. * @param scene defines the current scene
  110339. * @param rootUrl defines the root URL containing the effect layer information
  110340. * @returns a parsed effect Layer
  110341. */
  110342. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110343. }
  110344. }
  110345. declare module BABYLON {
  110346. interface AbstractScene {
  110347. /**
  110348. * The list of effect layers (highlights/glow) added to the scene
  110349. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110350. * @see http://doc.babylonjs.com/how_to/glow_layer
  110351. */
  110352. effectLayers: Array<EffectLayer>;
  110353. /**
  110354. * Removes the given effect layer from this scene.
  110355. * @param toRemove defines the effect layer to remove
  110356. * @returns the index of the removed effect layer
  110357. */
  110358. removeEffectLayer(toRemove: EffectLayer): number;
  110359. /**
  110360. * Adds the given effect layer to this scene
  110361. * @param newEffectLayer defines the effect layer to add
  110362. */
  110363. addEffectLayer(newEffectLayer: EffectLayer): void;
  110364. }
  110365. /**
  110366. * Defines the layer scene component responsible to manage any effect layers
  110367. * in a given scene.
  110368. */
  110369. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110370. /**
  110371. * The component name helpfull to identify the component in the list of scene components.
  110372. */
  110373. readonly name: string;
  110374. /**
  110375. * The scene the component belongs to.
  110376. */
  110377. scene: Scene;
  110378. private _engine;
  110379. private _renderEffects;
  110380. private _needStencil;
  110381. private _previousStencilState;
  110382. /**
  110383. * Creates a new instance of the component for the given scene
  110384. * @param scene Defines the scene to register the component in
  110385. */
  110386. constructor(scene: Scene);
  110387. /**
  110388. * Registers the component in a given scene
  110389. */
  110390. register(): void;
  110391. /**
  110392. * Rebuilds the elements related to this component in case of
  110393. * context lost for instance.
  110394. */
  110395. rebuild(): void;
  110396. /**
  110397. * Serializes the component data to the specified json object
  110398. * @param serializationObject The object to serialize to
  110399. */
  110400. serialize(serializationObject: any): void;
  110401. /**
  110402. * Adds all the elements from the container to the scene
  110403. * @param container the container holding the elements
  110404. */
  110405. addFromContainer(container: AbstractScene): void;
  110406. /**
  110407. * Removes all the elements in the container from the scene
  110408. * @param container contains the elements to remove
  110409. * @param dispose if the removed element should be disposed (default: false)
  110410. */
  110411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110412. /**
  110413. * Disposes the component and the associated ressources.
  110414. */
  110415. dispose(): void;
  110416. private _isReadyForMesh;
  110417. private _renderMainTexture;
  110418. private _setStencil;
  110419. private _setStencilBack;
  110420. private _draw;
  110421. private _drawCamera;
  110422. private _drawRenderingGroup;
  110423. }
  110424. }
  110425. declare module BABYLON {
  110426. /** @hidden */
  110427. export var glowMapMergePixelShader: {
  110428. name: string;
  110429. shader: string;
  110430. };
  110431. }
  110432. declare module BABYLON {
  110433. /** @hidden */
  110434. export var glowMapMergeVertexShader: {
  110435. name: string;
  110436. shader: string;
  110437. };
  110438. }
  110439. declare module BABYLON {
  110440. interface AbstractScene {
  110441. /**
  110442. * Return a the first highlight layer of the scene with a given name.
  110443. * @param name The name of the highlight layer to look for.
  110444. * @return The highlight layer if found otherwise null.
  110445. */
  110446. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110447. }
  110448. /**
  110449. * Glow layer options. This helps customizing the behaviour
  110450. * of the glow layer.
  110451. */
  110452. export interface IGlowLayerOptions {
  110453. /**
  110454. * Multiplication factor apply to the canvas size to compute the render target size
  110455. * used to generated the glowing objects (the smaller the faster).
  110456. */
  110457. mainTextureRatio: number;
  110458. /**
  110459. * Enforces a fixed size texture to ensure resize independant blur.
  110460. */
  110461. mainTextureFixedSize?: number;
  110462. /**
  110463. * How big is the kernel of the blur texture.
  110464. */
  110465. blurKernelSize: number;
  110466. /**
  110467. * The camera attached to the layer.
  110468. */
  110469. camera: Nullable<Camera>;
  110470. /**
  110471. * Enable MSAA by chosing the number of samples.
  110472. */
  110473. mainTextureSamples?: number;
  110474. /**
  110475. * The rendering group to draw the layer in.
  110476. */
  110477. renderingGroupId: number;
  110478. }
  110479. /**
  110480. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110481. *
  110482. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110483. * glowy meshes to your scene.
  110484. *
  110485. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110486. */
  110487. export class GlowLayer extends EffectLayer {
  110488. /**
  110489. * Effect Name of the layer.
  110490. */
  110491. static readonly EffectName: string;
  110492. /**
  110493. * The default blur kernel size used for the glow.
  110494. */
  110495. static DefaultBlurKernelSize: number;
  110496. /**
  110497. * The default texture size ratio used for the glow.
  110498. */
  110499. static DefaultTextureRatio: number;
  110500. /**
  110501. * Sets the kernel size of the blur.
  110502. */
  110503. /**
  110504. * Gets the kernel size of the blur.
  110505. */
  110506. blurKernelSize: number;
  110507. /**
  110508. * Sets the glow intensity.
  110509. */
  110510. /**
  110511. * Gets the glow intensity.
  110512. */
  110513. intensity: number;
  110514. private _options;
  110515. private _intensity;
  110516. private _horizontalBlurPostprocess1;
  110517. private _verticalBlurPostprocess1;
  110518. private _horizontalBlurPostprocess2;
  110519. private _verticalBlurPostprocess2;
  110520. private _blurTexture1;
  110521. private _blurTexture2;
  110522. private _postProcesses1;
  110523. private _postProcesses2;
  110524. private _includedOnlyMeshes;
  110525. private _excludedMeshes;
  110526. /**
  110527. * Callback used to let the user override the color selection on a per mesh basis
  110528. */
  110529. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110530. /**
  110531. * Callback used to let the user override the texture selection on a per mesh basis
  110532. */
  110533. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110534. /**
  110535. * Instantiates a new glow Layer and references it to the scene.
  110536. * @param name The name of the layer
  110537. * @param scene The scene to use the layer in
  110538. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110539. */
  110540. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110541. /**
  110542. * Get the effect name of the layer.
  110543. * @return The effect name
  110544. */
  110545. getEffectName(): string;
  110546. /**
  110547. * Create the merge effect. This is the shader use to blit the information back
  110548. * to the main canvas at the end of the scene rendering.
  110549. */
  110550. protected _createMergeEffect(): Effect;
  110551. /**
  110552. * Creates the render target textures and post processes used in the glow layer.
  110553. */
  110554. protected _createTextureAndPostProcesses(): void;
  110555. /**
  110556. * Checks for the readiness of the element composing the layer.
  110557. * @param subMesh the mesh to check for
  110558. * @param useInstances specify wether or not to use instances to render the mesh
  110559. * @param emissiveTexture the associated emissive texture used to generate the glow
  110560. * @return true if ready otherwise, false
  110561. */
  110562. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110563. /**
  110564. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110565. */
  110566. needStencil(): boolean;
  110567. /**
  110568. * Returns true if the mesh can be rendered, otherwise false.
  110569. * @param mesh The mesh to render
  110570. * @param material The material used on the mesh
  110571. * @returns true if it can be rendered otherwise false
  110572. */
  110573. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110574. /**
  110575. * Implementation specific of rendering the generating effect on the main canvas.
  110576. * @param effect The effect used to render through
  110577. */
  110578. protected _internalRender(effect: Effect): void;
  110579. /**
  110580. * Sets the required values for both the emissive texture and and the main color.
  110581. */
  110582. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110583. /**
  110584. * Returns true if the mesh should render, otherwise false.
  110585. * @param mesh The mesh to render
  110586. * @returns true if it should render otherwise false
  110587. */
  110588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110589. /**
  110590. * Adds specific effects defines.
  110591. * @param defines The defines to add specifics to.
  110592. */
  110593. protected _addCustomEffectDefines(defines: string[]): void;
  110594. /**
  110595. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110596. * @param mesh The mesh to exclude from the glow layer
  110597. */
  110598. addExcludedMesh(mesh: Mesh): void;
  110599. /**
  110600. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110601. * @param mesh The mesh to remove
  110602. */
  110603. removeExcludedMesh(mesh: Mesh): void;
  110604. /**
  110605. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110606. * @param mesh The mesh to include in the glow layer
  110607. */
  110608. addIncludedOnlyMesh(mesh: Mesh): void;
  110609. /**
  110610. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110611. * @param mesh The mesh to remove
  110612. */
  110613. removeIncludedOnlyMesh(mesh: Mesh): void;
  110614. /**
  110615. * Determine if a given mesh will be used in the glow layer
  110616. * @param mesh The mesh to test
  110617. * @returns true if the mesh will be highlighted by the current glow layer
  110618. */
  110619. hasMesh(mesh: AbstractMesh): boolean;
  110620. /**
  110621. * Free any resources and references associated to a mesh.
  110622. * Internal use
  110623. * @param mesh The mesh to free.
  110624. * @hidden
  110625. */
  110626. _disposeMesh(mesh: Mesh): void;
  110627. /**
  110628. * Gets the class name of the effect layer
  110629. * @returns the string with the class name of the effect layer
  110630. */
  110631. getClassName(): string;
  110632. /**
  110633. * Serializes this glow layer
  110634. * @returns a serialized glow layer object
  110635. */
  110636. serialize(): any;
  110637. /**
  110638. * Creates a Glow Layer from parsed glow layer data
  110639. * @param parsedGlowLayer defines glow layer data
  110640. * @param scene defines the current scene
  110641. * @param rootUrl defines the root URL containing the glow layer information
  110642. * @returns a parsed Glow Layer
  110643. */
  110644. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110645. }
  110646. }
  110647. declare module BABYLON {
  110648. /** @hidden */
  110649. export var glowBlurPostProcessPixelShader: {
  110650. name: string;
  110651. shader: string;
  110652. };
  110653. }
  110654. declare module BABYLON {
  110655. interface AbstractScene {
  110656. /**
  110657. * Return a the first highlight layer of the scene with a given name.
  110658. * @param name The name of the highlight layer to look for.
  110659. * @return The highlight layer if found otherwise null.
  110660. */
  110661. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110662. }
  110663. /**
  110664. * Highlight layer options. This helps customizing the behaviour
  110665. * of the highlight layer.
  110666. */
  110667. export interface IHighlightLayerOptions {
  110668. /**
  110669. * Multiplication factor apply to the canvas size to compute the render target size
  110670. * used to generated the glowing objects (the smaller the faster).
  110671. */
  110672. mainTextureRatio: number;
  110673. /**
  110674. * Enforces a fixed size texture to ensure resize independant blur.
  110675. */
  110676. mainTextureFixedSize?: number;
  110677. /**
  110678. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110679. * of the picture to blur (the smaller the faster).
  110680. */
  110681. blurTextureSizeRatio: number;
  110682. /**
  110683. * How big in texel of the blur texture is the vertical blur.
  110684. */
  110685. blurVerticalSize: number;
  110686. /**
  110687. * How big in texel of the blur texture is the horizontal blur.
  110688. */
  110689. blurHorizontalSize: number;
  110690. /**
  110691. * Alpha blending mode used to apply the blur. Default is combine.
  110692. */
  110693. alphaBlendingMode: number;
  110694. /**
  110695. * The camera attached to the layer.
  110696. */
  110697. camera: Nullable<Camera>;
  110698. /**
  110699. * Should we display highlight as a solid stroke?
  110700. */
  110701. isStroke?: boolean;
  110702. /**
  110703. * The rendering group to draw the layer in.
  110704. */
  110705. renderingGroupId: number;
  110706. }
  110707. /**
  110708. * The highlight layer Helps adding a glow effect around a mesh.
  110709. *
  110710. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110711. * glowy meshes to your scene.
  110712. *
  110713. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110714. */
  110715. export class HighlightLayer extends EffectLayer {
  110716. name: string;
  110717. /**
  110718. * Effect Name of the highlight layer.
  110719. */
  110720. static readonly EffectName: string;
  110721. /**
  110722. * The neutral color used during the preparation of the glow effect.
  110723. * This is black by default as the blend operation is a blend operation.
  110724. */
  110725. static NeutralColor: Color4;
  110726. /**
  110727. * Stencil value used for glowing meshes.
  110728. */
  110729. static GlowingMeshStencilReference: number;
  110730. /**
  110731. * Stencil value used for the other meshes in the scene.
  110732. */
  110733. static NormalMeshStencilReference: number;
  110734. /**
  110735. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110736. */
  110737. innerGlow: boolean;
  110738. /**
  110739. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110740. */
  110741. outerGlow: boolean;
  110742. /**
  110743. * Specifies the horizontal size of the blur.
  110744. */
  110745. /**
  110746. * Gets the horizontal size of the blur.
  110747. */
  110748. blurHorizontalSize: number;
  110749. /**
  110750. * Specifies the vertical size of the blur.
  110751. */
  110752. /**
  110753. * Gets the vertical size of the blur.
  110754. */
  110755. blurVerticalSize: number;
  110756. /**
  110757. * An event triggered when the highlight layer is being blurred.
  110758. */
  110759. onBeforeBlurObservable: Observable<HighlightLayer>;
  110760. /**
  110761. * An event triggered when the highlight layer has been blurred.
  110762. */
  110763. onAfterBlurObservable: Observable<HighlightLayer>;
  110764. private _instanceGlowingMeshStencilReference;
  110765. private _options;
  110766. private _downSamplePostprocess;
  110767. private _horizontalBlurPostprocess;
  110768. private _verticalBlurPostprocess;
  110769. private _blurTexture;
  110770. private _meshes;
  110771. private _excludedMeshes;
  110772. /**
  110773. * Instantiates a new highlight Layer and references it to the scene..
  110774. * @param name The name of the layer
  110775. * @param scene The scene to use the layer in
  110776. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110777. */
  110778. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110779. /**
  110780. * Get the effect name of the layer.
  110781. * @return The effect name
  110782. */
  110783. getEffectName(): string;
  110784. /**
  110785. * Create the merge effect. This is the shader use to blit the information back
  110786. * to the main canvas at the end of the scene rendering.
  110787. */
  110788. protected _createMergeEffect(): Effect;
  110789. /**
  110790. * Creates the render target textures and post processes used in the highlight layer.
  110791. */
  110792. protected _createTextureAndPostProcesses(): void;
  110793. /**
  110794. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110795. */
  110796. needStencil(): boolean;
  110797. /**
  110798. * Checks for the readiness of the element composing the layer.
  110799. * @param subMesh the mesh to check for
  110800. * @param useInstances specify wether or not to use instances to render the mesh
  110801. * @param emissiveTexture the associated emissive texture used to generate the glow
  110802. * @return true if ready otherwise, false
  110803. */
  110804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110805. /**
  110806. * Implementation specific of rendering the generating effect on the main canvas.
  110807. * @param effect The effect used to render through
  110808. */
  110809. protected _internalRender(effect: Effect): void;
  110810. /**
  110811. * Returns true if the layer contains information to display, otherwise false.
  110812. */
  110813. shouldRender(): boolean;
  110814. /**
  110815. * Returns true if the mesh should render, otherwise false.
  110816. * @param mesh The mesh to render
  110817. * @returns true if it should render otherwise false
  110818. */
  110819. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110820. /**
  110821. * Sets the required values for both the emissive texture and and the main color.
  110822. */
  110823. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110824. /**
  110825. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110826. * @param mesh The mesh to exclude from the highlight layer
  110827. */
  110828. addExcludedMesh(mesh: Mesh): void;
  110829. /**
  110830. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110831. * @param mesh The mesh to highlight
  110832. */
  110833. removeExcludedMesh(mesh: Mesh): void;
  110834. /**
  110835. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110836. * @param mesh mesh to test
  110837. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110838. */
  110839. hasMesh(mesh: AbstractMesh): boolean;
  110840. /**
  110841. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110842. * @param mesh The mesh to highlight
  110843. * @param color The color of the highlight
  110844. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110845. */
  110846. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110847. /**
  110848. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110849. * @param mesh The mesh to highlight
  110850. */
  110851. removeMesh(mesh: Mesh): void;
  110852. /**
  110853. * Force the stencil to the normal expected value for none glowing parts
  110854. */
  110855. private _defaultStencilReference;
  110856. /**
  110857. * Free any resources and references associated to a mesh.
  110858. * Internal use
  110859. * @param mesh The mesh to free.
  110860. * @hidden
  110861. */
  110862. _disposeMesh(mesh: Mesh): void;
  110863. /**
  110864. * Dispose the highlight layer and free resources.
  110865. */
  110866. dispose(): void;
  110867. /**
  110868. * Gets the class name of the effect layer
  110869. * @returns the string with the class name of the effect layer
  110870. */
  110871. getClassName(): string;
  110872. /**
  110873. * Serializes this Highlight layer
  110874. * @returns a serialized Highlight layer object
  110875. */
  110876. serialize(): any;
  110877. /**
  110878. * Creates a Highlight layer from parsed Highlight layer data
  110879. * @param parsedHightlightLayer defines the Highlight layer data
  110880. * @param scene defines the current scene
  110881. * @param rootUrl defines the root URL containing the Highlight layer information
  110882. * @returns a parsed Highlight layer
  110883. */
  110884. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110885. }
  110886. }
  110887. declare module BABYLON {
  110888. interface AbstractScene {
  110889. /**
  110890. * The list of layers (background and foreground) of the scene
  110891. */
  110892. layers: Array<Layer>;
  110893. }
  110894. /**
  110895. * Defines the layer scene component responsible to manage any layers
  110896. * in a given scene.
  110897. */
  110898. export class LayerSceneComponent implements ISceneComponent {
  110899. /**
  110900. * The component name helpfull to identify the component in the list of scene components.
  110901. */
  110902. readonly name: string;
  110903. /**
  110904. * The scene the component belongs to.
  110905. */
  110906. scene: Scene;
  110907. private _engine;
  110908. /**
  110909. * Creates a new instance of the component for the given scene
  110910. * @param scene Defines the scene to register the component in
  110911. */
  110912. constructor(scene: Scene);
  110913. /**
  110914. * Registers the component in a given scene
  110915. */
  110916. register(): void;
  110917. /**
  110918. * Rebuilds the elements related to this component in case of
  110919. * context lost for instance.
  110920. */
  110921. rebuild(): void;
  110922. /**
  110923. * Disposes the component and the associated ressources.
  110924. */
  110925. dispose(): void;
  110926. private _draw;
  110927. private _drawCameraPredicate;
  110928. private _drawCameraBackground;
  110929. private _drawCameraForeground;
  110930. private _drawRenderTargetPredicate;
  110931. private _drawRenderTargetBackground;
  110932. private _drawRenderTargetForeground;
  110933. /**
  110934. * Adds all the elements from the container to the scene
  110935. * @param container the container holding the elements
  110936. */
  110937. addFromContainer(container: AbstractScene): void;
  110938. /**
  110939. * Removes all the elements in the container from the scene
  110940. * @param container contains the elements to remove
  110941. * @param dispose if the removed element should be disposed (default: false)
  110942. */
  110943. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110944. }
  110945. }
  110946. declare module BABYLON {
  110947. /** @hidden */
  110948. export var layerPixelShader: {
  110949. name: string;
  110950. shader: string;
  110951. };
  110952. }
  110953. declare module BABYLON {
  110954. /** @hidden */
  110955. export var layerVertexShader: {
  110956. name: string;
  110957. shader: string;
  110958. };
  110959. }
  110960. declare module BABYLON {
  110961. /**
  110962. * This represents a full screen 2d layer.
  110963. * This can be useful to display a picture in the background of your scene for instance.
  110964. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110965. */
  110966. export class Layer {
  110967. /**
  110968. * Define the name of the layer.
  110969. */
  110970. name: string;
  110971. /**
  110972. * Define the texture the layer should display.
  110973. */
  110974. texture: Nullable<Texture>;
  110975. /**
  110976. * Is the layer in background or foreground.
  110977. */
  110978. isBackground: boolean;
  110979. /**
  110980. * Define the color of the layer (instead of texture).
  110981. */
  110982. color: Color4;
  110983. /**
  110984. * Define the scale of the layer in order to zoom in out of the texture.
  110985. */
  110986. scale: Vector2;
  110987. /**
  110988. * Define an offset for the layer in order to shift the texture.
  110989. */
  110990. offset: Vector2;
  110991. /**
  110992. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110993. */
  110994. alphaBlendingMode: number;
  110995. /**
  110996. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110997. * Alpha test will not mix with the background color in case of transparency.
  110998. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110999. */
  111000. alphaTest: boolean;
  111001. /**
  111002. * Define a mask to restrict the layer to only some of the scene cameras.
  111003. */
  111004. layerMask: number;
  111005. /**
  111006. * Define the list of render target the layer is visible into.
  111007. */
  111008. renderTargetTextures: RenderTargetTexture[];
  111009. /**
  111010. * Define if the layer is only used in renderTarget or if it also
  111011. * renders in the main frame buffer of the canvas.
  111012. */
  111013. renderOnlyInRenderTargetTextures: boolean;
  111014. private _scene;
  111015. private _vertexBuffers;
  111016. private _indexBuffer;
  111017. private _effect;
  111018. private _alphaTestEffect;
  111019. /**
  111020. * An event triggered when the layer is disposed.
  111021. */
  111022. onDisposeObservable: Observable<Layer>;
  111023. private _onDisposeObserver;
  111024. /**
  111025. * Back compatibility with callback before the onDisposeObservable existed.
  111026. * The set callback will be triggered when the layer has been disposed.
  111027. */
  111028. onDispose: () => void;
  111029. /**
  111030. * An event triggered before rendering the scene
  111031. */
  111032. onBeforeRenderObservable: Observable<Layer>;
  111033. private _onBeforeRenderObserver;
  111034. /**
  111035. * Back compatibility with callback before the onBeforeRenderObservable existed.
  111036. * The set callback will be triggered just before rendering the layer.
  111037. */
  111038. onBeforeRender: () => void;
  111039. /**
  111040. * An event triggered after rendering the scene
  111041. */
  111042. onAfterRenderObservable: Observable<Layer>;
  111043. private _onAfterRenderObserver;
  111044. /**
  111045. * Back compatibility with callback before the onAfterRenderObservable existed.
  111046. * The set callback will be triggered just after rendering the layer.
  111047. */
  111048. onAfterRender: () => void;
  111049. /**
  111050. * Instantiates a new layer.
  111051. * This represents a full screen 2d layer.
  111052. * This can be useful to display a picture in the background of your scene for instance.
  111053. * @see https://www.babylonjs-playground.com/#08A2BS#1
  111054. * @param name Define the name of the layer in the scene
  111055. * @param imgUrl Define the url of the texture to display in the layer
  111056. * @param scene Define the scene the layer belongs to
  111057. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  111058. * @param color Defines a color for the layer
  111059. */
  111060. constructor(
  111061. /**
  111062. * Define the name of the layer.
  111063. */
  111064. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  111065. private _createIndexBuffer;
  111066. /** @hidden */
  111067. _rebuild(): void;
  111068. /**
  111069. * Renders the layer in the scene.
  111070. */
  111071. render(): void;
  111072. /**
  111073. * Disposes and releases the associated ressources.
  111074. */
  111075. dispose(): void;
  111076. }
  111077. }
  111078. declare module BABYLON {
  111079. /** @hidden */
  111080. export var lensFlarePixelShader: {
  111081. name: string;
  111082. shader: string;
  111083. };
  111084. }
  111085. declare module BABYLON {
  111086. /** @hidden */
  111087. export var lensFlareVertexShader: {
  111088. name: string;
  111089. shader: string;
  111090. };
  111091. }
  111092. declare module BABYLON {
  111093. /**
  111094. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111095. * It is usually composed of several `lensFlare`.
  111096. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111097. */
  111098. export class LensFlareSystem {
  111099. /**
  111100. * Define the name of the lens flare system
  111101. */
  111102. name: string;
  111103. /**
  111104. * List of lens flares used in this system.
  111105. */
  111106. lensFlares: LensFlare[];
  111107. /**
  111108. * Define a limit from the border the lens flare can be visible.
  111109. */
  111110. borderLimit: number;
  111111. /**
  111112. * Define a viewport border we do not want to see the lens flare in.
  111113. */
  111114. viewportBorder: number;
  111115. /**
  111116. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111117. */
  111118. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111119. /**
  111120. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111121. */
  111122. layerMask: number;
  111123. /**
  111124. * Define the id of the lens flare system in the scene.
  111125. * (equal to name by default)
  111126. */
  111127. id: string;
  111128. private _scene;
  111129. private _emitter;
  111130. private _vertexBuffers;
  111131. private _indexBuffer;
  111132. private _effect;
  111133. private _positionX;
  111134. private _positionY;
  111135. private _isEnabled;
  111136. /** @hidden */
  111137. static _SceneComponentInitialization: (scene: Scene) => void;
  111138. /**
  111139. * Instantiates a lens flare system.
  111140. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111141. * It is usually composed of several `lensFlare`.
  111142. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111143. * @param name Define the name of the lens flare system in the scene
  111144. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111145. * @param scene Define the scene the lens flare system belongs to
  111146. */
  111147. constructor(
  111148. /**
  111149. * Define the name of the lens flare system
  111150. */
  111151. name: string, emitter: any, scene: Scene);
  111152. /**
  111153. * Define if the lens flare system is enabled.
  111154. */
  111155. isEnabled: boolean;
  111156. /**
  111157. * Get the scene the effects belongs to.
  111158. * @returns the scene holding the lens flare system
  111159. */
  111160. getScene(): Scene;
  111161. /**
  111162. * Get the emitter of the lens flare system.
  111163. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111164. * @returns the emitter of the lens flare system
  111165. */
  111166. getEmitter(): any;
  111167. /**
  111168. * Set the emitter of the lens flare system.
  111169. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111170. * @param newEmitter Define the new emitter of the system
  111171. */
  111172. setEmitter(newEmitter: any): void;
  111173. /**
  111174. * Get the lens flare system emitter position.
  111175. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111176. * @returns the position
  111177. */
  111178. getEmitterPosition(): Vector3;
  111179. /**
  111180. * @hidden
  111181. */
  111182. computeEffectivePosition(globalViewport: Viewport): boolean;
  111183. /** @hidden */
  111184. _isVisible(): boolean;
  111185. /**
  111186. * @hidden
  111187. */
  111188. render(): boolean;
  111189. /**
  111190. * Dispose and release the lens flare with its associated resources.
  111191. */
  111192. dispose(): void;
  111193. /**
  111194. * Parse a lens flare system from a JSON repressentation
  111195. * @param parsedLensFlareSystem Define the JSON to parse
  111196. * @param scene Define the scene the parsed system should be instantiated in
  111197. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111198. * @returns the parsed system
  111199. */
  111200. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111201. /**
  111202. * Serialize the current Lens Flare System into a JSON representation.
  111203. * @returns the serialized JSON
  111204. */
  111205. serialize(): any;
  111206. }
  111207. }
  111208. declare module BABYLON {
  111209. /**
  111210. * This represents one of the lens effect in a `lensFlareSystem`.
  111211. * It controls one of the indiviual texture used in the effect.
  111212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111213. */
  111214. export class LensFlare {
  111215. /**
  111216. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111217. */
  111218. size: number;
  111219. /**
  111220. * 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.
  111221. */
  111222. position: number;
  111223. /**
  111224. * Define the lens color.
  111225. */
  111226. color: Color3;
  111227. /**
  111228. * Define the lens texture.
  111229. */
  111230. texture: Nullable<Texture>;
  111231. /**
  111232. * Define the alpha mode to render this particular lens.
  111233. */
  111234. alphaMode: number;
  111235. private _system;
  111236. /**
  111237. * Creates a new Lens Flare.
  111238. * This represents one of the lens effect in a `lensFlareSystem`.
  111239. * It controls one of the indiviual texture used in the effect.
  111240. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111241. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111242. * @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.
  111243. * @param color Define the lens color
  111244. * @param imgUrl Define the lens texture url
  111245. * @param system Define the `lensFlareSystem` this flare is part of
  111246. * @returns The newly created Lens Flare
  111247. */
  111248. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111249. /**
  111250. * Instantiates a new Lens Flare.
  111251. * This represents one of the lens effect in a `lensFlareSystem`.
  111252. * It controls one of the indiviual texture used in the effect.
  111253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111254. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111255. * @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.
  111256. * @param color Define the lens color
  111257. * @param imgUrl Define the lens texture url
  111258. * @param system Define the `lensFlareSystem` this flare is part of
  111259. */
  111260. constructor(
  111261. /**
  111262. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111263. */
  111264. size: number,
  111265. /**
  111266. * 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.
  111267. */
  111268. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111269. /**
  111270. * Dispose and release the lens flare with its associated resources.
  111271. */
  111272. dispose(): void;
  111273. }
  111274. }
  111275. declare module BABYLON {
  111276. interface AbstractScene {
  111277. /**
  111278. * The list of lens flare system added to the scene
  111279. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111280. */
  111281. lensFlareSystems: Array<LensFlareSystem>;
  111282. /**
  111283. * Removes the given lens flare system from this scene.
  111284. * @param toRemove The lens flare system to remove
  111285. * @returns The index of the removed lens flare system
  111286. */
  111287. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111288. /**
  111289. * Adds the given lens flare system to this scene
  111290. * @param newLensFlareSystem The lens flare system to add
  111291. */
  111292. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111293. /**
  111294. * Gets a lens flare system using its name
  111295. * @param name defines the name to look for
  111296. * @returns the lens flare system or null if not found
  111297. */
  111298. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111299. /**
  111300. * Gets a lens flare system using its id
  111301. * @param id defines the id to look for
  111302. * @returns the lens flare system or null if not found
  111303. */
  111304. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111305. }
  111306. /**
  111307. * Defines the lens flare scene component responsible to manage any lens flares
  111308. * in a given scene.
  111309. */
  111310. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111311. /**
  111312. * The component name helpfull to identify the component in the list of scene components.
  111313. */
  111314. readonly name: string;
  111315. /**
  111316. * The scene the component belongs to.
  111317. */
  111318. scene: Scene;
  111319. /**
  111320. * Creates a new instance of the component for the given scene
  111321. * @param scene Defines the scene to register the component in
  111322. */
  111323. constructor(scene: Scene);
  111324. /**
  111325. * Registers the component in a given scene
  111326. */
  111327. register(): void;
  111328. /**
  111329. * Rebuilds the elements related to this component in case of
  111330. * context lost for instance.
  111331. */
  111332. rebuild(): void;
  111333. /**
  111334. * Adds all the elements from the container to the scene
  111335. * @param container the container holding the elements
  111336. */
  111337. addFromContainer(container: AbstractScene): void;
  111338. /**
  111339. * Removes all the elements in the container from the scene
  111340. * @param container contains the elements to remove
  111341. * @param dispose if the removed element should be disposed (default: false)
  111342. */
  111343. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111344. /**
  111345. * Serializes the component data to the specified json object
  111346. * @param serializationObject The object to serialize to
  111347. */
  111348. serialize(serializationObject: any): void;
  111349. /**
  111350. * Disposes the component and the associated ressources.
  111351. */
  111352. dispose(): void;
  111353. private _draw;
  111354. }
  111355. }
  111356. declare module BABYLON {
  111357. /**
  111358. * Defines the shadow generator component responsible to manage any shadow generators
  111359. * in a given scene.
  111360. */
  111361. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111362. /**
  111363. * The component name helpfull to identify the component in the list of scene components.
  111364. */
  111365. readonly name: string;
  111366. /**
  111367. * The scene the component belongs to.
  111368. */
  111369. scene: Scene;
  111370. /**
  111371. * Creates a new instance of the component for the given scene
  111372. * @param scene Defines the scene to register the component in
  111373. */
  111374. constructor(scene: Scene);
  111375. /**
  111376. * Registers the component in a given scene
  111377. */
  111378. register(): void;
  111379. /**
  111380. * Rebuilds the elements related to this component in case of
  111381. * context lost for instance.
  111382. */
  111383. rebuild(): void;
  111384. /**
  111385. * Serializes the component data to the specified json object
  111386. * @param serializationObject The object to serialize to
  111387. */
  111388. serialize(serializationObject: any): void;
  111389. /**
  111390. * Adds all the elements from the container to the scene
  111391. * @param container the container holding the elements
  111392. */
  111393. addFromContainer(container: AbstractScene): void;
  111394. /**
  111395. * Removes all the elements in the container from the scene
  111396. * @param container contains the elements to remove
  111397. * @param dispose if the removed element should be disposed (default: false)
  111398. */
  111399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111400. /**
  111401. * Rebuilds the elements related to this component in case of
  111402. * context lost for instance.
  111403. */
  111404. dispose(): void;
  111405. private _gatherRenderTargets;
  111406. }
  111407. }
  111408. declare module BABYLON {
  111409. /**
  111410. * A point light is a light defined by an unique point in world space.
  111411. * The light is emitted in every direction from this point.
  111412. * A good example of a point light is a standard light bulb.
  111413. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111414. */
  111415. export class PointLight extends ShadowLight {
  111416. private _shadowAngle;
  111417. /**
  111418. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111419. * This specifies what angle the shadow will use to be created.
  111420. *
  111421. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111422. */
  111423. /**
  111424. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111425. * This specifies what angle the shadow will use to be created.
  111426. *
  111427. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111428. */
  111429. shadowAngle: number;
  111430. /**
  111431. * Gets the direction if it has been set.
  111432. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111433. */
  111434. /**
  111435. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111436. */
  111437. direction: Vector3;
  111438. /**
  111439. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111440. * A PointLight emits the light in every direction.
  111441. * It can cast shadows.
  111442. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111443. * ```javascript
  111444. * var pointLight = new PointLight("pl", camera.position, scene);
  111445. * ```
  111446. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111447. * @param name The light friendly name
  111448. * @param position The position of the point light in the scene
  111449. * @param scene The scene the lights belongs to
  111450. */
  111451. constructor(name: string, position: Vector3, scene: Scene);
  111452. /**
  111453. * Returns the string "PointLight"
  111454. * @returns the class name
  111455. */
  111456. getClassName(): string;
  111457. /**
  111458. * Returns the integer 0.
  111459. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111460. */
  111461. getTypeID(): number;
  111462. /**
  111463. * Specifies wether or not the shadowmap should be a cube texture.
  111464. * @returns true if the shadowmap needs to be a cube texture.
  111465. */
  111466. needCube(): boolean;
  111467. /**
  111468. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111469. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111470. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111471. */
  111472. getShadowDirection(faceIndex?: number): Vector3;
  111473. /**
  111474. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111475. * - fov = PI / 2
  111476. * - aspect ratio : 1.0
  111477. * - z-near and far equal to the active camera minZ and maxZ.
  111478. * Returns the PointLight.
  111479. */
  111480. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111481. protected _buildUniformLayout(): void;
  111482. /**
  111483. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111484. * @param effect The effect to update
  111485. * @param lightIndex The index of the light in the effect to update
  111486. * @returns The point light
  111487. */
  111488. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111489. /**
  111490. * Prepares the list of defines specific to the light type.
  111491. * @param defines the list of defines
  111492. * @param lightIndex defines the index of the light for the effect
  111493. */
  111494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111495. }
  111496. }
  111497. declare module BABYLON {
  111498. /**
  111499. * Header information of HDR texture files.
  111500. */
  111501. export interface HDRInfo {
  111502. /**
  111503. * The height of the texture in pixels.
  111504. */
  111505. height: number;
  111506. /**
  111507. * The width of the texture in pixels.
  111508. */
  111509. width: number;
  111510. /**
  111511. * The index of the beginning of the data in the binary file.
  111512. */
  111513. dataPosition: number;
  111514. }
  111515. /**
  111516. * This groups tools to convert HDR texture to native colors array.
  111517. */
  111518. export class HDRTools {
  111519. private static Ldexp;
  111520. private static Rgbe2float;
  111521. private static readStringLine;
  111522. /**
  111523. * Reads header information from an RGBE texture stored in a native array.
  111524. * More information on this format are available here:
  111525. * https://en.wikipedia.org/wiki/RGBE_image_format
  111526. *
  111527. * @param uint8array The binary file stored in native array.
  111528. * @return The header information.
  111529. */
  111530. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111531. /**
  111532. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111533. * This RGBE texture needs to store the information as a panorama.
  111534. *
  111535. * More information on this format are available here:
  111536. * https://en.wikipedia.org/wiki/RGBE_image_format
  111537. *
  111538. * @param buffer The binary file stored in an array buffer.
  111539. * @param size The expected size of the extracted cubemap.
  111540. * @return The Cube Map information.
  111541. */
  111542. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111543. /**
  111544. * Returns the pixels data extracted from an RGBE texture.
  111545. * This pixels will be stored left to right up to down in the R G B order in one array.
  111546. *
  111547. * More information on this format are available here:
  111548. * https://en.wikipedia.org/wiki/RGBE_image_format
  111549. *
  111550. * @param uint8array The binary file stored in an array buffer.
  111551. * @param hdrInfo The header information of the file.
  111552. * @return The pixels data in RGB right to left up to down order.
  111553. */
  111554. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111555. private static RGBE_ReadPixels_RLE;
  111556. }
  111557. }
  111558. declare module BABYLON {
  111559. /**
  111560. * This represents a texture coming from an HDR input.
  111561. *
  111562. * The only supported format is currently panorama picture stored in RGBE format.
  111563. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111564. */
  111565. export class HDRCubeTexture extends BaseTexture {
  111566. private static _facesMapping;
  111567. private _generateHarmonics;
  111568. private _noMipmap;
  111569. private _textureMatrix;
  111570. private _size;
  111571. private _onLoad;
  111572. private _onError;
  111573. /**
  111574. * The texture URL.
  111575. */
  111576. url: string;
  111577. /**
  111578. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111579. */
  111580. coordinatesMode: number;
  111581. protected _isBlocking: boolean;
  111582. /**
  111583. * Sets wether or not the texture is blocking during loading.
  111584. */
  111585. /**
  111586. * Gets wether or not the texture is blocking during loading.
  111587. */
  111588. isBlocking: boolean;
  111589. protected _rotationY: number;
  111590. /**
  111591. * Sets texture matrix rotation angle around Y axis in radians.
  111592. */
  111593. /**
  111594. * Gets texture matrix rotation angle around Y axis radians.
  111595. */
  111596. rotationY: number;
  111597. /**
  111598. * Gets or sets the center of the bounding box associated with the cube texture
  111599. * It must define where the camera used to render the texture was set
  111600. */
  111601. boundingBoxPosition: Vector3;
  111602. private _boundingBoxSize;
  111603. /**
  111604. * Gets or sets the size of the bounding box associated with the cube texture
  111605. * When defined, the cubemap will switch to local mode
  111606. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111607. * @example https://www.babylonjs-playground.com/#RNASML
  111608. */
  111609. boundingBoxSize: Vector3;
  111610. /**
  111611. * Instantiates an HDRTexture from the following parameters.
  111612. *
  111613. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111614. * @param scene The scene the texture will be used in
  111615. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111616. * @param noMipmap Forces to not generate the mipmap if true
  111617. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111618. * @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)
  111619. * @param reserved Reserved flag for internal use.
  111620. */
  111621. 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>);
  111622. /**
  111623. * Get the current class name of the texture useful for serialization or dynamic coding.
  111624. * @returns "HDRCubeTexture"
  111625. */
  111626. getClassName(): string;
  111627. /**
  111628. * Occurs when the file is raw .hdr file.
  111629. */
  111630. private loadTexture;
  111631. clone(): HDRCubeTexture;
  111632. delayLoad(): void;
  111633. /**
  111634. * Get the texture reflection matrix used to rotate/transform the reflection.
  111635. * @returns the reflection matrix
  111636. */
  111637. getReflectionTextureMatrix(): Matrix;
  111638. /**
  111639. * Set the texture reflection matrix used to rotate/transform the reflection.
  111640. * @param value Define the reflection matrix to set
  111641. */
  111642. setReflectionTextureMatrix(value: Matrix): void;
  111643. /**
  111644. * Parses a JSON representation of an HDR Texture in order to create the texture
  111645. * @param parsedTexture Define the JSON representation
  111646. * @param scene Define the scene the texture should be created in
  111647. * @param rootUrl Define the root url in case we need to load relative dependencies
  111648. * @returns the newly created texture after parsing
  111649. */
  111650. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111651. serialize(): any;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * Class used to control physics engine
  111657. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111658. */
  111659. export class PhysicsEngine implements IPhysicsEngine {
  111660. private _physicsPlugin;
  111661. /**
  111662. * Global value used to control the smallest number supported by the simulation
  111663. */
  111664. static Epsilon: number;
  111665. private _impostors;
  111666. private _joints;
  111667. /**
  111668. * Gets the gravity vector used by the simulation
  111669. */
  111670. gravity: Vector3;
  111671. /**
  111672. * Factory used to create the default physics plugin.
  111673. * @returns The default physics plugin
  111674. */
  111675. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111676. /**
  111677. * Creates a new Physics Engine
  111678. * @param gravity defines the gravity vector used by the simulation
  111679. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111680. */
  111681. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111682. /**
  111683. * Sets the gravity vector used by the simulation
  111684. * @param gravity defines the gravity vector to use
  111685. */
  111686. setGravity(gravity: Vector3): void;
  111687. /**
  111688. * Set the time step of the physics engine.
  111689. * Default is 1/60.
  111690. * To slow it down, enter 1/600 for example.
  111691. * To speed it up, 1/30
  111692. * @param newTimeStep defines the new timestep to apply to this world.
  111693. */
  111694. setTimeStep(newTimeStep?: number): void;
  111695. /**
  111696. * Get the time step of the physics engine.
  111697. * @returns the current time step
  111698. */
  111699. getTimeStep(): number;
  111700. /**
  111701. * Release all resources
  111702. */
  111703. dispose(): void;
  111704. /**
  111705. * Gets the name of the current physics plugin
  111706. * @returns the name of the plugin
  111707. */
  111708. getPhysicsPluginName(): string;
  111709. /**
  111710. * Adding a new impostor for the impostor tracking.
  111711. * This will be done by the impostor itself.
  111712. * @param impostor the impostor to add
  111713. */
  111714. addImpostor(impostor: PhysicsImpostor): void;
  111715. /**
  111716. * Remove an impostor from the engine.
  111717. * This impostor and its mesh will not longer be updated by the physics engine.
  111718. * @param impostor the impostor to remove
  111719. */
  111720. removeImpostor(impostor: PhysicsImpostor): void;
  111721. /**
  111722. * Add a joint to the physics engine
  111723. * @param mainImpostor defines the main impostor to which the joint is added.
  111724. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111725. * @param joint defines the joint that will connect both impostors.
  111726. */
  111727. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111728. /**
  111729. * Removes a joint from the simulation
  111730. * @param mainImpostor defines the impostor used with the joint
  111731. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111732. * @param joint defines the joint to remove
  111733. */
  111734. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111735. /**
  111736. * Called by the scene. No need to call it.
  111737. * @param delta defines the timespam between frames
  111738. */
  111739. _step(delta: number): void;
  111740. /**
  111741. * Gets the current plugin used to run the simulation
  111742. * @returns current plugin
  111743. */
  111744. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111745. /**
  111746. * Gets the list of physic impostors
  111747. * @returns an array of PhysicsImpostor
  111748. */
  111749. getImpostors(): Array<PhysicsImpostor>;
  111750. /**
  111751. * Gets the impostor for a physics enabled object
  111752. * @param object defines the object impersonated by the impostor
  111753. * @returns the PhysicsImpostor or null if not found
  111754. */
  111755. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111756. /**
  111757. * Gets the impostor for a physics body object
  111758. * @param body defines physics body used by the impostor
  111759. * @returns the PhysicsImpostor or null if not found
  111760. */
  111761. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111762. /**
  111763. * Does a raycast in the physics world
  111764. * @param from when should the ray start?
  111765. * @param to when should the ray end?
  111766. * @returns PhysicsRaycastResult
  111767. */
  111768. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111769. }
  111770. }
  111771. declare module BABYLON {
  111772. /** @hidden */
  111773. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111774. private _useDeltaForWorldStep;
  111775. world: any;
  111776. name: string;
  111777. private _physicsMaterials;
  111778. private _fixedTimeStep;
  111779. private _cannonRaycastResult;
  111780. private _raycastResult;
  111781. private _physicsBodysToRemoveAfterStep;
  111782. BJSCANNON: any;
  111783. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111784. setGravity(gravity: Vector3): void;
  111785. setTimeStep(timeStep: number): void;
  111786. getTimeStep(): number;
  111787. executeStep(delta: number): void;
  111788. private _removeMarkedPhysicsBodiesFromWorld;
  111789. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111790. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111791. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111792. private _processChildMeshes;
  111793. removePhysicsBody(impostor: PhysicsImpostor): void;
  111794. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111795. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111796. private _addMaterial;
  111797. private _checkWithEpsilon;
  111798. private _createShape;
  111799. private _createHeightmap;
  111800. private _minus90X;
  111801. private _plus90X;
  111802. private _tmpPosition;
  111803. private _tmpDeltaPosition;
  111804. private _tmpUnityRotation;
  111805. private _updatePhysicsBodyTransformation;
  111806. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111807. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111808. isSupported(): boolean;
  111809. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111810. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111811. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111812. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111813. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111814. getBodyMass(impostor: PhysicsImpostor): number;
  111815. getBodyFriction(impostor: PhysicsImpostor): number;
  111816. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111817. getBodyRestitution(impostor: PhysicsImpostor): number;
  111818. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111819. sleepBody(impostor: PhysicsImpostor): void;
  111820. wakeUpBody(impostor: PhysicsImpostor): void;
  111821. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111822. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111823. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111824. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111825. getRadius(impostor: PhysicsImpostor): number;
  111826. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111827. dispose(): void;
  111828. private _extendNamespace;
  111829. /**
  111830. * Does a raycast in the physics world
  111831. * @param from when should the ray start?
  111832. * @param to when should the ray end?
  111833. * @returns PhysicsRaycastResult
  111834. */
  111835. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111836. }
  111837. }
  111838. declare module BABYLON {
  111839. /** @hidden */
  111840. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111841. world: any;
  111842. name: string;
  111843. BJSOIMO: any;
  111844. private _raycastResult;
  111845. constructor(iterations?: number, oimoInjection?: any);
  111846. setGravity(gravity: Vector3): void;
  111847. setTimeStep(timeStep: number): void;
  111848. getTimeStep(): number;
  111849. private _tmpImpostorsArray;
  111850. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111851. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111852. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111853. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111854. private _tmpPositionVector;
  111855. removePhysicsBody(impostor: PhysicsImpostor): void;
  111856. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111857. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111858. isSupported(): boolean;
  111859. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111860. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111861. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111862. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111863. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111866. getBodyMass(impostor: PhysicsImpostor): number;
  111867. getBodyFriction(impostor: PhysicsImpostor): number;
  111868. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111869. getBodyRestitution(impostor: PhysicsImpostor): number;
  111870. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111871. sleepBody(impostor: PhysicsImpostor): void;
  111872. wakeUpBody(impostor: PhysicsImpostor): void;
  111873. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111874. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111875. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111876. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111877. getRadius(impostor: PhysicsImpostor): number;
  111878. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111879. dispose(): void;
  111880. /**
  111881. * Does a raycast in the physics world
  111882. * @param from when should the ray start?
  111883. * @param to when should the ray end?
  111884. * @returns PhysicsRaycastResult
  111885. */
  111886. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111887. }
  111888. }
  111889. declare module BABYLON {
  111890. /**
  111891. * Class containing static functions to help procedurally build meshes
  111892. */
  111893. export class RibbonBuilder {
  111894. /**
  111895. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111896. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111897. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111898. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111899. * * 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
  111900. * * 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
  111901. * * 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
  111902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111905. * * 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
  111906. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111907. * * 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
  111908. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111910. * @param name defines the name of the mesh
  111911. * @param options defines the options used to create the mesh
  111912. * @param scene defines the hosting scene
  111913. * @returns the ribbon mesh
  111914. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111916. */
  111917. static CreateRibbon(name: string, options: {
  111918. pathArray: Vector3[][];
  111919. closeArray?: boolean;
  111920. closePath?: boolean;
  111921. offset?: number;
  111922. updatable?: boolean;
  111923. sideOrientation?: number;
  111924. frontUVs?: Vector4;
  111925. backUVs?: Vector4;
  111926. instance?: Mesh;
  111927. invertUV?: boolean;
  111928. uvs?: Vector2[];
  111929. colors?: Color4[];
  111930. }, scene?: Nullable<Scene>): Mesh;
  111931. }
  111932. }
  111933. declare module BABYLON {
  111934. /**
  111935. * Class containing static functions to help procedurally build meshes
  111936. */
  111937. export class ShapeBuilder {
  111938. /**
  111939. * 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.
  111940. * * 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.
  111941. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111942. * * 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.
  111943. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111944. * * 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
  111945. * * 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
  111946. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111951. * @param name defines the name of the mesh
  111952. * @param options defines the options used to create the mesh
  111953. * @param scene defines the hosting scene
  111954. * @returns the extruded shape mesh
  111955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111957. */
  111958. static ExtrudeShape(name: string, options: {
  111959. shape: Vector3[];
  111960. path: Vector3[];
  111961. scale?: number;
  111962. rotation?: number;
  111963. cap?: number;
  111964. updatable?: boolean;
  111965. sideOrientation?: number;
  111966. frontUVs?: Vector4;
  111967. backUVs?: Vector4;
  111968. instance?: Mesh;
  111969. invertUV?: boolean;
  111970. }, scene?: Nullable<Scene>): Mesh;
  111971. /**
  111972. * Creates an custom extruded shape mesh.
  111973. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111974. * * 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.
  111975. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111976. * * 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
  111977. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111978. * * 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
  111979. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111980. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111981. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  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 custom extruded shape mesh
  111993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111996. */
  111997. static ExtrudeShapeCustom(name: string, options: {
  111998. shape: Vector3[];
  111999. path: Vector3[];
  112000. scaleFunction?: any;
  112001. rotationFunction?: any;
  112002. ribbonCloseArray?: boolean;
  112003. ribbonClosePath?: boolean;
  112004. cap?: number;
  112005. updatable?: boolean;
  112006. sideOrientation?: number;
  112007. frontUVs?: Vector4;
  112008. backUVs?: Vector4;
  112009. instance?: Mesh;
  112010. invertUV?: boolean;
  112011. }, scene?: Nullable<Scene>): Mesh;
  112012. private static _ExtrudeShapeGeneric;
  112013. }
  112014. }
  112015. declare module BABYLON {
  112016. /**
  112017. * AmmoJS Physics plugin
  112018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112019. * @see https://github.com/kripken/ammo.js/
  112020. */
  112021. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  112022. private _useDeltaForWorldStep;
  112023. /**
  112024. * Reference to the Ammo library
  112025. */
  112026. bjsAMMO: any;
  112027. /**
  112028. * Created ammoJS world which physics bodies are added to
  112029. */
  112030. world: any;
  112031. /**
  112032. * Name of the plugin
  112033. */
  112034. name: string;
  112035. private _timeStep;
  112036. private _fixedTimeStep;
  112037. private _maxSteps;
  112038. private _tmpQuaternion;
  112039. private _tmpAmmoTransform;
  112040. private _tmpAmmoQuaternion;
  112041. private _tmpAmmoConcreteContactResultCallback;
  112042. private _collisionConfiguration;
  112043. private _dispatcher;
  112044. private _overlappingPairCache;
  112045. private _solver;
  112046. private _softBodySolver;
  112047. private _tmpAmmoVectorA;
  112048. private _tmpAmmoVectorB;
  112049. private _tmpAmmoVectorC;
  112050. private _tmpAmmoVectorD;
  112051. private _tmpContactCallbackResult;
  112052. private _tmpAmmoVectorRCA;
  112053. private _tmpAmmoVectorRCB;
  112054. private _raycastResult;
  112055. private static readonly DISABLE_COLLISION_FLAG;
  112056. private static readonly KINEMATIC_FLAG;
  112057. private static readonly DISABLE_DEACTIVATION_FLAG;
  112058. /**
  112059. * Initializes the ammoJS plugin
  112060. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  112061. * @param ammoInjection can be used to inject your own ammo reference
  112062. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  112063. */
  112064. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  112065. /**
  112066. * Sets the gravity of the physics world (m/(s^2))
  112067. * @param gravity Gravity to set
  112068. */
  112069. setGravity(gravity: Vector3): void;
  112070. /**
  112071. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  112072. * @param timeStep timestep to use in seconds
  112073. */
  112074. setTimeStep(timeStep: number): void;
  112075. /**
  112076. * 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)
  112077. * @param fixedTimeStep fixedTimeStep to use in seconds
  112078. */
  112079. setFixedTimeStep(fixedTimeStep: number): void;
  112080. /**
  112081. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  112082. * @param maxSteps the maximum number of steps by the physics engine per frame
  112083. */
  112084. setMaxSteps(maxSteps: number): void;
  112085. /**
  112086. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  112087. * @returns the current timestep in seconds
  112088. */
  112089. getTimeStep(): number;
  112090. private _isImpostorInContact;
  112091. private _isImpostorPairInContact;
  112092. private _stepSimulation;
  112093. /**
  112094. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112095. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112096. * After the step the babylon meshes are set to the position of the physics imposters
  112097. * @param delta amount of time to step forward
  112098. * @param impostors array of imposters to update before/after the step
  112099. */
  112100. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112101. /**
  112102. * Update babylon mesh to match physics world object
  112103. * @param impostor imposter to match
  112104. */
  112105. private _afterSoftStep;
  112106. /**
  112107. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112108. * @param impostor imposter to match
  112109. */
  112110. private _ropeStep;
  112111. /**
  112112. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112113. * @param impostor imposter to match
  112114. */
  112115. private _softbodyOrClothStep;
  112116. private _tmpVector;
  112117. private _tmpMatrix;
  112118. /**
  112119. * Applies an impulse on the imposter
  112120. * @param impostor imposter to apply impulse to
  112121. * @param force amount of force to be applied to the imposter
  112122. * @param contactPoint the location to apply the impulse on the imposter
  112123. */
  112124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112125. /**
  112126. * Applies a force on the imposter
  112127. * @param impostor imposter to apply force
  112128. * @param force amount of force to be applied to the imposter
  112129. * @param contactPoint the location to apply the force on the imposter
  112130. */
  112131. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112132. /**
  112133. * Creates a physics body using the plugin
  112134. * @param impostor the imposter to create the physics body on
  112135. */
  112136. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112137. /**
  112138. * Removes the physics body from the imposter and disposes of the body's memory
  112139. * @param impostor imposter to remove the physics body from
  112140. */
  112141. removePhysicsBody(impostor: PhysicsImpostor): void;
  112142. /**
  112143. * Generates a joint
  112144. * @param impostorJoint the imposter joint to create the joint with
  112145. */
  112146. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112147. /**
  112148. * Removes a joint
  112149. * @param impostorJoint the imposter joint to remove the joint from
  112150. */
  112151. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112152. private _addMeshVerts;
  112153. /**
  112154. * Initialise the soft body vertices to match its object's (mesh) vertices
  112155. * Softbody vertices (nodes) are in world space and to match this
  112156. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112157. * @param impostor to create the softbody for
  112158. */
  112159. private _softVertexData;
  112160. /**
  112161. * Create an impostor's soft body
  112162. * @param impostor to create the softbody for
  112163. */
  112164. private _createSoftbody;
  112165. /**
  112166. * Create cloth for an impostor
  112167. * @param impostor to create the softbody for
  112168. */
  112169. private _createCloth;
  112170. /**
  112171. * Create rope for an impostor
  112172. * @param impostor to create the softbody for
  112173. */
  112174. private _createRope;
  112175. private _addHullVerts;
  112176. private _createShape;
  112177. /**
  112178. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112179. * @param impostor imposter containing the physics body and babylon object
  112180. */
  112181. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112182. /**
  112183. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112184. * @param impostor imposter containing the physics body and babylon object
  112185. * @param newPosition new position
  112186. * @param newRotation new rotation
  112187. */
  112188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112189. /**
  112190. * If this plugin is supported
  112191. * @returns true if its supported
  112192. */
  112193. isSupported(): boolean;
  112194. /**
  112195. * Sets the linear velocity of the physics body
  112196. * @param impostor imposter to set the velocity on
  112197. * @param velocity velocity to set
  112198. */
  112199. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112200. /**
  112201. * Sets the angular velocity of the physics body
  112202. * @param impostor imposter to set the velocity on
  112203. * @param velocity velocity to set
  112204. */
  112205. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112206. /**
  112207. * gets the linear velocity
  112208. * @param impostor imposter to get linear velocity from
  112209. * @returns linear velocity
  112210. */
  112211. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112212. /**
  112213. * gets the angular velocity
  112214. * @param impostor imposter to get angular velocity from
  112215. * @returns angular velocity
  112216. */
  112217. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112218. /**
  112219. * Sets the mass of physics body
  112220. * @param impostor imposter to set the mass on
  112221. * @param mass mass to set
  112222. */
  112223. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112224. /**
  112225. * Gets the mass of the physics body
  112226. * @param impostor imposter to get the mass from
  112227. * @returns mass
  112228. */
  112229. getBodyMass(impostor: PhysicsImpostor): number;
  112230. /**
  112231. * Gets friction of the impostor
  112232. * @param impostor impostor to get friction from
  112233. * @returns friction value
  112234. */
  112235. getBodyFriction(impostor: PhysicsImpostor): number;
  112236. /**
  112237. * Sets friction of the impostor
  112238. * @param impostor impostor to set friction on
  112239. * @param friction friction value
  112240. */
  112241. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112242. /**
  112243. * Gets restitution of the impostor
  112244. * @param impostor impostor to get restitution from
  112245. * @returns restitution value
  112246. */
  112247. getBodyRestitution(impostor: PhysicsImpostor): number;
  112248. /**
  112249. * Sets resitution of the impostor
  112250. * @param impostor impostor to set resitution on
  112251. * @param restitution resitution value
  112252. */
  112253. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112254. /**
  112255. * Gets pressure inside the impostor
  112256. * @param impostor impostor to get pressure from
  112257. * @returns pressure value
  112258. */
  112259. getBodyPressure(impostor: PhysicsImpostor): number;
  112260. /**
  112261. * Sets pressure inside a soft body impostor
  112262. * Cloth and rope must remain 0 pressure
  112263. * @param impostor impostor to set pressure on
  112264. * @param pressure pressure value
  112265. */
  112266. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112267. /**
  112268. * Gets stiffness of the impostor
  112269. * @param impostor impostor to get stiffness from
  112270. * @returns pressure value
  112271. */
  112272. getBodyStiffness(impostor: PhysicsImpostor): number;
  112273. /**
  112274. * Sets stiffness of the impostor
  112275. * @param impostor impostor to set stiffness on
  112276. * @param stiffness stiffness value from 0 to 1
  112277. */
  112278. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112279. /**
  112280. * Gets velocityIterations of the impostor
  112281. * @param impostor impostor to get velocity iterations from
  112282. * @returns velocityIterations value
  112283. */
  112284. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112285. /**
  112286. * Sets velocityIterations of the impostor
  112287. * @param impostor impostor to set velocity iterations on
  112288. * @param velocityIterations velocityIterations value
  112289. */
  112290. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112291. /**
  112292. * Gets positionIterations of the impostor
  112293. * @param impostor impostor to get position iterations from
  112294. * @returns positionIterations value
  112295. */
  112296. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112297. /**
  112298. * Sets positionIterations of the impostor
  112299. * @param impostor impostor to set position on
  112300. * @param positionIterations positionIterations value
  112301. */
  112302. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112303. /**
  112304. * Append an anchor to a cloth object
  112305. * @param impostor is the cloth impostor to add anchor to
  112306. * @param otherImpostor is the rigid impostor to anchor to
  112307. * @param width ratio across width from 0 to 1
  112308. * @param height ratio up height from 0 to 1
  112309. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112310. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112311. */
  112312. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112313. /**
  112314. * Append an hook to a rope object
  112315. * @param impostor is the rope impostor to add hook to
  112316. * @param otherImpostor is the rigid impostor to hook to
  112317. * @param length ratio along the rope from 0 to 1
  112318. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112319. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112320. */
  112321. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112322. /**
  112323. * Sleeps the physics body and stops it from being active
  112324. * @param impostor impostor to sleep
  112325. */
  112326. sleepBody(impostor: PhysicsImpostor): void;
  112327. /**
  112328. * Activates the physics body
  112329. * @param impostor impostor to activate
  112330. */
  112331. wakeUpBody(impostor: PhysicsImpostor): void;
  112332. /**
  112333. * Updates the distance parameters of the joint
  112334. * @param joint joint to update
  112335. * @param maxDistance maximum distance of the joint
  112336. * @param minDistance minimum distance of the joint
  112337. */
  112338. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112339. /**
  112340. * Sets a motor on the joint
  112341. * @param joint joint to set motor on
  112342. * @param speed speed of the motor
  112343. * @param maxForce maximum force of the motor
  112344. * @param motorIndex index of the motor
  112345. */
  112346. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112347. /**
  112348. * Sets the motors limit
  112349. * @param joint joint to set limit on
  112350. * @param upperLimit upper limit
  112351. * @param lowerLimit lower limit
  112352. */
  112353. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112354. /**
  112355. * Syncs the position and rotation of a mesh with the impostor
  112356. * @param mesh mesh to sync
  112357. * @param impostor impostor to update the mesh with
  112358. */
  112359. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112360. /**
  112361. * Gets the radius of the impostor
  112362. * @param impostor impostor to get radius from
  112363. * @returns the radius
  112364. */
  112365. getRadius(impostor: PhysicsImpostor): number;
  112366. /**
  112367. * Gets the box size of the impostor
  112368. * @param impostor impostor to get box size from
  112369. * @param result the resulting box size
  112370. */
  112371. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112372. /**
  112373. * Disposes of the impostor
  112374. */
  112375. dispose(): void;
  112376. /**
  112377. * Does a raycast in the physics world
  112378. * @param from when should the ray start?
  112379. * @param to when should the ray end?
  112380. * @returns PhysicsRaycastResult
  112381. */
  112382. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112383. }
  112384. }
  112385. declare module BABYLON {
  112386. interface AbstractScene {
  112387. /**
  112388. * The list of reflection probes added to the scene
  112389. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112390. */
  112391. reflectionProbes: Array<ReflectionProbe>;
  112392. /**
  112393. * Removes the given reflection probe from this scene.
  112394. * @param toRemove The reflection probe to remove
  112395. * @returns The index of the removed reflection probe
  112396. */
  112397. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112398. /**
  112399. * Adds the given reflection probe to this scene.
  112400. * @param newReflectionProbe The reflection probe to add
  112401. */
  112402. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112403. }
  112404. /**
  112405. * Class used to generate realtime reflection / refraction cube textures
  112406. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112407. */
  112408. export class ReflectionProbe {
  112409. /** defines the name of the probe */
  112410. name: string;
  112411. private _scene;
  112412. private _renderTargetTexture;
  112413. private _projectionMatrix;
  112414. private _viewMatrix;
  112415. private _target;
  112416. private _add;
  112417. private _attachedMesh;
  112418. private _invertYAxis;
  112419. /** Gets or sets probe position (center of the cube map) */
  112420. position: Vector3;
  112421. /**
  112422. * Creates a new reflection probe
  112423. * @param name defines the name of the probe
  112424. * @param size defines the texture resolution (for each face)
  112425. * @param scene defines the hosting scene
  112426. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112427. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112428. */
  112429. constructor(
  112430. /** defines the name of the probe */
  112431. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112432. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112433. samples: number;
  112434. /** Gets or sets the refresh rate to use (on every frame by default) */
  112435. refreshRate: number;
  112436. /**
  112437. * Gets the hosting scene
  112438. * @returns a Scene
  112439. */
  112440. getScene(): Scene;
  112441. /** Gets the internal CubeTexture used to render to */
  112442. readonly cubeTexture: RenderTargetTexture;
  112443. /** Gets the list of meshes to render */
  112444. readonly renderList: Nullable<AbstractMesh[]>;
  112445. /**
  112446. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112447. * @param mesh defines the mesh to attach to
  112448. */
  112449. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112450. /**
  112451. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112452. * @param renderingGroupId The rendering group id corresponding to its index
  112453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112454. */
  112455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112456. /**
  112457. * Clean all associated resources
  112458. */
  112459. dispose(): void;
  112460. /**
  112461. * Converts the reflection probe information to a readable string for debug purpose.
  112462. * @param fullDetails Supports for multiple levels of logging within scene loading
  112463. * @returns the human readable reflection probe info
  112464. */
  112465. toString(fullDetails?: boolean): string;
  112466. /**
  112467. * Get the class name of the relfection probe.
  112468. * @returns "ReflectionProbe"
  112469. */
  112470. getClassName(): string;
  112471. /**
  112472. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112473. * @returns The JSON representation of the texture
  112474. */
  112475. serialize(): any;
  112476. /**
  112477. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112478. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112479. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112480. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112481. * @returns The parsed reflection probe if successful
  112482. */
  112483. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112484. }
  112485. }
  112486. declare module BABYLON {
  112487. /** @hidden */
  112488. export var _BabylonLoaderRegistered: boolean;
  112489. }
  112490. declare module BABYLON {
  112491. /**
  112492. * The Physically based simple base material of BJS.
  112493. *
  112494. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112495. * It is used as the base class for both the specGloss and metalRough conventions.
  112496. */
  112497. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112498. /**
  112499. * Number of Simultaneous lights allowed on the material.
  112500. */
  112501. maxSimultaneousLights: number;
  112502. /**
  112503. * If sets to true, disables all the lights affecting the material.
  112504. */
  112505. disableLighting: boolean;
  112506. /**
  112507. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112508. */
  112509. environmentTexture: BaseTexture;
  112510. /**
  112511. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112512. */
  112513. invertNormalMapX: boolean;
  112514. /**
  112515. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112516. */
  112517. invertNormalMapY: boolean;
  112518. /**
  112519. * Normal map used in the model.
  112520. */
  112521. normalTexture: BaseTexture;
  112522. /**
  112523. * Emissivie color used to self-illuminate the model.
  112524. */
  112525. emissiveColor: Color3;
  112526. /**
  112527. * Emissivie texture used to self-illuminate the model.
  112528. */
  112529. emissiveTexture: BaseTexture;
  112530. /**
  112531. * Occlusion Channel Strenght.
  112532. */
  112533. occlusionStrength: number;
  112534. /**
  112535. * Occlusion Texture of the material (adding extra occlusion effects).
  112536. */
  112537. occlusionTexture: BaseTexture;
  112538. /**
  112539. * Defines the alpha limits in alpha test mode.
  112540. */
  112541. alphaCutOff: number;
  112542. /**
  112543. * Gets the current double sided mode.
  112544. */
  112545. /**
  112546. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112547. */
  112548. doubleSided: boolean;
  112549. /**
  112550. * Stores the pre-calculated light information of a mesh in a texture.
  112551. */
  112552. lightmapTexture: BaseTexture;
  112553. /**
  112554. * If true, the light map contains occlusion information instead of lighting info.
  112555. */
  112556. useLightmapAsShadowmap: boolean;
  112557. /**
  112558. * Instantiates a new PBRMaterial instance.
  112559. *
  112560. * @param name The material name
  112561. * @param scene The scene the material will be use in.
  112562. */
  112563. constructor(name: string, scene: Scene);
  112564. getClassName(): string;
  112565. }
  112566. }
  112567. declare module BABYLON {
  112568. /**
  112569. * The PBR material of BJS following the metal roughness convention.
  112570. *
  112571. * This fits to the PBR convention in the GLTF definition:
  112572. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112573. */
  112574. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112575. /**
  112576. * The base color has two different interpretations depending on the value of metalness.
  112577. * When the material is a metal, the base color is the specific measured reflectance value
  112578. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112579. * of the material.
  112580. */
  112581. baseColor: Color3;
  112582. /**
  112583. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112584. * well as opacity information in the alpha channel.
  112585. */
  112586. baseTexture: BaseTexture;
  112587. /**
  112588. * Specifies the metallic scalar value of the material.
  112589. * Can also be used to scale the metalness values of the metallic texture.
  112590. */
  112591. metallic: number;
  112592. /**
  112593. * Specifies the roughness scalar value of the material.
  112594. * Can also be used to scale the roughness values of the metallic texture.
  112595. */
  112596. roughness: number;
  112597. /**
  112598. * Texture containing both the metallic value in the B channel and the
  112599. * roughness value in the G channel to keep better precision.
  112600. */
  112601. metallicRoughnessTexture: BaseTexture;
  112602. /**
  112603. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112604. *
  112605. * @param name The material name
  112606. * @param scene The scene the material will be use in.
  112607. */
  112608. constructor(name: string, scene: Scene);
  112609. /**
  112610. * Return the currrent class name of the material.
  112611. */
  112612. getClassName(): string;
  112613. /**
  112614. * Makes a duplicate of the current material.
  112615. * @param name - name to use for the new material.
  112616. */
  112617. clone(name: string): PBRMetallicRoughnessMaterial;
  112618. /**
  112619. * Serialize the material to a parsable JSON object.
  112620. */
  112621. serialize(): any;
  112622. /**
  112623. * Parses a JSON object correponding to the serialize function.
  112624. */
  112625. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112626. }
  112627. }
  112628. declare module BABYLON {
  112629. /**
  112630. * The PBR material of BJS following the specular glossiness convention.
  112631. *
  112632. * This fits to the PBR convention in the GLTF definition:
  112633. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112634. */
  112635. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112636. /**
  112637. * Specifies the diffuse color of the material.
  112638. */
  112639. diffuseColor: Color3;
  112640. /**
  112641. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112642. * channel.
  112643. */
  112644. diffuseTexture: BaseTexture;
  112645. /**
  112646. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112647. */
  112648. specularColor: Color3;
  112649. /**
  112650. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112651. */
  112652. glossiness: number;
  112653. /**
  112654. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112655. */
  112656. specularGlossinessTexture: BaseTexture;
  112657. /**
  112658. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112659. *
  112660. * @param name The material name
  112661. * @param scene The scene the material will be use in.
  112662. */
  112663. constructor(name: string, scene: Scene);
  112664. /**
  112665. * Return the currrent class name of the material.
  112666. */
  112667. getClassName(): string;
  112668. /**
  112669. * Makes a duplicate of the current material.
  112670. * @param name - name to use for the new material.
  112671. */
  112672. clone(name: string): PBRSpecularGlossinessMaterial;
  112673. /**
  112674. * Serialize the material to a parsable JSON object.
  112675. */
  112676. serialize(): any;
  112677. /**
  112678. * Parses a JSON object correponding to the serialize function.
  112679. */
  112680. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112681. }
  112682. }
  112683. declare module BABYLON {
  112684. /**
  112685. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112686. * It can help converting any input color in a desired output one. This can then be used to create effects
  112687. * from sepia, black and white to sixties or futuristic rendering...
  112688. *
  112689. * The only supported format is currently 3dl.
  112690. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112691. */
  112692. export class ColorGradingTexture extends BaseTexture {
  112693. /**
  112694. * The current texture matrix. (will always be identity in color grading texture)
  112695. */
  112696. private _textureMatrix;
  112697. /**
  112698. * The texture URL.
  112699. */
  112700. url: string;
  112701. /**
  112702. * Empty line regex stored for GC.
  112703. */
  112704. private static _noneEmptyLineRegex;
  112705. private _engine;
  112706. /**
  112707. * Instantiates a ColorGradingTexture from the following parameters.
  112708. *
  112709. * @param url The location of the color gradind data (currently only supporting 3dl)
  112710. * @param scene The scene the texture will be used in
  112711. */
  112712. constructor(url: string, scene: Scene);
  112713. /**
  112714. * Returns the texture matrix used in most of the material.
  112715. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112716. */
  112717. getTextureMatrix(): Matrix;
  112718. /**
  112719. * Occurs when the file being loaded is a .3dl LUT file.
  112720. */
  112721. private load3dlTexture;
  112722. /**
  112723. * Starts the loading process of the texture.
  112724. */
  112725. private loadTexture;
  112726. /**
  112727. * Clones the color gradind texture.
  112728. */
  112729. clone(): ColorGradingTexture;
  112730. /**
  112731. * Called during delayed load for textures.
  112732. */
  112733. delayLoad(): void;
  112734. /**
  112735. * Parses a color grading texture serialized by Babylon.
  112736. * @param parsedTexture The texture information being parsedTexture
  112737. * @param scene The scene to load the texture in
  112738. * @param rootUrl The root url of the data assets to load
  112739. * @return A color gradind texture
  112740. */
  112741. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112742. /**
  112743. * Serializes the LUT texture to json format.
  112744. */
  112745. serialize(): any;
  112746. }
  112747. }
  112748. declare module BABYLON {
  112749. /**
  112750. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112751. */
  112752. export class EquiRectangularCubeTexture extends BaseTexture {
  112753. /** The six faces of the cube. */
  112754. private static _FacesMapping;
  112755. private _noMipmap;
  112756. private _onLoad;
  112757. private _onError;
  112758. /** The size of the cubemap. */
  112759. private _size;
  112760. /** The buffer of the image. */
  112761. private _buffer;
  112762. /** The width of the input image. */
  112763. private _width;
  112764. /** The height of the input image. */
  112765. private _height;
  112766. /** The URL to the image. */
  112767. url: string;
  112768. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112769. coordinatesMode: number;
  112770. /**
  112771. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112772. * @param url The location of the image
  112773. * @param scene The scene the texture will be used in
  112774. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112775. * @param noMipmap Forces to not generate the mipmap if true
  112776. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112777. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112778. * @param onLoad — defines a callback called when texture is loaded
  112779. * @param onError — defines a callback called if there is an error
  112780. */
  112781. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112782. /**
  112783. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112784. */
  112785. private loadImage;
  112786. /**
  112787. * Convert the image buffer into a cubemap and create a CubeTexture.
  112788. */
  112789. private loadTexture;
  112790. /**
  112791. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112792. * @param buffer The ArrayBuffer that should be converted.
  112793. * @returns The buffer as Float32Array.
  112794. */
  112795. private getFloat32ArrayFromArrayBuffer;
  112796. /**
  112797. * Get the current class name of the texture useful for serialization or dynamic coding.
  112798. * @returns "EquiRectangularCubeTexture"
  112799. */
  112800. getClassName(): string;
  112801. /**
  112802. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112803. * @returns A clone of the current EquiRectangularCubeTexture.
  112804. */
  112805. clone(): EquiRectangularCubeTexture;
  112806. }
  112807. }
  112808. declare module BABYLON {
  112809. /**
  112810. * Based on jsTGALoader - Javascript loader for TGA file
  112811. * By Vincent Thibault
  112812. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112813. */
  112814. export class TGATools {
  112815. private static _TYPE_INDEXED;
  112816. private static _TYPE_RGB;
  112817. private static _TYPE_GREY;
  112818. private static _TYPE_RLE_INDEXED;
  112819. private static _TYPE_RLE_RGB;
  112820. private static _TYPE_RLE_GREY;
  112821. private static _ORIGIN_MASK;
  112822. private static _ORIGIN_SHIFT;
  112823. private static _ORIGIN_BL;
  112824. private static _ORIGIN_BR;
  112825. private static _ORIGIN_UL;
  112826. private static _ORIGIN_UR;
  112827. /**
  112828. * Gets the header of a TGA file
  112829. * @param data defines the TGA data
  112830. * @returns the header
  112831. */
  112832. static GetTGAHeader(data: Uint8Array): any;
  112833. /**
  112834. * Uploads TGA content to a Babylon Texture
  112835. * @hidden
  112836. */
  112837. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112838. /** @hidden */
  112839. 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;
  112840. /** @hidden */
  112841. 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;
  112842. /** @hidden */
  112843. 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;
  112844. /** @hidden */
  112845. 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;
  112846. /** @hidden */
  112847. 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;
  112848. /** @hidden */
  112849. 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;
  112850. }
  112851. }
  112852. declare module BABYLON {
  112853. /**
  112854. * Implementation of the TGA Texture Loader.
  112855. * @hidden
  112856. */
  112857. export class _TGATextureLoader implements IInternalTextureLoader {
  112858. /**
  112859. * Defines wether the loader supports cascade loading the different faces.
  112860. */
  112861. readonly supportCascades: boolean;
  112862. /**
  112863. * This returns if the loader support the current file information.
  112864. * @param extension defines the file extension of the file being loaded
  112865. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112866. * @param fallback defines the fallback internal texture if any
  112867. * @param isBase64 defines whether the texture is encoded as a base64
  112868. * @param isBuffer defines whether the texture data are stored as a buffer
  112869. * @returns true if the loader can load the specified file
  112870. */
  112871. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112872. /**
  112873. * Transform the url before loading if required.
  112874. * @param rootUrl the url of the texture
  112875. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112876. * @returns the transformed texture
  112877. */
  112878. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112879. /**
  112880. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112881. * @param rootUrl the url of the texture
  112882. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112883. * @returns the fallback texture
  112884. */
  112885. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112886. /**
  112887. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112888. * @param data contains the texture data
  112889. * @param texture defines the BabylonJS internal texture
  112890. * @param createPolynomials will be true if polynomials have been requested
  112891. * @param onLoad defines the callback to trigger once the texture is ready
  112892. * @param onError defines the callback to trigger in case of error
  112893. */
  112894. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112895. /**
  112896. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112897. * @param data contains the texture data
  112898. * @param texture defines the BabylonJS internal texture
  112899. * @param callback defines the method to call once ready to upload
  112900. */
  112901. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112902. }
  112903. }
  112904. declare module BABYLON {
  112905. /**
  112906. * Info about the .basis files
  112907. */
  112908. class BasisFileInfo {
  112909. /**
  112910. * If the file has alpha
  112911. */
  112912. hasAlpha: boolean;
  112913. /**
  112914. * Info about each image of the basis file
  112915. */
  112916. images: Array<{
  112917. levels: Array<{
  112918. width: number;
  112919. height: number;
  112920. transcodedPixels: ArrayBufferView;
  112921. }>;
  112922. }>;
  112923. }
  112924. /**
  112925. * Result of transcoding a basis file
  112926. */
  112927. class TranscodeResult {
  112928. /**
  112929. * Info about the .basis file
  112930. */
  112931. fileInfo: BasisFileInfo;
  112932. /**
  112933. * Format to use when loading the file
  112934. */
  112935. format: number;
  112936. }
  112937. /**
  112938. * Configuration options for the Basis transcoder
  112939. */
  112940. export class BasisTranscodeConfiguration {
  112941. /**
  112942. * Supported compression formats used to determine the supported output format of the transcoder
  112943. */
  112944. supportedCompressionFormats?: {
  112945. /**
  112946. * etc1 compression format
  112947. */
  112948. etc1?: boolean;
  112949. /**
  112950. * s3tc compression format
  112951. */
  112952. s3tc?: boolean;
  112953. /**
  112954. * pvrtc compression format
  112955. */
  112956. pvrtc?: boolean;
  112957. /**
  112958. * etc2 compression format
  112959. */
  112960. etc2?: boolean;
  112961. };
  112962. /**
  112963. * If mipmap levels should be loaded for transcoded images (Default: true)
  112964. */
  112965. loadMipmapLevels?: boolean;
  112966. /**
  112967. * Index of a single image to load (Default: all images)
  112968. */
  112969. loadSingleImage?: number;
  112970. }
  112971. /**
  112972. * Used to load .Basis files
  112973. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112974. */
  112975. export class BasisTools {
  112976. private static _IgnoreSupportedFormats;
  112977. /**
  112978. * URL to use when loading the basis transcoder
  112979. */
  112980. static JSModuleURL: string;
  112981. /**
  112982. * URL to use when loading the wasm module for the transcoder
  112983. */
  112984. static WasmModuleURL: string;
  112985. /**
  112986. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  112987. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  112988. * @returns internal format corresponding to the Basis format
  112989. */
  112990. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  112991. private static _WorkerPromise;
  112992. private static _Worker;
  112993. private static _actionId;
  112994. private static _CreateWorkerAsync;
  112995. /**
  112996. * Transcodes a loaded image file to compressed pixel data
  112997. * @param imageData image data to transcode
  112998. * @param config configuration options for the transcoding
  112999. * @returns a promise resulting in the transcoded image
  113000. */
  113001. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  113002. /**
  113003. * Loads a texture from the transcode result
  113004. * @param texture texture load to
  113005. * @param transcodeResult the result of transcoding the basis file to load from
  113006. */
  113007. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  113008. }
  113009. }
  113010. declare module BABYLON {
  113011. /**
  113012. * Loader for .basis file format
  113013. */
  113014. export class _BasisTextureLoader implements IInternalTextureLoader {
  113015. /**
  113016. * Defines whether the loader supports cascade loading the different faces.
  113017. */
  113018. readonly supportCascades: boolean;
  113019. /**
  113020. * This returns if the loader support the current file information.
  113021. * @param extension defines the file extension of the file being loaded
  113022. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113023. * @param fallback defines the fallback internal texture if any
  113024. * @param isBase64 defines whether the texture is encoded as a base64
  113025. * @param isBuffer defines whether the texture data are stored as a buffer
  113026. * @returns true if the loader can load the specified file
  113027. */
  113028. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113029. /**
  113030. * Transform the url before loading if required.
  113031. * @param rootUrl the url of the texture
  113032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113033. * @returns the transformed texture
  113034. */
  113035. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113036. /**
  113037. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113038. * @param rootUrl the url of the texture
  113039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113040. * @returns the fallback texture
  113041. */
  113042. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113043. /**
  113044. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  113045. * @param data contains the texture data
  113046. * @param texture defines the BabylonJS internal texture
  113047. * @param createPolynomials will be true if polynomials have been requested
  113048. * @param onLoad defines the callback to trigger once the texture is ready
  113049. * @param onError defines the callback to trigger in case of error
  113050. */
  113051. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113052. /**
  113053. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113054. * @param data contains the texture data
  113055. * @param texture defines the BabylonJS internal texture
  113056. * @param callback defines the method to call once ready to upload
  113057. */
  113058. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113059. }
  113060. }
  113061. declare module BABYLON {
  113062. /**
  113063. * 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.
  113064. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113065. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113066. */
  113067. export class CustomProceduralTexture extends ProceduralTexture {
  113068. private _animate;
  113069. private _time;
  113070. private _config;
  113071. private _texturePath;
  113072. /**
  113073. * Instantiates a new Custom Procedural Texture.
  113074. * 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.
  113075. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  113076. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  113077. * @param name Define the name of the texture
  113078. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  113079. * @param size Define the size of the texture to create
  113080. * @param scene Define the scene the texture belongs to
  113081. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  113082. * @param generateMipMaps Define if the texture should creates mip maps or not
  113083. */
  113084. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113085. private _loadJson;
  113086. /**
  113087. * Is the texture ready to be used ? (rendered at least once)
  113088. * @returns true if ready, otherwise, false.
  113089. */
  113090. isReady(): boolean;
  113091. /**
  113092. * Render the texture to its associated render target.
  113093. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113094. */
  113095. render(useCameraPostProcess?: boolean): void;
  113096. /**
  113097. * Update the list of dependant textures samplers in the shader.
  113098. */
  113099. updateTextures(): void;
  113100. /**
  113101. * Update the uniform values of the procedural texture in the shader.
  113102. */
  113103. updateShaderUniforms(): void;
  113104. /**
  113105. * Define if the texture animates or not.
  113106. */
  113107. animate: boolean;
  113108. }
  113109. }
  113110. declare module BABYLON {
  113111. /** @hidden */
  113112. export var noisePixelShader: {
  113113. name: string;
  113114. shader: string;
  113115. };
  113116. }
  113117. declare module BABYLON {
  113118. /**
  113119. * Class used to generate noise procedural textures
  113120. */
  113121. export class NoiseProceduralTexture extends ProceduralTexture {
  113122. private _time;
  113123. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113124. brightness: number;
  113125. /** Defines the number of octaves to process */
  113126. octaves: number;
  113127. /** Defines the level of persistence (0.8 by default) */
  113128. persistence: number;
  113129. /** Gets or sets animation speed factor (default is 1) */
  113130. animationSpeedFactor: number;
  113131. /**
  113132. * Creates a new NoiseProceduralTexture
  113133. * @param name defines the name fo the texture
  113134. * @param size defines the size of the texture (default is 256)
  113135. * @param scene defines the hosting scene
  113136. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113137. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113138. */
  113139. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113140. private _updateShaderUniforms;
  113141. protected _getDefines(): string;
  113142. /** Generate the current state of the procedural texture */
  113143. render(useCameraPostProcess?: boolean): void;
  113144. /**
  113145. * Serializes this noise procedural texture
  113146. * @returns a serialized noise procedural texture object
  113147. */
  113148. serialize(): any;
  113149. /**
  113150. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113151. * @param parsedTexture defines parsed texture data
  113152. * @param scene defines the current scene
  113153. * @param rootUrl defines the root URL containing noise procedural texture information
  113154. * @returns a parsed NoiseProceduralTexture
  113155. */
  113156. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113157. }
  113158. }
  113159. declare module BABYLON {
  113160. /**
  113161. * Raw cube texture where the raw buffers are passed in
  113162. */
  113163. export class RawCubeTexture extends CubeTexture {
  113164. /**
  113165. * Creates a cube texture where the raw buffers are passed in.
  113166. * @param scene defines the scene the texture is attached to
  113167. * @param data defines the array of data to use to create each face
  113168. * @param size defines the size of the textures
  113169. * @param format defines the format of the data
  113170. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113171. * @param generateMipMaps defines if the engine should generate the mip levels
  113172. * @param invertY defines if data must be stored with Y axis inverted
  113173. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113174. * @param compression defines the compression used (null by default)
  113175. */
  113176. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113177. /**
  113178. * Updates the raw cube texture.
  113179. * @param data defines the data to store
  113180. * @param format defines the data format
  113181. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113182. * @param invertY defines if data must be stored with Y axis inverted
  113183. * @param compression defines the compression used (null by default)
  113184. * @param level defines which level of the texture to update
  113185. */
  113186. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113187. /**
  113188. * Updates a raw cube texture with RGBD encoded data.
  113189. * @param data defines the array of data [mipmap][face] to use to create each face
  113190. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113191. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113192. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113193. * @returns a promsie that resolves when the operation is complete
  113194. */
  113195. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113196. /**
  113197. * Clones the raw cube texture.
  113198. * @return a new cube texture
  113199. */
  113200. clone(): CubeTexture;
  113201. /** @hidden */
  113202. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113203. }
  113204. }
  113205. declare module BABYLON {
  113206. /**
  113207. * Class used to store 3D textures containing user data
  113208. */
  113209. export class RawTexture3D extends Texture {
  113210. /** Gets or sets the texture format to use */
  113211. format: number;
  113212. private _engine;
  113213. /**
  113214. * Create a new RawTexture3D
  113215. * @param data defines the data of the texture
  113216. * @param width defines the width of the texture
  113217. * @param height defines the height of the texture
  113218. * @param depth defines the depth of the texture
  113219. * @param format defines the texture format to use
  113220. * @param scene defines the hosting scene
  113221. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113222. * @param invertY defines if texture must be stored with Y axis inverted
  113223. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113224. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113225. */
  113226. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113227. /** Gets or sets the texture format to use */
  113228. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113229. /**
  113230. * Update the texture with new data
  113231. * @param data defines the data to store in the texture
  113232. */
  113233. update(data: ArrayBufferView): void;
  113234. }
  113235. }
  113236. declare module BABYLON {
  113237. /**
  113238. * Creates a refraction texture used by refraction channel of the standard material.
  113239. * It is like a mirror but to see through a material.
  113240. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113241. */
  113242. export class RefractionTexture extends RenderTargetTexture {
  113243. /**
  113244. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113245. * 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.
  113246. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113247. */
  113248. refractionPlane: Plane;
  113249. /**
  113250. * Define how deep under the surface we should see.
  113251. */
  113252. depth: number;
  113253. /**
  113254. * Creates a refraction texture used by refraction channel of the standard material.
  113255. * It is like a mirror but to see through a material.
  113256. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113257. * @param name Define the texture name
  113258. * @param size Define the size of the underlying texture
  113259. * @param scene Define the scene the refraction belongs to
  113260. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113261. */
  113262. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113263. /**
  113264. * Clone the refraction texture.
  113265. * @returns the cloned texture
  113266. */
  113267. clone(): RefractionTexture;
  113268. /**
  113269. * Serialize the texture to a JSON representation you could use in Parse later on
  113270. * @returns the serialized JSON representation
  113271. */
  113272. serialize(): any;
  113273. }
  113274. }
  113275. declare module BABYLON {
  113276. /**
  113277. * Defines the options related to the creation of an HtmlElementTexture
  113278. */
  113279. export interface IHtmlElementTextureOptions {
  113280. /**
  113281. * Defines wether mip maps should be created or not.
  113282. */
  113283. generateMipMaps?: boolean;
  113284. /**
  113285. * Defines the sampling mode of the texture.
  113286. */
  113287. samplingMode?: number;
  113288. /**
  113289. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113290. */
  113291. engine: Nullable<Engine>;
  113292. /**
  113293. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113294. */
  113295. scene: Nullable<Scene>;
  113296. }
  113297. /**
  113298. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113299. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113300. * is automatically managed.
  113301. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113302. * in your application.
  113303. *
  113304. * As the update is not automatic, you need to call them manually.
  113305. */
  113306. export class HtmlElementTexture extends BaseTexture {
  113307. /**
  113308. * The texture URL.
  113309. */
  113310. element: HTMLVideoElement | HTMLCanvasElement;
  113311. private static readonly DefaultOptions;
  113312. private _textureMatrix;
  113313. private _engine;
  113314. private _isVideo;
  113315. private _generateMipMaps;
  113316. private _samplingMode;
  113317. /**
  113318. * Instantiates a HtmlElementTexture from the following parameters.
  113319. *
  113320. * @param name Defines the name of the texture
  113321. * @param element Defines the video or canvas the texture is filled with
  113322. * @param options Defines the other none mandatory texture creation options
  113323. */
  113324. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113325. private _createInternalTexture;
  113326. /**
  113327. * Returns the texture matrix used in most of the material.
  113328. */
  113329. getTextureMatrix(): Matrix;
  113330. /**
  113331. * Updates the content of the texture.
  113332. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113333. */
  113334. update(invertY?: Nullable<boolean>): void;
  113335. }
  113336. }
  113337. declare module BABYLON {
  113338. /**
  113339. * Enum used to define the target of a block
  113340. */
  113341. export enum NodeMaterialBlockTargets {
  113342. /** Vertex shader */
  113343. Vertex = 1,
  113344. /** Fragment shader */
  113345. Fragment = 2,
  113346. /** Vertex and Fragment */
  113347. VertexAndFragment = 3
  113348. }
  113349. }
  113350. declare module BABYLON {
  113351. /**
  113352. * Defines the kind of connection point for node based material
  113353. */
  113354. export enum NodeMaterialBlockConnectionPointTypes {
  113355. /** Float */
  113356. Float = 1,
  113357. /** Int */
  113358. Int = 2,
  113359. /** Vector2 */
  113360. Vector2 = 4,
  113361. /** Vector3 */
  113362. Vector3 = 8,
  113363. /** Vector4 */
  113364. Vector4 = 16,
  113365. /** Color3 */
  113366. Color3 = 32,
  113367. /** Color4 */
  113368. Color4 = 64,
  113369. /** Matrix */
  113370. Matrix = 128,
  113371. /** Texture */
  113372. Texture = 256,
  113373. /** Texture3D */
  113374. Texture3D = 512,
  113375. /** Vector3 or Color3 */
  113376. Vector3OrColor3 = 40,
  113377. /** Vector3 or Vector4 */
  113378. Vector3OrVector4 = 24,
  113379. /** Vector4 or Color4 */
  113380. Vector4OrColor4 = 80,
  113381. /** Color3 or Color4 */
  113382. Color3OrColor4 = 96,
  113383. /** Vector3 or Color3 */
  113384. Vector3OrColor3OrVector4OrColor4 = 120,
  113385. /** Detect type based on connection */
  113386. AutoDetect = 1024,
  113387. /** Output type that will be defined by input type */
  113388. BasedOnInput = 2048,
  113389. /** Light */
  113390. Light = 4096
  113391. }
  113392. }
  113393. declare module BABYLON {
  113394. /**
  113395. * Enum used to define well known values e.g. values automatically provided by the system
  113396. */
  113397. export enum NodeMaterialWellKnownValues {
  113398. /** World */
  113399. World = 1,
  113400. /** View */
  113401. View = 2,
  113402. /** Projection */
  113403. Projection = 3,
  113404. /** ViewProjection */
  113405. ViewProjection = 4,
  113406. /** WorldView */
  113407. WorldView = 5,
  113408. /** WorldViewProjection */
  113409. WorldViewProjection = 6,
  113410. /** CameraPosition */
  113411. CameraPosition = 7,
  113412. /** Will be filled by the block itself */
  113413. Automatic = 8
  113414. }
  113415. }
  113416. declare module BABYLON {
  113417. /**
  113418. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113419. */
  113420. export enum NodeMaterialBlockConnectionPointMode {
  113421. /** Value is an uniform */
  113422. Uniform = 0,
  113423. /** Value is a mesh attribute */
  113424. Attribute = 1,
  113425. /** Value is a varying between vertex and fragment shaders */
  113426. Varying = 2,
  113427. /** Mode is undefined */
  113428. Undefined = 3
  113429. }
  113430. }
  113431. declare module BABYLON {
  113432. /**
  113433. * Class used to store shared data between 2 NodeMaterialBuildState
  113434. */
  113435. export class NodeMaterialBuildStateSharedData {
  113436. /**
  113437. * Gets the list of emitted varyings
  113438. */
  113439. varyings: string[];
  113440. /**
  113441. * Gets the varying declaration string
  113442. */
  113443. varyingDeclaration: string;
  113444. /**
  113445. * Uniform connection points
  113446. */
  113447. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113448. /**
  113449. * Bindable blocks (Blocks that need to set data to the effect)
  113450. */
  113451. bindableBlocks: NodeMaterialBlock[];
  113452. /**
  113453. * List of blocks that can provide a compilation fallback
  113454. */
  113455. blocksWithFallbacks: NodeMaterialBlock[];
  113456. /**
  113457. * List of blocks that can provide a define update
  113458. */
  113459. blocksWithDefines: NodeMaterialBlock[];
  113460. /**
  113461. * List of blocks that can provide a repeatable content
  113462. */
  113463. repeatableContentBlocks: NodeMaterialBlock[];
  113464. /**
  113465. * List of blocks that can provide a dynamic list of uniforms
  113466. */
  113467. dynamicUniformBlocks: NodeMaterialBlock[];
  113468. /**
  113469. * List of blocks that can block the isReady function for the material
  113470. */
  113471. blockingBlocks: NodeMaterialBlock[];
  113472. /**
  113473. * Build Id used to avoid multiple recompilations
  113474. */
  113475. buildId: number;
  113476. /** List of emitted variables */
  113477. variableNames: {
  113478. [key: string]: number;
  113479. };
  113480. /** List of emitted defines */
  113481. defineNames: {
  113482. [key: string]: number;
  113483. };
  113484. /** Should emit comments? */
  113485. emitComments: boolean;
  113486. /** Emit build activity */
  113487. verbose: boolean;
  113488. /**
  113489. * Gets the compilation hints emitted at compilation time
  113490. */
  113491. hints: {
  113492. needWorldViewMatrix: boolean;
  113493. needWorldViewProjectionMatrix: boolean;
  113494. needAlphaBlending: boolean;
  113495. needAlphaTesting: boolean;
  113496. };
  113497. /**
  113498. * List of compilation checks
  113499. */
  113500. checks: {
  113501. emitVertex: boolean;
  113502. emitFragment: boolean;
  113503. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113504. };
  113505. /** Creates a new shared data */
  113506. constructor();
  113507. /**
  113508. * Emits console errors and exceptions if there is a failing check
  113509. */
  113510. emitErrors(): void;
  113511. }
  113512. }
  113513. declare module BABYLON {
  113514. /**
  113515. * Class used to store node based material build state
  113516. */
  113517. export class NodeMaterialBuildState {
  113518. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113519. supportUniformBuffers: boolean;
  113520. /**
  113521. * Gets the list of emitted attributes
  113522. */
  113523. attributes: string[];
  113524. /**
  113525. * Gets the list of emitted uniforms
  113526. */
  113527. uniforms: string[];
  113528. /**
  113529. * Gets the list of emitted uniform buffers
  113530. */
  113531. uniformBuffers: string[];
  113532. /**
  113533. * Gets the list of emitted samplers
  113534. */
  113535. samplers: string[];
  113536. /**
  113537. * Gets the list of emitted functions
  113538. */
  113539. functions: {
  113540. [key: string]: string;
  113541. };
  113542. /**
  113543. * Gets the target of the compilation state
  113544. */
  113545. target: NodeMaterialBlockTargets;
  113546. /**
  113547. * Gets the list of emitted counters
  113548. */
  113549. counters: {
  113550. [key: string]: number;
  113551. };
  113552. /**
  113553. * Shared data between multiple NodeMaterialBuildState instances
  113554. */
  113555. sharedData: NodeMaterialBuildStateSharedData;
  113556. /** @hidden */
  113557. _vertexState: NodeMaterialBuildState;
  113558. private _attributeDeclaration;
  113559. private _uniformDeclaration;
  113560. private _samplerDeclaration;
  113561. private _varyingTransfer;
  113562. private _repeatableContentAnchorIndex;
  113563. /** @hidden */
  113564. _builtCompilationString: string;
  113565. /**
  113566. * Gets the emitted compilation strings
  113567. */
  113568. compilationString: string;
  113569. /**
  113570. * Finalize the compilation strings
  113571. * @param state defines the current compilation state
  113572. */
  113573. finalize(state: NodeMaterialBuildState): void;
  113574. /** @hidden */
  113575. readonly _repeatableContentAnchor: string;
  113576. /** @hidden */
  113577. _getFreeVariableName(prefix: string): string;
  113578. /** @hidden */
  113579. _getFreeDefineName(prefix: string): string;
  113580. /** @hidden */
  113581. _excludeVariableName(name: string): void;
  113582. /** @hidden */
  113583. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113584. /** @hidden */
  113585. _emitFunction(name: string, code: string, comments: string): void;
  113586. /** @hidden */
  113587. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113588. replaceStrings?: {
  113589. search: RegExp;
  113590. replace: string;
  113591. }[];
  113592. repeatKey?: string;
  113593. }): string;
  113594. /** @hidden */
  113595. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113596. repeatKey?: string;
  113597. removeAttributes?: boolean;
  113598. removeUniforms?: boolean;
  113599. removeVaryings?: boolean;
  113600. removeIfDef?: boolean;
  113601. replaceStrings?: {
  113602. search: RegExp;
  113603. replace: string;
  113604. }[];
  113605. }, storeKey?: string): void;
  113606. /** @hidden */
  113607. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113608. private _emitDefine;
  113609. /** @hidden */
  113610. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113611. }
  113612. }
  113613. declare module BABYLON {
  113614. /**
  113615. * Root class for all node material optimizers
  113616. */
  113617. export class NodeMaterialOptimizer {
  113618. /**
  113619. * Function used to optimize a NodeMaterial graph
  113620. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113621. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113622. */
  113623. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113624. }
  113625. }
  113626. declare module BABYLON {
  113627. /**
  113628. * Block used to transform a vector4 with a matrix
  113629. */
  113630. export class Vector4TransformBlock extends NodeMaterialBlock {
  113631. /**
  113632. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113633. */
  113634. complementW: number;
  113635. /**
  113636. * Creates a new Vector4TransformBlock
  113637. * @param name defines the block name
  113638. */
  113639. constructor(name: string);
  113640. /**
  113641. * Gets the current class name
  113642. * @returns the class name
  113643. */
  113644. getClassName(): string;
  113645. /**
  113646. * Gets the vector input
  113647. */
  113648. readonly vector: NodeMaterialConnectionPoint;
  113649. /**
  113650. * Gets the output component
  113651. */
  113652. readonly output: NodeMaterialConnectionPoint;
  113653. /**
  113654. * Gets the matrix transform input
  113655. */
  113656. readonly transform: NodeMaterialConnectionPoint;
  113657. protected _buildBlock(state: NodeMaterialBuildState): this;
  113658. }
  113659. }
  113660. declare module BABYLON {
  113661. /**
  113662. * Block used to output the vertex position
  113663. */
  113664. export class VertexOutputBlock extends NodeMaterialBlock {
  113665. /**
  113666. * Creates a new VertexOutputBlock
  113667. * @param name defines the block name
  113668. */
  113669. constructor(name: string);
  113670. /**
  113671. * Gets the current class name
  113672. * @returns the class name
  113673. */
  113674. getClassName(): string;
  113675. /**
  113676. * Gets the vector input component
  113677. */
  113678. readonly vector: NodeMaterialConnectionPoint;
  113679. protected _buildBlock(state: NodeMaterialBuildState): this;
  113680. }
  113681. }
  113682. declare module BABYLON {
  113683. /**
  113684. * Block used to output the final color
  113685. */
  113686. export class FragmentOutputBlock extends NodeMaterialBlock {
  113687. /**
  113688. * Gets or sets a boolean indicating if this block will output an alpha value
  113689. */
  113690. alphaBlendingEnabled: boolean;
  113691. /**
  113692. * Create a new FragmentOutputBlock
  113693. * @param name defines the block name
  113694. */
  113695. constructor(name: string);
  113696. /**
  113697. * Gets the current class name
  113698. * @returns the class name
  113699. */
  113700. getClassName(): string;
  113701. /**
  113702. * Gets the color input component
  113703. */
  113704. readonly color: NodeMaterialConnectionPoint;
  113705. protected _buildBlock(state: NodeMaterialBuildState): this;
  113706. }
  113707. }
  113708. declare module BABYLON {
  113709. /**
  113710. * Interface used to configure the node material editor
  113711. */
  113712. export interface INodeMaterialEditorOptions {
  113713. /** Define the URl to load node editor script */
  113714. editorURL?: string;
  113715. }
  113716. /** @hidden */
  113717. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113718. /** BONES */
  113719. NUM_BONE_INFLUENCERS: number;
  113720. BonesPerMesh: number;
  113721. BONETEXTURE: boolean;
  113722. /** MORPH TARGETS */
  113723. MORPHTARGETS: boolean;
  113724. MORPHTARGETS_NORMAL: boolean;
  113725. MORPHTARGETS_TANGENT: boolean;
  113726. MORPHTARGETS_UV: boolean;
  113727. NUM_MORPH_INFLUENCERS: number;
  113728. /** IMAGE PROCESSING */
  113729. IMAGEPROCESSING: boolean;
  113730. VIGNETTE: boolean;
  113731. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113732. VIGNETTEBLENDMODEOPAQUE: boolean;
  113733. TONEMAPPING: boolean;
  113734. TONEMAPPING_ACES: boolean;
  113735. CONTRAST: boolean;
  113736. EXPOSURE: boolean;
  113737. COLORCURVES: boolean;
  113738. COLORGRADING: boolean;
  113739. COLORGRADING3D: boolean;
  113740. SAMPLER3DGREENDEPTH: boolean;
  113741. SAMPLER3DBGRMAP: boolean;
  113742. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113743. constructor();
  113744. setValue(name: string, value: boolean): void;
  113745. }
  113746. /**
  113747. * Class used to configure NodeMaterial
  113748. */
  113749. export interface INodeMaterialOptions {
  113750. /**
  113751. * Defines if blocks should emit comments
  113752. */
  113753. emitComments: boolean;
  113754. }
  113755. /**
  113756. * Class used to create a node based material built by assembling shader blocks
  113757. */
  113758. export class NodeMaterial extends PushMaterial {
  113759. private _options;
  113760. private _vertexCompilationState;
  113761. private _fragmentCompilationState;
  113762. private _sharedData;
  113763. private _buildId;
  113764. private _buildWasSuccessful;
  113765. private _cachedWorldViewMatrix;
  113766. private _cachedWorldViewProjectionMatrix;
  113767. private _textureConnectionPoints;
  113768. private _optimizers;
  113769. /** Define the URl to load node editor script */
  113770. static EditorURL: string;
  113771. private BJSNODEMATERIALEDITOR;
  113772. /** Get the inspector from bundle or global */
  113773. private _getGlobalNodeMaterialEditor;
  113774. /**
  113775. * Defines the maximum number of lights that can be used in the material
  113776. */
  113777. maxSimultaneousLights: number;
  113778. /**
  113779. * Observable raised when the material is built
  113780. */
  113781. onBuildObservable: Observable<NodeMaterial>;
  113782. /**
  113783. * Gets or sets the root nodes of the material vertex shader
  113784. */
  113785. _vertexOutputNodes: NodeMaterialBlock[];
  113786. /**
  113787. * Gets or sets the root nodes of the material fragment (pixel) shader
  113788. */
  113789. _fragmentOutputNodes: NodeMaterialBlock[];
  113790. /** Gets or sets options to control the node material overall behavior */
  113791. options: INodeMaterialOptions;
  113792. /**
  113793. * Default configuration related to image processing available in the standard Material.
  113794. */
  113795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113796. /**
  113797. * Gets the image processing configuration used either in this material.
  113798. */
  113799. /**
  113800. * Sets the Default image processing configuration used either in the this material.
  113801. *
  113802. * If sets to null, the scene one is in use.
  113803. */
  113804. imageProcessingConfiguration: ImageProcessingConfiguration;
  113805. /**
  113806. * Create a new node based material
  113807. * @param name defines the material name
  113808. * @param scene defines the hosting scene
  113809. * @param options defines creation option
  113810. */
  113811. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113812. /**
  113813. * Gets the current class name of the material e.g. "NodeMaterial"
  113814. * @returns the class name
  113815. */
  113816. getClassName(): string;
  113817. /**
  113818. * Keep track of the image processing observer to allow dispose and replace.
  113819. */
  113820. private _imageProcessingObserver;
  113821. /**
  113822. * Attaches a new image processing configuration to the Standard Material.
  113823. * @param configuration
  113824. */
  113825. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113826. /**
  113827. * Adds a new optimizer to the list of optimizers
  113828. * @param optimizer defines the optimizers to add
  113829. * @returns the current material
  113830. */
  113831. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113832. /**
  113833. * Remove an optimizer from the list of optimizers
  113834. * @param optimizer defines the optimizers to remove
  113835. * @returns the current material
  113836. */
  113837. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113838. /**
  113839. * Add a new block to the list of output nodes
  113840. * @param node defines the node to add
  113841. * @returns the current material
  113842. */
  113843. addOutputNode(node: NodeMaterialBlock): this;
  113844. /**
  113845. * Remove a block from the list of root nodes
  113846. * @param node defines the node to remove
  113847. * @returns the current material
  113848. */
  113849. removeOutputNode(node: NodeMaterialBlock): this;
  113850. private _addVertexOutputNode;
  113851. private _removeVertexOutputNode;
  113852. private _addFragmentOutputNode;
  113853. private _removeFragmentOutputNode;
  113854. /**
  113855. * Specifies if the material will require alpha blending
  113856. * @returns a boolean specifying if alpha blending is needed
  113857. */
  113858. needAlphaBlending(): boolean;
  113859. /**
  113860. * Specifies if this material should be rendered in alpha test mode
  113861. * @returns a boolean specifying if an alpha test is needed.
  113862. */
  113863. needAlphaTesting(): boolean;
  113864. private _initializeBlock;
  113865. private _resetDualBlocks;
  113866. /**
  113867. * Build the material and generates the inner effect
  113868. * @param verbose defines if the build should log activity
  113869. */
  113870. build(verbose?: boolean): void;
  113871. /**
  113872. * Runs an otpimization phase to try to improve the shader code
  113873. */
  113874. optimize(): void;
  113875. private _prepareDefinesForAttributes;
  113876. /**
  113877. * Get if the submesh is ready to be used and all its information available.
  113878. * Child classes can use it to update shaders
  113879. * @param mesh defines the mesh to check
  113880. * @param subMesh defines which submesh to check
  113881. * @param useInstances specifies that instances should be used
  113882. * @returns a boolean indicating that the submesh is ready or not
  113883. */
  113884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113885. /**
  113886. * Binds the world matrix to the material
  113887. * @param world defines the world transformation matrix
  113888. */
  113889. bindOnlyWorldMatrix(world: Matrix): void;
  113890. /**
  113891. * Binds the submesh to this material by preparing the effect and shader to draw
  113892. * @param world defines the world transformation matrix
  113893. * @param mesh defines the mesh containing the submesh
  113894. * @param subMesh defines the submesh to bind the material to
  113895. */
  113896. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113897. /**
  113898. * Gets the active textures from the material
  113899. * @returns an array of textures
  113900. */
  113901. getActiveTextures(): BaseTexture[];
  113902. /**
  113903. * Specifies if the material uses a texture
  113904. * @param texture defines the texture to check against the material
  113905. * @returns a boolean specifying if the material uses the texture
  113906. */
  113907. hasTexture(texture: BaseTexture): boolean;
  113908. /**
  113909. * Disposes the material
  113910. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113911. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113912. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113913. */
  113914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113915. /** Creates the node editor window. */
  113916. private _createNodeEditor;
  113917. /**
  113918. * Launch the node material editor
  113919. * @param config Define the configuration of the editor
  113920. * @return a promise fulfilled when the node editor is visible
  113921. */
  113922. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113923. /**
  113924. * Clear the current material
  113925. */
  113926. clear(): void;
  113927. /**
  113928. * Clear the current material and set it to a default state
  113929. */
  113930. setToDefault(): void;
  113931. }
  113932. }
  113933. declare module BABYLON {
  113934. /**
  113935. * Defines a block that can be used inside a node based material
  113936. */
  113937. export class NodeMaterialBlock {
  113938. private _buildId;
  113939. private _target;
  113940. private _isFinalMerger;
  113941. /** @hidden */
  113942. _inputs: NodeMaterialConnectionPoint[];
  113943. /** @hidden */
  113944. _outputs: NodeMaterialConnectionPoint[];
  113945. /**
  113946. * Gets or sets the name of the block
  113947. */
  113948. name: string;
  113949. /**
  113950. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113951. */
  113952. readonly isFinalMerger: boolean;
  113953. /**
  113954. * Gets or sets the build Id
  113955. */
  113956. buildId: number;
  113957. /**
  113958. * Gets or sets the target of the block
  113959. */
  113960. target: NodeMaterialBlockTargets;
  113961. /**
  113962. * Gets the list of input points
  113963. */
  113964. readonly inputs: NodeMaterialConnectionPoint[];
  113965. /** Gets the list of output points */
  113966. readonly outputs: NodeMaterialConnectionPoint[];
  113967. /**
  113968. * Find an input by its name
  113969. * @param name defines the name of the input to look for
  113970. * @returns the input or null if not found
  113971. */
  113972. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113973. /**
  113974. * Find an output by its name
  113975. * @param name defines the name of the outputto look for
  113976. * @returns the output or null if not found
  113977. */
  113978. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113979. /**
  113980. * Creates a new NodeMaterialBlock
  113981. * @param name defines the block name
  113982. * @param target defines the target of that block (Vertex by default)
  113983. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113984. */
  113985. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113986. /**
  113987. * Initialize the block and prepare the context for build
  113988. * @param state defines the state that will be used for the build
  113989. */
  113990. initialize(state: NodeMaterialBuildState): void;
  113991. /**
  113992. * Bind data to effect. Will only be called for blocks with isBindable === true
  113993. * @param effect defines the effect to bind data to
  113994. * @param nodeMaterial defines the hosting NodeMaterial
  113995. * @param mesh defines the mesh that will be rendered
  113996. */
  113997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113998. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113999. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  114000. protected _writeFloat(value: number): string;
  114001. /**
  114002. * Gets the current class name e.g. "NodeMaterialBlock"
  114003. * @returns the class name
  114004. */
  114005. getClassName(): string;
  114006. /**
  114007. * Register a new input. Must be called inside a block constructor
  114008. * @param name defines the connection point name
  114009. * @param type defines the connection point type
  114010. * @param isOptional defines a boolean indicating that this input can be omitted
  114011. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114012. * @returns the current block
  114013. */
  114014. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  114015. /**
  114016. * Register a new output. Must be called inside a block constructor
  114017. * @param name defines the connection point name
  114018. * @param type defines the connection point type
  114019. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  114020. * @returns the current block
  114021. */
  114022. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  114023. /**
  114024. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  114025. * @param forOutput defines an optional connection point to check compatibility with
  114026. * @returns the first available input or null
  114027. */
  114028. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  114029. /**
  114030. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  114031. * @param forBlock defines an optional block to check compatibility with
  114032. * @returns the first available input or null
  114033. */
  114034. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  114035. /**
  114036. * Connect current block with another block
  114037. * @param other defines the block to connect with
  114038. * @param options define the various options to help pick the right connections
  114039. * @returns the current block
  114040. */
  114041. connectTo(other: NodeMaterialBlock, options?: {
  114042. input?: string;
  114043. output?: string;
  114044. outputSwizzle?: string;
  114045. }): this | undefined;
  114046. protected _buildBlock(state: NodeMaterialBuildState): void;
  114047. /**
  114048. * Add uniforms, samplers and uniform buffers at compilation time
  114049. * @param state defines the state to update
  114050. * @param nodeMaterial defines the node material requesting the update
  114051. * @param defines defines the material defines to update
  114052. */
  114053. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114054. /**
  114055. * Add potential fallbacks if shader compilation fails
  114056. * @param mesh defines the mesh to be rendered
  114057. * @param fallbacks defines the current prioritized list of fallbacks
  114058. */
  114059. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114060. /**
  114061. * Update defines for shader compilation
  114062. * @param mesh defines the mesh to be rendered
  114063. * @param nodeMaterial defines the node material requesting the update
  114064. * @param defines defines the material defines to update
  114065. * @param useInstances specifies that instances should be used
  114066. */
  114067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114068. /**
  114069. * Lets the block try to connect some inputs automatically
  114070. */
  114071. autoConfigure(): void;
  114072. /**
  114073. * Function called when a block is declared as repeatable content generator
  114074. * @param vertexShaderState defines the current compilation state for the vertex shader
  114075. * @param fragmentShaderState defines the current compilation state for the fragment shader
  114076. * @param mesh defines the mesh to be rendered
  114077. * @param defines defines the material defines to update
  114078. */
  114079. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114080. /**
  114081. * Checks if the block is ready
  114082. * @param mesh defines the mesh to be rendered
  114083. * @param nodeMaterial defines the node material requesting the update
  114084. * @param defines defines the material defines to update
  114085. * @param useInstances specifies that instances should be used
  114086. * @returns true if the block is ready
  114087. */
  114088. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114089. /**
  114090. * Compile the current node and generate the shader code
  114091. * @param state defines the current compilation state (uniforms, samplers, current string)
  114092. * @returns the current block
  114093. */
  114094. build(state: NodeMaterialBuildState): this | undefined;
  114095. }
  114096. }
  114097. declare module BABYLON {
  114098. /**
  114099. * Defines a connection point for a block
  114100. */
  114101. export class NodeMaterialConnectionPoint {
  114102. /** @hidden */
  114103. _ownerBlock: NodeMaterialBlock;
  114104. /** @hidden */
  114105. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114106. private _associatedVariableName;
  114107. private _endpoints;
  114108. private _storedValue;
  114109. private _valueCallback;
  114110. private _mode;
  114111. /** @hidden */
  114112. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114113. /** @hidden */
  114114. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114115. /** @hidden */
  114116. _needToEmitVarying: boolean;
  114117. /** @hidden */
  114118. _forceUniformInVertexShaderOnly: boolean;
  114119. private _type;
  114120. /**
  114121. * Gets or sets the connection point type (default is float)
  114122. */
  114123. type: NodeMaterialBlockConnectionPointTypes;
  114124. /**
  114125. * Gets or sets the connection point name
  114126. */
  114127. name: string;
  114128. /**
  114129. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114130. */
  114131. swizzle: string;
  114132. /**
  114133. * Gets or sets a boolean indicating that this connection point can be omitted
  114134. */
  114135. isOptional: boolean;
  114136. /**
  114137. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114138. */
  114139. define: string;
  114140. /** Gets or sets the target of that connection point */
  114141. target: NodeMaterialBlockTargets;
  114142. /**
  114143. * Gets or sets the value of that point.
  114144. * Please note that this value will be ignored if valueCallback is defined
  114145. */
  114146. value: any;
  114147. /**
  114148. * Gets or sets a callback used to get the value of that point.
  114149. * Please note that setting this value will force the connection point to ignore the value property
  114150. */
  114151. valueCallback: () => any;
  114152. /**
  114153. * Gets or sets the associated variable name in the shader
  114154. */
  114155. associatedVariableName: string;
  114156. /**
  114157. * Gets a boolean indicating that this connection point not defined yet
  114158. */
  114159. readonly isUndefined: boolean;
  114160. /**
  114161. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114162. * In this case the connection point name must be the name of the uniform to use.
  114163. * Can only be set on inputs
  114164. */
  114165. isUniform: boolean;
  114166. /**
  114167. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114168. * In this case the connection point name must be the name of the attribute to use
  114169. * Can only be set on inputs
  114170. */
  114171. isAttribute: boolean;
  114172. /**
  114173. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114174. * Can only be set on exit points
  114175. */
  114176. isVarying: boolean;
  114177. /** Get the other side of the connection (if any) */
  114178. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114179. /** Get the block that owns this connection point */
  114180. readonly ownerBlock: NodeMaterialBlock;
  114181. /** Get the block connected on the other side of this connection (if any) */
  114182. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114183. /** Get the block connected on the endpoints of this connection (if any) */
  114184. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114185. /**
  114186. * Creates a new connection point
  114187. * @param name defines the connection point name
  114188. * @param ownerBlock defines the block hosting this connection point
  114189. */
  114190. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114191. /**
  114192. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114193. * @returns the class name
  114194. */
  114195. getClassName(): string;
  114196. /**
  114197. * Set the source of this connection point to a vertex attribute
  114198. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114199. * @returns the current connection point
  114200. */
  114201. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114202. /**
  114203. * Set the source of this connection point to a well known value
  114204. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114205. * @returns the current connection point
  114206. */
  114207. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114208. /**
  114209. * Gets a boolean indicating that the current connection point is a well known value
  114210. */
  114211. readonly isWellKnownValue: boolean;
  114212. /**
  114213. * Gets or sets the current well known value or null if not defined as well know value
  114214. */
  114215. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114216. private _getTypeLength;
  114217. /**
  114218. * Gets an boolean indicating if the current point can be connected to another point
  114219. * @param connectionPoint defines the other connection point
  114220. * @returns true if the connection is possible
  114221. */
  114222. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114223. /**
  114224. * Connect this point to another connection point
  114225. * @param connectionPoint defines the other connection point
  114226. * @returns the current connection point
  114227. */
  114228. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114229. /**
  114230. * Disconnect this point from one of his endpoint
  114231. * @param endpoint defines the other connection point
  114232. * @returns the current connection point
  114233. */
  114234. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114235. /**
  114236. * When connection point is an uniform, this function will send its value to the effect
  114237. * @param effect defines the effect to transmit value to
  114238. * @param world defines the world matrix
  114239. * @param worldView defines the worldxview matrix
  114240. * @param worldViewProjection defines the worldxviewxprojection matrix
  114241. */
  114242. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114243. /**
  114244. * When connection point is an uniform, this function will send its value to the effect
  114245. * @param effect defines the effect to transmit value to
  114246. * @param scene defines the hosting scene
  114247. */
  114248. transmit(effect: Effect, scene: Scene): void;
  114249. }
  114250. }
  114251. declare module BABYLON {
  114252. /**
  114253. * Block used to add support for vertex skinning (bones)
  114254. */
  114255. export class BonesBlock extends NodeMaterialBlock {
  114256. /**
  114257. * Creates a new BonesBlock
  114258. * @param name defines the block name
  114259. */
  114260. constructor(name: string);
  114261. /**
  114262. * Initialize the block and prepare the context for build
  114263. * @param state defines the state that will be used for the build
  114264. */
  114265. initialize(state: NodeMaterialBuildState): void;
  114266. /**
  114267. * Gets the current class name
  114268. * @returns the class name
  114269. */
  114270. getClassName(): string;
  114271. /**
  114272. * Gets the matrix indices input component
  114273. */
  114274. readonly matricesIndices: NodeMaterialConnectionPoint;
  114275. /**
  114276. * Gets the matrix weights input component
  114277. */
  114278. readonly matricesWeights: NodeMaterialConnectionPoint;
  114279. /**
  114280. * Gets the extra matrix indices input component
  114281. */
  114282. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114283. /**
  114284. * Gets the extra matrix weights input component
  114285. */
  114286. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114287. /**
  114288. * Gets the world input component
  114289. */
  114290. readonly world: NodeMaterialConnectionPoint;
  114291. /**
  114292. * Gets the output component
  114293. */
  114294. readonly output: NodeMaterialConnectionPoint;
  114295. autoConfigure(): void;
  114296. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114298. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114299. protected _buildBlock(state: NodeMaterialBuildState): this;
  114300. }
  114301. }
  114302. declare module BABYLON {
  114303. /**
  114304. * Block used to add support for instances
  114305. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114306. */
  114307. export class InstancesBlock extends NodeMaterialBlock {
  114308. /**
  114309. * Creates a new InstancesBlock
  114310. * @param name defines the block name
  114311. */
  114312. constructor(name: string);
  114313. /**
  114314. * Gets the current class name
  114315. * @returns the class name
  114316. */
  114317. getClassName(): string;
  114318. /**
  114319. * Gets the first world row input component
  114320. */
  114321. readonly world0: NodeMaterialConnectionPoint;
  114322. /**
  114323. * Gets the second world row input component
  114324. */
  114325. readonly world1: NodeMaterialConnectionPoint;
  114326. /**
  114327. * Gets the third world row input component
  114328. */
  114329. readonly world2: NodeMaterialConnectionPoint;
  114330. /**
  114331. * Gets the forth world row input component
  114332. */
  114333. readonly world3: NodeMaterialConnectionPoint;
  114334. /**
  114335. * Gets the world input component
  114336. */
  114337. readonly world: NodeMaterialConnectionPoint;
  114338. /**
  114339. * Gets the output component
  114340. */
  114341. readonly output: NodeMaterialConnectionPoint;
  114342. autoConfigure(): void;
  114343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114344. protected _buildBlock(state: NodeMaterialBuildState): this;
  114345. }
  114346. }
  114347. declare module BABYLON {
  114348. /**
  114349. * Block used to add morph targets support to vertex shader
  114350. */
  114351. export class MorphTargetsBlock extends NodeMaterialBlock {
  114352. private _repeatableContentAnchor;
  114353. private _repeatebleContentGenerated;
  114354. /**
  114355. * Create a new MorphTargetsBlock
  114356. * @param name defines the block name
  114357. */
  114358. constructor(name: string);
  114359. /**
  114360. * Gets the current class name
  114361. * @returns the class name
  114362. */
  114363. getClassName(): string;
  114364. /**
  114365. * Gets the position input component
  114366. */
  114367. readonly position: NodeMaterialConnectionPoint;
  114368. /**
  114369. * Gets the normal input component
  114370. */
  114371. readonly normal: NodeMaterialConnectionPoint;
  114372. /**
  114373. * Gets the tangent input component
  114374. */
  114375. readonly tangent: NodeMaterialConnectionPoint;
  114376. /**
  114377. * Gets the tangent input component
  114378. */
  114379. readonly uv: NodeMaterialConnectionPoint;
  114380. /**
  114381. * Gets the position output component
  114382. */
  114383. readonly positionOutput: NodeMaterialConnectionPoint;
  114384. /**
  114385. * Gets the normal output component
  114386. */
  114387. readonly normalOutput: NodeMaterialConnectionPoint;
  114388. /**
  114389. * Gets the tangent output component
  114390. */
  114391. readonly tangentOutput: NodeMaterialConnectionPoint;
  114392. /**
  114393. * Gets the tangent output component
  114394. */
  114395. readonly uvOutput: NodeMaterialConnectionPoint;
  114396. initialize(state: NodeMaterialBuildState): void;
  114397. autoConfigure(): void;
  114398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114400. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114401. protected _buildBlock(state: NodeMaterialBuildState): this;
  114402. }
  114403. }
  114404. declare module BABYLON {
  114405. /**
  114406. * Block used to add an alpha test in the fragment shader
  114407. */
  114408. export class AlphaTestBlock extends NodeMaterialBlock {
  114409. /**
  114410. * Gets or sets the alpha value where alpha testing happens
  114411. */
  114412. alphaCutOff: number;
  114413. /**
  114414. * Create a new AlphaTestBlock
  114415. * @param name defines the block name
  114416. */
  114417. constructor(name: string);
  114418. /**
  114419. * Gets the current class name
  114420. * @returns the class name
  114421. */
  114422. getClassName(): string;
  114423. /**
  114424. * Gets the color input component
  114425. */
  114426. readonly color: NodeMaterialConnectionPoint;
  114427. protected _buildBlock(state: NodeMaterialBuildState): this;
  114428. }
  114429. }
  114430. declare module BABYLON {
  114431. /**
  114432. * Block used to create a Color4 out of 4 inputs (one for each component)
  114433. */
  114434. export class RGBAMergerBlock extends NodeMaterialBlock {
  114435. /**
  114436. * Create a new RGBAMergerBlock
  114437. * @param name defines the block name
  114438. */
  114439. constructor(name: string);
  114440. /**
  114441. * Gets the current class name
  114442. * @returns the class name
  114443. */
  114444. getClassName(): string;
  114445. /**
  114446. * Gets the R input component
  114447. */
  114448. readonly r: NodeMaterialConnectionPoint;
  114449. /**
  114450. * Gets the G input component
  114451. */
  114452. readonly g: NodeMaterialConnectionPoint;
  114453. /**
  114454. * Gets the B input component
  114455. */
  114456. readonly b: NodeMaterialConnectionPoint;
  114457. /**
  114458. * Gets the RGB input component
  114459. */
  114460. readonly rgb: NodeMaterialConnectionPoint;
  114461. /**
  114462. * Gets the R input component
  114463. */
  114464. readonly a: NodeMaterialConnectionPoint;
  114465. /**
  114466. * Gets the output component
  114467. */
  114468. readonly output: NodeMaterialConnectionPoint;
  114469. protected _buildBlock(state: NodeMaterialBuildState): this;
  114470. }
  114471. }
  114472. declare module BABYLON {
  114473. /**
  114474. * Block used to create a Color3 out of 3 inputs (one for each component)
  114475. */
  114476. export class RGBMergerBlock extends NodeMaterialBlock {
  114477. /**
  114478. * Create a new RGBMergerBlock
  114479. * @param name defines the block name
  114480. */
  114481. constructor(name: string);
  114482. /**
  114483. * Gets the current class name
  114484. * @returns the class name
  114485. */
  114486. getClassName(): string;
  114487. /**
  114488. * Gets the R component input
  114489. */
  114490. readonly r: NodeMaterialConnectionPoint;
  114491. /**
  114492. * Gets the G component input
  114493. */
  114494. readonly g: NodeMaterialConnectionPoint;
  114495. /**
  114496. * Gets the B component input
  114497. */
  114498. readonly b: NodeMaterialConnectionPoint;
  114499. /**
  114500. * Gets the output component
  114501. */
  114502. readonly output: NodeMaterialConnectionPoint;
  114503. protected _buildBlock(state: NodeMaterialBuildState): this;
  114504. }
  114505. }
  114506. declare module BABYLON {
  114507. /**
  114508. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114509. */
  114510. export class RGBASplitterBlock extends NodeMaterialBlock {
  114511. /**
  114512. * Create a new RGBASplitterBlock
  114513. * @param name defines the block name
  114514. */
  114515. constructor(name: string);
  114516. /**
  114517. * Gets the current class name
  114518. * @returns the class name
  114519. */
  114520. getClassName(): string;
  114521. /**
  114522. * Gets the input component
  114523. */
  114524. readonly input: NodeMaterialConnectionPoint;
  114525. protected _buildBlock(state: NodeMaterialBuildState): this;
  114526. }
  114527. }
  114528. declare module BABYLON {
  114529. /**
  114530. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114531. */
  114532. export class RGBSplitterBlock extends NodeMaterialBlock {
  114533. /**
  114534. * Create a new RGBSplitterBlock
  114535. * @param name defines the block name
  114536. */
  114537. constructor(name: string);
  114538. /**
  114539. * Gets the current class name
  114540. * @returns the class name
  114541. */
  114542. getClassName(): string;
  114543. /**
  114544. * Gets the input component
  114545. */
  114546. readonly input: NodeMaterialConnectionPoint;
  114547. protected _buildBlock(state: NodeMaterialBuildState): this;
  114548. }
  114549. }
  114550. declare module BABYLON {
  114551. /**
  114552. * Block used to read a texture from a sampler
  114553. */
  114554. export class TextureBlock extends NodeMaterialBlock {
  114555. private _defineName;
  114556. /**
  114557. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114558. */
  114559. autoConnectTextureMatrix: boolean;
  114560. /**
  114561. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114562. */
  114563. autoSelectUV: boolean;
  114564. /**
  114565. * Create a new TextureBlock
  114566. * @param name defines the block name
  114567. */
  114568. constructor(name: string);
  114569. /**
  114570. * Gets the current class name
  114571. * @returns the class name
  114572. */
  114573. getClassName(): string;
  114574. /**
  114575. * Gets the uv input component
  114576. */
  114577. readonly uv: NodeMaterialConnectionPoint;
  114578. /**
  114579. * Gets the texture information input component
  114580. */
  114581. readonly textureInfo: NodeMaterialConnectionPoint;
  114582. /**
  114583. * Gets the transformed uv input component
  114584. */
  114585. readonly transformedUV: NodeMaterialConnectionPoint;
  114586. /**
  114587. * Gets the texture input component
  114588. */
  114589. readonly texture: NodeMaterialConnectionPoint;
  114590. /**
  114591. * Gets the texture transform input component
  114592. */
  114593. readonly textureTransform: NodeMaterialConnectionPoint;
  114594. /**
  114595. * Gets the output component
  114596. */
  114597. readonly output: NodeMaterialConnectionPoint;
  114598. autoConfigure(): void;
  114599. initialize(state: NodeMaterialBuildState): void;
  114600. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114601. isReady(): boolean;
  114602. private _injectVertexCode;
  114603. protected _buildBlock(state: NodeMaterialBuildState): this;
  114604. }
  114605. }
  114606. declare module BABYLON {
  114607. /**
  114608. * Block used to add image processing support to fragment shader
  114609. */
  114610. export class ImageProcessingBlock extends NodeMaterialBlock {
  114611. /**
  114612. * Create a new ImageProcessingBlock
  114613. * @param name defines the block name
  114614. */
  114615. constructor(name: string);
  114616. /**
  114617. * Gets the current class name
  114618. * @returns the class name
  114619. */
  114620. getClassName(): string;
  114621. /**
  114622. * Gets the color input component
  114623. */
  114624. readonly color: NodeMaterialConnectionPoint;
  114625. /**
  114626. * Gets the output component
  114627. */
  114628. readonly output: NodeMaterialConnectionPoint;
  114629. /**
  114630. * Initialize the block and prepare the context for build
  114631. * @param state defines the state that will be used for the build
  114632. */
  114633. initialize(state: NodeMaterialBuildState): void;
  114634. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114636. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114637. protected _buildBlock(state: NodeMaterialBuildState): this;
  114638. }
  114639. }
  114640. declare module BABYLON {
  114641. /**
  114642. * Block used to add support for scene fog
  114643. */
  114644. export class FogBlock extends NodeMaterialBlock {
  114645. /**
  114646. * Create a new FogBlock
  114647. * @param name defines the block name
  114648. */
  114649. constructor(name: string);
  114650. /**
  114651. * Gets the current class name
  114652. * @returns the class name
  114653. */
  114654. getClassName(): string;
  114655. /**
  114656. * Gets the world position input component
  114657. */
  114658. readonly worldPosition: NodeMaterialConnectionPoint;
  114659. /**
  114660. * Gets the view input component
  114661. */
  114662. readonly view: NodeMaterialConnectionPoint;
  114663. /**
  114664. * Gets the color input component
  114665. */
  114666. readonly color: NodeMaterialConnectionPoint;
  114667. /**
  114668. * Gets the fog color input component
  114669. */
  114670. readonly fogColor: NodeMaterialConnectionPoint;
  114671. /**
  114672. * Gets the for parameter input component
  114673. */
  114674. readonly fogParameters: NodeMaterialConnectionPoint;
  114675. /**
  114676. * Gets the output component
  114677. */
  114678. readonly output: NodeMaterialConnectionPoint;
  114679. autoConfigure(): void;
  114680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114682. protected _buildBlock(state: NodeMaterialBuildState): this;
  114683. }
  114684. }
  114685. declare module BABYLON {
  114686. /**
  114687. * Block used to add light in the fragment shader
  114688. */
  114689. export class LightBlock extends NodeMaterialBlock {
  114690. private _lightId;
  114691. /**
  114692. * Create a new LightBlock
  114693. * @param name defines the block name
  114694. */
  114695. constructor(name: string);
  114696. /**
  114697. * Gets the current class name
  114698. * @returns the class name
  114699. */
  114700. getClassName(): string;
  114701. /**
  114702. * Gets the world position input component
  114703. */
  114704. readonly worldPosition: NodeMaterialConnectionPoint;
  114705. /**
  114706. * Gets the world normal input component
  114707. */
  114708. readonly worldNormal: NodeMaterialConnectionPoint;
  114709. /**
  114710. * Gets the light input component.
  114711. * If not defined, all lights will be considered
  114712. */
  114713. readonly light: NodeMaterialConnectionPoint;
  114714. /**
  114715. * Gets the camera (or eye) position component
  114716. */
  114717. readonly cameraPosition: NodeMaterialConnectionPoint;
  114718. /**
  114719. * Gets the diffuse output component
  114720. */
  114721. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114722. /**
  114723. * Gets the specular output component
  114724. */
  114725. readonly specularOutput: NodeMaterialConnectionPoint;
  114726. autoConfigure(): void;
  114727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114728. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114730. private _injectVertexCode;
  114731. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114732. }
  114733. }
  114734. declare module BABYLON {
  114735. /**
  114736. * Block used to multiply 2 values
  114737. */
  114738. export class MultiplyBlock extends NodeMaterialBlock {
  114739. /**
  114740. * Creates a new MultiplyBlock
  114741. * @param name defines the block name
  114742. */
  114743. constructor(name: string);
  114744. /**
  114745. * Gets the current class name
  114746. * @returns the class name
  114747. */
  114748. getClassName(): string;
  114749. /**
  114750. * Gets the left operand input component
  114751. */
  114752. readonly left: NodeMaterialConnectionPoint;
  114753. /**
  114754. * Gets the right operand input component
  114755. */
  114756. readonly right: NodeMaterialConnectionPoint;
  114757. /**
  114758. * Gets the output component
  114759. */
  114760. readonly output: NodeMaterialConnectionPoint;
  114761. protected _buildBlock(state: NodeMaterialBuildState): this;
  114762. }
  114763. }
  114764. declare module BABYLON {
  114765. /**
  114766. * Block used to add 2 vector4
  114767. */
  114768. export class AddBlock extends NodeMaterialBlock {
  114769. /**
  114770. * Creates a new AddBlock
  114771. * @param name defines the block name
  114772. */
  114773. constructor(name: string);
  114774. /**
  114775. * Gets the current class name
  114776. * @returns the class name
  114777. */
  114778. getClassName(): string;
  114779. /**
  114780. * Gets the left operand input component
  114781. */
  114782. readonly left: NodeMaterialConnectionPoint;
  114783. /**
  114784. * Gets the right operand input component
  114785. */
  114786. readonly right: NodeMaterialConnectionPoint;
  114787. /**
  114788. * Gets the output component
  114789. */
  114790. readonly output: NodeMaterialConnectionPoint;
  114791. protected _buildBlock(state: NodeMaterialBuildState): this;
  114792. }
  114793. }
  114794. declare module BABYLON {
  114795. /**
  114796. * Block used to clamp a float
  114797. */
  114798. export class ClampBlock extends NodeMaterialBlock {
  114799. /** Gets or sets the minimum range */
  114800. minimum: number;
  114801. /** Gets or sets the maximum range */
  114802. maximum: number;
  114803. /**
  114804. * Creates a new ClampBlock
  114805. * @param name defines the block name
  114806. */
  114807. constructor(name: string);
  114808. /**
  114809. * Gets the current class name
  114810. * @returns the class name
  114811. */
  114812. getClassName(): string;
  114813. /**
  114814. * Gets the value input component
  114815. */
  114816. readonly value: NodeMaterialConnectionPoint;
  114817. /**
  114818. * Gets the output component
  114819. */
  114820. readonly output: NodeMaterialConnectionPoint;
  114821. protected _buildBlock(state: NodeMaterialBuildState): this;
  114822. }
  114823. }
  114824. declare module BABYLON {
  114825. /**
  114826. * Block used to transform a vector2 with a matrix
  114827. */
  114828. export class Vector2TransformBlock extends NodeMaterialBlock {
  114829. /**
  114830. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114831. */
  114832. complementZ: number;
  114833. /**
  114834. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114835. */
  114836. complementW: number;
  114837. /**
  114838. * Creates a new Vector2TransformBlock
  114839. * @param name defines the block name
  114840. */
  114841. constructor(name: string);
  114842. /**
  114843. * Gets the vector input
  114844. */
  114845. readonly vector: NodeMaterialConnectionPoint;
  114846. /**
  114847. * Gets the matrix transform input
  114848. */
  114849. readonly transform: NodeMaterialConnectionPoint;
  114850. /**
  114851. * Gets the output component
  114852. */
  114853. readonly output: NodeMaterialConnectionPoint;
  114854. /**
  114855. * Gets the current class name
  114856. * @returns the class name
  114857. */
  114858. getClassName(): string;
  114859. protected _buildBlock(state: NodeMaterialBuildState): this;
  114860. }
  114861. }
  114862. declare module BABYLON {
  114863. /**
  114864. * Block used to transform a vector3 with a matrix
  114865. */
  114866. export class Vector3TransformBlock extends NodeMaterialBlock {
  114867. /**
  114868. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114869. */
  114870. complement: number;
  114871. /**
  114872. * Creates a new Vector3TransformBlock
  114873. * @param name defines the block name
  114874. */
  114875. constructor(name: string);
  114876. /**
  114877. * Gets the vector input
  114878. */
  114879. readonly vector: NodeMaterialConnectionPoint;
  114880. /**
  114881. * Gets the matrix transform input
  114882. */
  114883. readonly transform: NodeMaterialConnectionPoint;
  114884. /**
  114885. * Gets the output component
  114886. */
  114887. readonly output: NodeMaterialConnectionPoint;
  114888. /**
  114889. * Gets the current class name
  114890. * @returns the class name
  114891. */
  114892. getClassName(): string;
  114893. protected _buildBlock(state: NodeMaterialBuildState): this;
  114894. }
  114895. }
  114896. declare module BABYLON {
  114897. /**
  114898. * Helper class to render one or more effects
  114899. */
  114900. export class EffectRenderer {
  114901. private engine;
  114902. private static _Vertices;
  114903. private static _Indices;
  114904. private _vertexBuffers;
  114905. private _indexBuffer;
  114906. private _ringBufferIndex;
  114907. private _ringScreenBuffer;
  114908. private _getNextFrameBuffer;
  114909. /**
  114910. * Creates an effect renderer
  114911. * @param engine the engine to use for rendering
  114912. */
  114913. constructor(engine: Engine);
  114914. /**
  114915. * renders one or more effects to a specified texture
  114916. * @param effectWrappers list of effects to renderer
  114917. * @param outputTexture texture to draw to, if null it will render to the screen
  114918. */
  114919. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  114920. /**
  114921. * Disposes of the effect renderer
  114922. */
  114923. dispose(): void;
  114924. }
  114925. /**
  114926. * Options to create an EffectWrapper
  114927. */
  114928. interface EffectWrapperCreationOptions {
  114929. /**
  114930. * Engine to use to create the effect
  114931. */
  114932. engine: Engine;
  114933. /**
  114934. * Fragment shader for the effect
  114935. */
  114936. fragmentShader: string;
  114937. /**
  114938. * Attributes to use in the shader
  114939. */
  114940. attributeNames: Array<string>;
  114941. /**
  114942. * Uniforms to use in the shader
  114943. */
  114944. uniformNames: Array<string>;
  114945. /**
  114946. * Texture sampler names to use in the shader
  114947. */
  114948. samplerNames: Array<string>;
  114949. }
  114950. /**
  114951. * Wraps an effect to be used for rendering
  114952. */
  114953. export class EffectWrapper {
  114954. /**
  114955. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  114956. */
  114957. onApplyObservable: Observable<{}>;
  114958. /**
  114959. * The underlying effect
  114960. */
  114961. effect: Effect;
  114962. /**
  114963. * Creates an effect to be renderer
  114964. * @param creationOptions options to create the effect
  114965. */
  114966. constructor(creationOptions: EffectWrapperCreationOptions);
  114967. /**
  114968. * Disposes of the effect wrapper
  114969. */
  114970. dispose(): void;
  114971. }
  114972. }
  114973. declare module BABYLON {
  114974. /**
  114975. * Helper class to push actions to a pool of workers.
  114976. */
  114977. export class WorkerPool implements IDisposable {
  114978. private _workerInfos;
  114979. private _pendingActions;
  114980. /**
  114981. * Constructor
  114982. * @param workers Array of workers to use for actions
  114983. */
  114984. constructor(workers: Array<Worker>);
  114985. /**
  114986. * Terminates all workers and clears any pending actions.
  114987. */
  114988. dispose(): void;
  114989. /**
  114990. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114991. * pended until a worker has completed its action.
  114992. * @param action The action to perform. Call onComplete when the action is complete.
  114993. */
  114994. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114995. private _execute;
  114996. }
  114997. }
  114998. declare module BABYLON {
  114999. /**
  115000. * Configuration for Draco compression
  115001. */
  115002. export interface IDracoCompressionConfiguration {
  115003. /**
  115004. * Configuration for the decoder.
  115005. */
  115006. decoder: {
  115007. /**
  115008. * The url to the WebAssembly module.
  115009. */
  115010. wasmUrl?: string;
  115011. /**
  115012. * The url to the WebAssembly binary.
  115013. */
  115014. wasmBinaryUrl?: string;
  115015. /**
  115016. * The url to the fallback JavaScript module.
  115017. */
  115018. fallbackUrl?: string;
  115019. };
  115020. }
  115021. /**
  115022. * Draco compression (https://google.github.io/draco/)
  115023. *
  115024. * This class wraps the Draco module.
  115025. *
  115026. * **Encoder**
  115027. *
  115028. * The encoder is not currently implemented.
  115029. *
  115030. * **Decoder**
  115031. *
  115032. * 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.
  115033. *
  115034. * To update the configuration, use the following code:
  115035. * ```javascript
  115036. * DracoCompression.Configuration = {
  115037. * decoder: {
  115038. * wasmUrl: "<url to the WebAssembly library>",
  115039. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  115040. * fallbackUrl: "<url to the fallback JavaScript library>",
  115041. * }
  115042. * };
  115043. * ```
  115044. *
  115045. * 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.
  115046. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  115047. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  115048. *
  115049. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  115050. * ```javascript
  115051. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  115052. * ```
  115053. *
  115054. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  115055. */
  115056. export class DracoCompression implements IDisposable {
  115057. private _workerPoolPromise?;
  115058. private _decoderModulePromise?;
  115059. /**
  115060. * The configuration. Defaults to the following urls:
  115061. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  115062. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  115063. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  115064. */
  115065. static Configuration: IDracoCompressionConfiguration;
  115066. /**
  115067. * Returns true if the decoder configuration is available.
  115068. */
  115069. static readonly DecoderAvailable: boolean;
  115070. /**
  115071. * Default number of workers to create when creating the draco compression object.
  115072. */
  115073. static DefaultNumWorkers: number;
  115074. private static GetDefaultNumWorkers;
  115075. private static _Default;
  115076. /**
  115077. * Default instance for the draco compression object.
  115078. */
  115079. static readonly Default: DracoCompression;
  115080. /**
  115081. * Constructor
  115082. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  115083. */
  115084. constructor(numWorkers?: number);
  115085. /**
  115086. * Stop all async operations and release resources.
  115087. */
  115088. dispose(): void;
  115089. /**
  115090. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115091. * @returns a promise that resolves when ready
  115092. */
  115093. whenReadyAsync(): Promise<void>;
  115094. /**
  115095. * Decode Draco compressed mesh data to vertex data.
  115096. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115097. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115098. * @returns A promise that resolves with the decoded vertex data
  115099. */
  115100. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115101. [kind: string]: number;
  115102. }): Promise<VertexData>;
  115103. }
  115104. }
  115105. declare module BABYLON {
  115106. /**
  115107. * Class for building Constructive Solid Geometry
  115108. */
  115109. export class CSG {
  115110. private polygons;
  115111. /**
  115112. * The world matrix
  115113. */
  115114. matrix: Matrix;
  115115. /**
  115116. * Stores the position
  115117. */
  115118. position: Vector3;
  115119. /**
  115120. * Stores the rotation
  115121. */
  115122. rotation: Vector3;
  115123. /**
  115124. * Stores the rotation quaternion
  115125. */
  115126. rotationQuaternion: Nullable<Quaternion>;
  115127. /**
  115128. * Stores the scaling vector
  115129. */
  115130. scaling: Vector3;
  115131. /**
  115132. * Convert the Mesh to CSG
  115133. * @param mesh The Mesh to convert to CSG
  115134. * @returns A new CSG from the Mesh
  115135. */
  115136. static FromMesh(mesh: Mesh): CSG;
  115137. /**
  115138. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115139. * @param polygons Polygons used to construct a CSG solid
  115140. */
  115141. private static FromPolygons;
  115142. /**
  115143. * Clones, or makes a deep copy, of the CSG
  115144. * @returns A new CSG
  115145. */
  115146. clone(): CSG;
  115147. /**
  115148. * Unions this CSG with another CSG
  115149. * @param csg The CSG to union against this CSG
  115150. * @returns The unioned CSG
  115151. */
  115152. union(csg: CSG): CSG;
  115153. /**
  115154. * Unions this CSG with another CSG in place
  115155. * @param csg The CSG to union against this CSG
  115156. */
  115157. unionInPlace(csg: CSG): void;
  115158. /**
  115159. * Subtracts this CSG with another CSG
  115160. * @param csg The CSG to subtract against this CSG
  115161. * @returns A new CSG
  115162. */
  115163. subtract(csg: CSG): CSG;
  115164. /**
  115165. * Subtracts this CSG with another CSG in place
  115166. * @param csg The CSG to subtact against this CSG
  115167. */
  115168. subtractInPlace(csg: CSG): void;
  115169. /**
  115170. * Intersect this CSG with another CSG
  115171. * @param csg The CSG to intersect against this CSG
  115172. * @returns A new CSG
  115173. */
  115174. intersect(csg: CSG): CSG;
  115175. /**
  115176. * Intersects this CSG with another CSG in place
  115177. * @param csg The CSG to intersect against this CSG
  115178. */
  115179. intersectInPlace(csg: CSG): void;
  115180. /**
  115181. * Return a new CSG solid with solid and empty space switched. This solid is
  115182. * not modified.
  115183. * @returns A new CSG solid with solid and empty space switched
  115184. */
  115185. inverse(): CSG;
  115186. /**
  115187. * Inverses the CSG in place
  115188. */
  115189. inverseInPlace(): void;
  115190. /**
  115191. * This is used to keep meshes transformations so they can be restored
  115192. * when we build back a Babylon Mesh
  115193. * NB : All CSG operations are performed in world coordinates
  115194. * @param csg The CSG to copy the transform attributes from
  115195. * @returns This CSG
  115196. */
  115197. copyTransformAttributes(csg: CSG): CSG;
  115198. /**
  115199. * Build Raw mesh from CSG
  115200. * Coordinates here are in world space
  115201. * @param name The name of the mesh geometry
  115202. * @param scene The Scene
  115203. * @param keepSubMeshes Specifies if the submeshes should be kept
  115204. * @returns A new Mesh
  115205. */
  115206. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115207. /**
  115208. * Build Mesh from CSG taking material and transforms into account
  115209. * @param name The name of the Mesh
  115210. * @param material The material of the Mesh
  115211. * @param scene The Scene
  115212. * @param keepSubMeshes Specifies if submeshes should be kept
  115213. * @returns The new Mesh
  115214. */
  115215. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115216. }
  115217. }
  115218. declare module BABYLON {
  115219. /**
  115220. * Class used to create a trail following a mesh
  115221. */
  115222. export class TrailMesh extends Mesh {
  115223. private _generator;
  115224. private _autoStart;
  115225. private _running;
  115226. private _diameter;
  115227. private _length;
  115228. private _sectionPolygonPointsCount;
  115229. private _sectionVectors;
  115230. private _sectionNormalVectors;
  115231. private _beforeRenderObserver;
  115232. /**
  115233. * @constructor
  115234. * @param name The value used by scene.getMeshByName() to do a lookup.
  115235. * @param generator The mesh to generate a trail.
  115236. * @param scene The scene to add this mesh to.
  115237. * @param diameter Diameter of trailing mesh. Default is 1.
  115238. * @param length Length of trailing mesh. Default is 60.
  115239. * @param autoStart Automatically start trailing mesh. Default true.
  115240. */
  115241. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115242. /**
  115243. * "TrailMesh"
  115244. * @returns "TrailMesh"
  115245. */
  115246. getClassName(): string;
  115247. private _createMesh;
  115248. /**
  115249. * Start trailing mesh.
  115250. */
  115251. start(): void;
  115252. /**
  115253. * Stop trailing mesh.
  115254. */
  115255. stop(): void;
  115256. /**
  115257. * Update trailing mesh geometry.
  115258. */
  115259. update(): void;
  115260. /**
  115261. * Returns a new TrailMesh object.
  115262. * @param name is a string, the name given to the new mesh
  115263. * @param newGenerator use new generator object for cloned trail mesh
  115264. * @returns a new mesh
  115265. */
  115266. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115267. /**
  115268. * Serializes this trail mesh
  115269. * @param serializationObject object to write serialization to
  115270. */
  115271. serialize(serializationObject: any): void;
  115272. /**
  115273. * Parses a serialized trail mesh
  115274. * @param parsedMesh the serialized mesh
  115275. * @param scene the scene to create the trail mesh in
  115276. * @returns the created trail mesh
  115277. */
  115278. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115279. }
  115280. }
  115281. declare module BABYLON {
  115282. /**
  115283. * Class containing static functions to help procedurally build meshes
  115284. */
  115285. export class TiledBoxBuilder {
  115286. /**
  115287. * Creates a box mesh
  115288. * 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)
  115289. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115293. * @param name defines the name of the mesh
  115294. * @param options defines the options used to create the mesh
  115295. * @param scene defines the hosting scene
  115296. * @returns the box mesh
  115297. */
  115298. static CreateTiledBox(name: string, options: {
  115299. pattern?: number;
  115300. width?: number;
  115301. height?: number;
  115302. depth?: number;
  115303. tileSize?: number;
  115304. tileWidth?: number;
  115305. tileHeight?: number;
  115306. alignHorizontal?: number;
  115307. alignVertical?: number;
  115308. faceUV?: Vector4[];
  115309. faceColors?: Color4[];
  115310. sideOrientation?: number;
  115311. updatable?: boolean;
  115312. }, scene?: Nullable<Scene>): Mesh;
  115313. }
  115314. }
  115315. declare module BABYLON {
  115316. /**
  115317. * Class containing static functions to help procedurally build meshes
  115318. */
  115319. export class TorusKnotBuilder {
  115320. /**
  115321. * Creates a torus knot mesh
  115322. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115323. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115324. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115325. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115329. * @param name defines the name of the mesh
  115330. * @param options defines the options used to create the mesh
  115331. * @param scene defines the hosting scene
  115332. * @returns the torus knot mesh
  115333. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115334. */
  115335. static CreateTorusKnot(name: string, options: {
  115336. radius?: number;
  115337. tube?: number;
  115338. radialSegments?: number;
  115339. tubularSegments?: number;
  115340. p?: number;
  115341. q?: number;
  115342. updatable?: boolean;
  115343. sideOrientation?: number;
  115344. frontUVs?: Vector4;
  115345. backUVs?: Vector4;
  115346. }, scene: any): Mesh;
  115347. }
  115348. }
  115349. declare module BABYLON {
  115350. /**
  115351. * Polygon
  115352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115353. */
  115354. export class Polygon {
  115355. /**
  115356. * Creates a rectangle
  115357. * @param xmin bottom X coord
  115358. * @param ymin bottom Y coord
  115359. * @param xmax top X coord
  115360. * @param ymax top Y coord
  115361. * @returns points that make the resulting rectation
  115362. */
  115363. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115364. /**
  115365. * Creates a circle
  115366. * @param radius radius of circle
  115367. * @param cx scale in x
  115368. * @param cy scale in y
  115369. * @param numberOfSides number of sides that make up the circle
  115370. * @returns points that make the resulting circle
  115371. */
  115372. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115373. /**
  115374. * Creates a polygon from input string
  115375. * @param input Input polygon data
  115376. * @returns the parsed points
  115377. */
  115378. static Parse(input: string): Vector2[];
  115379. /**
  115380. * Starts building a polygon from x and y coordinates
  115381. * @param x x coordinate
  115382. * @param y y coordinate
  115383. * @returns the started path2
  115384. */
  115385. static StartingAt(x: number, y: number): Path2;
  115386. }
  115387. /**
  115388. * Builds a polygon
  115389. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115390. */
  115391. export class PolygonMeshBuilder {
  115392. private _points;
  115393. private _outlinepoints;
  115394. private _holes;
  115395. private _name;
  115396. private _scene;
  115397. private _epoints;
  115398. private _eholes;
  115399. private _addToepoint;
  115400. /**
  115401. * Babylon reference to the earcut plugin.
  115402. */
  115403. bjsEarcut: any;
  115404. /**
  115405. * Creates a PolygonMeshBuilder
  115406. * @param name name of the builder
  115407. * @param contours Path of the polygon
  115408. * @param scene scene to add to when creating the mesh
  115409. * @param earcutInjection can be used to inject your own earcut reference
  115410. */
  115411. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115412. /**
  115413. * Adds a whole within the polygon
  115414. * @param hole Array of points defining the hole
  115415. * @returns this
  115416. */
  115417. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115418. /**
  115419. * Creates the polygon
  115420. * @param updatable If the mesh should be updatable
  115421. * @param depth The depth of the mesh created
  115422. * @returns the created mesh
  115423. */
  115424. build(updatable?: boolean, depth?: number): Mesh;
  115425. /**
  115426. * Creates the polygon
  115427. * @param depth The depth of the mesh created
  115428. * @returns the created VertexData
  115429. */
  115430. buildVertexData(depth?: number): VertexData;
  115431. /**
  115432. * Adds a side to the polygon
  115433. * @param positions points that make the polygon
  115434. * @param normals normals of the polygon
  115435. * @param uvs uvs of the polygon
  115436. * @param indices indices of the polygon
  115437. * @param bounds bounds of the polygon
  115438. * @param points points of the polygon
  115439. * @param depth depth of the polygon
  115440. * @param flip flip of the polygon
  115441. */
  115442. private addSide;
  115443. }
  115444. }
  115445. declare module BABYLON {
  115446. /**
  115447. * Class containing static functions to help procedurally build meshes
  115448. */
  115449. export class PolygonBuilder {
  115450. /**
  115451. * Creates a polygon mesh
  115452. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115453. * * 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
  115454. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115457. * * Remember you can only change the shape positions, not their number when updating a polygon
  115458. * @param name defines the name of the mesh
  115459. * @param options defines the options used to create the mesh
  115460. * @param scene defines the hosting scene
  115461. * @param earcutInjection can be used to inject your own earcut reference
  115462. * @returns the polygon mesh
  115463. */
  115464. static CreatePolygon(name: string, options: {
  115465. shape: Vector3[];
  115466. holes?: Vector3[][];
  115467. depth?: number;
  115468. faceUV?: Vector4[];
  115469. faceColors?: Color4[];
  115470. updatable?: boolean;
  115471. sideOrientation?: number;
  115472. frontUVs?: Vector4;
  115473. backUVs?: Vector4;
  115474. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115475. /**
  115476. * Creates an extruded polygon mesh, with depth in the Y direction.
  115477. * * 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)
  115478. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115479. * @param name defines the name of the mesh
  115480. * @param options defines the options used to create the mesh
  115481. * @param scene defines the hosting scene
  115482. * @param earcutInjection can be used to inject your own earcut reference
  115483. * @returns the polygon mesh
  115484. */
  115485. static ExtrudePolygon(name: string, options: {
  115486. shape: Vector3[];
  115487. holes?: Vector3[][];
  115488. depth?: number;
  115489. faceUV?: Vector4[];
  115490. faceColors?: Color4[];
  115491. updatable?: boolean;
  115492. sideOrientation?: number;
  115493. frontUVs?: Vector4;
  115494. backUVs?: Vector4;
  115495. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115496. }
  115497. }
  115498. declare module BABYLON {
  115499. /**
  115500. * Class containing static functions to help procedurally build meshes
  115501. */
  115502. export class LatheBuilder {
  115503. /**
  115504. * Creates lathe mesh.
  115505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115506. * * 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
  115507. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115508. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115509. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115510. * * 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
  115511. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115512. * * 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
  115513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the lathe mesh
  115521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115522. */
  115523. static CreateLathe(name: string, options: {
  115524. shape: Vector3[];
  115525. radius?: number;
  115526. tessellation?: number;
  115527. clip?: number;
  115528. arc?: number;
  115529. closed?: boolean;
  115530. updatable?: boolean;
  115531. sideOrientation?: number;
  115532. frontUVs?: Vector4;
  115533. backUVs?: Vector4;
  115534. cap?: number;
  115535. invertUV?: boolean;
  115536. }, scene?: Nullable<Scene>): Mesh;
  115537. }
  115538. }
  115539. declare module BABYLON {
  115540. /**
  115541. * Class containing static functions to help procedurally build meshes
  115542. */
  115543. export class TiledPlaneBuilder {
  115544. /**
  115545. * Creates a tiled plane mesh
  115546. * * The parameter `pattern` will, depending on value, do nothing or
  115547. * * * flip (reflect about central vertical) alternate tiles across and up
  115548. * * * flip every tile on alternate rows
  115549. * * * rotate (180 degs) alternate tiles across and up
  115550. * * * rotate every tile on alternate rows
  115551. * * * flip and rotate alternate tiles across and up
  115552. * * * flip and rotate every tile on alternate rows
  115553. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115554. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115557. * * 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)
  115558. * * 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)
  115559. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115560. * @param name defines the name of the mesh
  115561. * @param options defines the options used to create the mesh
  115562. * @param scene defines the hosting scene
  115563. * @returns the box mesh
  115564. */
  115565. static CreateTiledPlane(name: string, options: {
  115566. pattern?: number;
  115567. tileSize?: number;
  115568. tileWidth?: number;
  115569. tileHeight?: number;
  115570. size?: number;
  115571. width?: number;
  115572. height?: number;
  115573. alignHorizontal?: number;
  115574. alignVertical?: number;
  115575. sideOrientation?: number;
  115576. frontUVs?: Vector4;
  115577. backUVs?: Vector4;
  115578. updatable?: boolean;
  115579. }, scene?: Nullable<Scene>): Mesh;
  115580. }
  115581. }
  115582. declare module BABYLON {
  115583. /**
  115584. * Class containing static functions to help procedurally build meshes
  115585. */
  115586. export class TubeBuilder {
  115587. /**
  115588. * Creates a tube mesh.
  115589. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115590. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115591. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115592. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115593. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115594. * * 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)
  115595. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115596. * * 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
  115597. * * 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
  115598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115602. * @param name defines the name of the mesh
  115603. * @param options defines the options used to create the mesh
  115604. * @param scene defines the hosting scene
  115605. * @returns the tube mesh
  115606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115607. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115608. */
  115609. static CreateTube(name: string, options: {
  115610. path: Vector3[];
  115611. radius?: number;
  115612. tessellation?: number;
  115613. radiusFunction?: {
  115614. (i: number, distance: number): number;
  115615. };
  115616. cap?: number;
  115617. arc?: number;
  115618. updatable?: boolean;
  115619. sideOrientation?: number;
  115620. frontUVs?: Vector4;
  115621. backUVs?: Vector4;
  115622. instance?: Mesh;
  115623. invertUV?: boolean;
  115624. }, scene?: Nullable<Scene>): Mesh;
  115625. }
  115626. }
  115627. declare module BABYLON {
  115628. /**
  115629. * Class containing static functions to help procedurally build meshes
  115630. */
  115631. export class IcoSphereBuilder {
  115632. /**
  115633. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115634. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115635. * * 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`)
  115636. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115637. * * 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
  115638. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115639. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115641. * @param name defines the name of the mesh
  115642. * @param options defines the options used to create the mesh
  115643. * @param scene defines the hosting scene
  115644. * @returns the icosahedron mesh
  115645. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115646. */
  115647. static CreateIcoSphere(name: string, options: {
  115648. radius?: number;
  115649. radiusX?: number;
  115650. radiusY?: number;
  115651. radiusZ?: number;
  115652. flat?: boolean;
  115653. subdivisions?: number;
  115654. sideOrientation?: number;
  115655. frontUVs?: Vector4;
  115656. backUVs?: Vector4;
  115657. updatable?: boolean;
  115658. }, scene?: Nullable<Scene>): Mesh;
  115659. }
  115660. }
  115661. declare module BABYLON {
  115662. /**
  115663. * Class containing static functions to help procedurally build meshes
  115664. */
  115665. export class DecalBuilder {
  115666. /**
  115667. * Creates a decal mesh.
  115668. * 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
  115669. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115670. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115671. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115672. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115673. * @param name defines the name of the mesh
  115674. * @param sourceMesh defines the mesh where the decal must be applied
  115675. * @param options defines the options used to create the mesh
  115676. * @param scene defines the hosting scene
  115677. * @returns the decal mesh
  115678. * @see https://doc.babylonjs.com/how_to/decals
  115679. */
  115680. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115681. position?: Vector3;
  115682. normal?: Vector3;
  115683. size?: Vector3;
  115684. angle?: number;
  115685. }): Mesh;
  115686. }
  115687. }
  115688. declare module BABYLON {
  115689. /**
  115690. * Class containing static functions to help procedurally build meshes
  115691. */
  115692. export class MeshBuilder {
  115693. /**
  115694. * Creates a box mesh
  115695. * * The parameter `size` sets the size (float) of each box side (default 1)
  115696. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115697. * * 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)
  115698. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115702. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115703. * @param name defines the name of the mesh
  115704. * @param options defines the options used to create the mesh
  115705. * @param scene defines the hosting scene
  115706. * @returns the box mesh
  115707. */
  115708. static CreateBox(name: string, options: {
  115709. size?: number;
  115710. width?: number;
  115711. height?: number;
  115712. depth?: number;
  115713. faceUV?: Vector4[];
  115714. faceColors?: Color4[];
  115715. sideOrientation?: number;
  115716. frontUVs?: Vector4;
  115717. backUVs?: Vector4;
  115718. updatable?: boolean;
  115719. }, scene?: Nullable<Scene>): Mesh;
  115720. /**
  115721. * Creates a tiled box mesh
  115722. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115724. * @param name defines the name of the mesh
  115725. * @param options defines the options used to create the mesh
  115726. * @param scene defines the hosting scene
  115727. * @returns the tiled box mesh
  115728. */
  115729. static CreateTiledBox(name: string, options: {
  115730. pattern?: number;
  115731. size?: number;
  115732. width?: number;
  115733. height?: number;
  115734. depth: number;
  115735. tileSize?: number;
  115736. tileWidth?: number;
  115737. tileHeight?: number;
  115738. faceUV?: Vector4[];
  115739. faceColors?: Color4[];
  115740. alignHorizontal?: number;
  115741. alignVertical?: number;
  115742. sideOrientation?: number;
  115743. updatable?: boolean;
  115744. }, scene?: Nullable<Scene>): Mesh;
  115745. /**
  115746. * Creates a sphere mesh
  115747. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115748. * * 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`)
  115749. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115750. * * 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
  115751. * * 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)
  115752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115755. * @param name defines the name of the mesh
  115756. * @param options defines the options used to create the mesh
  115757. * @param scene defines the hosting scene
  115758. * @returns the sphere mesh
  115759. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115760. */
  115761. static CreateSphere(name: string, options: {
  115762. segments?: number;
  115763. diameter?: number;
  115764. diameterX?: number;
  115765. diameterY?: number;
  115766. diameterZ?: number;
  115767. arc?: number;
  115768. slice?: number;
  115769. sideOrientation?: number;
  115770. frontUVs?: Vector4;
  115771. backUVs?: Vector4;
  115772. updatable?: boolean;
  115773. }, scene?: Nullable<Scene>): Mesh;
  115774. /**
  115775. * Creates a plane polygonal mesh. By default, this is a disc
  115776. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115777. * * 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
  115778. * * 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
  115779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115782. * @param name defines the name of the mesh
  115783. * @param options defines the options used to create the mesh
  115784. * @param scene defines the hosting scene
  115785. * @returns the plane polygonal mesh
  115786. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115787. */
  115788. static CreateDisc(name: string, options: {
  115789. radius?: number;
  115790. tessellation?: number;
  115791. arc?: number;
  115792. updatable?: boolean;
  115793. sideOrientation?: number;
  115794. frontUVs?: Vector4;
  115795. backUVs?: Vector4;
  115796. }, scene?: Nullable<Scene>): Mesh;
  115797. /**
  115798. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115799. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115800. * * 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`)
  115801. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115802. * * 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
  115803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115806. * @param name defines the name of the mesh
  115807. * @param options defines the options used to create the mesh
  115808. * @param scene defines the hosting scene
  115809. * @returns the icosahedron mesh
  115810. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115811. */
  115812. static CreateIcoSphere(name: string, options: {
  115813. radius?: number;
  115814. radiusX?: number;
  115815. radiusY?: number;
  115816. radiusZ?: number;
  115817. flat?: boolean;
  115818. subdivisions?: number;
  115819. sideOrientation?: number;
  115820. frontUVs?: Vector4;
  115821. backUVs?: Vector4;
  115822. updatable?: boolean;
  115823. }, scene?: Nullable<Scene>): Mesh;
  115824. /**
  115825. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115826. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115827. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115828. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115829. * * 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
  115830. * * 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
  115831. * * 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
  115832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115835. * * 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
  115836. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115837. * * 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
  115838. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115840. * @param name defines the name of the mesh
  115841. * @param options defines the options used to create the mesh
  115842. * @param scene defines the hosting scene
  115843. * @returns the ribbon mesh
  115844. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115846. */
  115847. static CreateRibbon(name: string, options: {
  115848. pathArray: Vector3[][];
  115849. closeArray?: boolean;
  115850. closePath?: boolean;
  115851. offset?: number;
  115852. updatable?: boolean;
  115853. sideOrientation?: number;
  115854. frontUVs?: Vector4;
  115855. backUVs?: Vector4;
  115856. instance?: Mesh;
  115857. invertUV?: boolean;
  115858. uvs?: Vector2[];
  115859. colors?: Color4[];
  115860. }, scene?: Nullable<Scene>): Mesh;
  115861. /**
  115862. * Creates a cylinder or a cone mesh
  115863. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115864. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115865. * * 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.
  115866. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115867. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115868. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115869. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115870. * * 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).
  115871. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115872. * * 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).
  115873. * * 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
  115874. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115875. * * 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
  115876. * * 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.
  115877. * * If `enclose` is false, a ring surface is one element.
  115878. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115879. * * 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
  115880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115883. * @param name defines the name of the mesh
  115884. * @param options defines the options used to create the mesh
  115885. * @param scene defines the hosting scene
  115886. * @returns the cylinder mesh
  115887. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115888. */
  115889. static CreateCylinder(name: string, options: {
  115890. height?: number;
  115891. diameterTop?: number;
  115892. diameterBottom?: number;
  115893. diameter?: number;
  115894. tessellation?: number;
  115895. subdivisions?: number;
  115896. arc?: number;
  115897. faceColors?: Color4[];
  115898. faceUV?: Vector4[];
  115899. updatable?: boolean;
  115900. hasRings?: boolean;
  115901. enclose?: boolean;
  115902. cap?: number;
  115903. sideOrientation?: number;
  115904. frontUVs?: Vector4;
  115905. backUVs?: Vector4;
  115906. }, scene?: Nullable<Scene>): Mesh;
  115907. /**
  115908. * Creates a torus mesh
  115909. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115910. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115911. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115915. * @param name defines the name of the mesh
  115916. * @param options defines the options used to create the mesh
  115917. * @param scene defines the hosting scene
  115918. * @returns the torus mesh
  115919. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115920. */
  115921. static CreateTorus(name: string, options: {
  115922. diameter?: number;
  115923. thickness?: number;
  115924. tessellation?: number;
  115925. updatable?: boolean;
  115926. sideOrientation?: number;
  115927. frontUVs?: Vector4;
  115928. backUVs?: Vector4;
  115929. }, scene?: Nullable<Scene>): Mesh;
  115930. /**
  115931. * Creates a torus knot mesh
  115932. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115933. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115934. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115935. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115939. * @param name defines the name of the mesh
  115940. * @param options defines the options used to create the mesh
  115941. * @param scene defines the hosting scene
  115942. * @returns the torus knot mesh
  115943. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115944. */
  115945. static CreateTorusKnot(name: string, options: {
  115946. radius?: number;
  115947. tube?: number;
  115948. radialSegments?: number;
  115949. tubularSegments?: number;
  115950. p?: number;
  115951. q?: number;
  115952. updatable?: boolean;
  115953. sideOrientation?: number;
  115954. frontUVs?: Vector4;
  115955. backUVs?: Vector4;
  115956. }, scene?: Nullable<Scene>): Mesh;
  115957. /**
  115958. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115959. * * 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
  115960. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115961. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115962. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115963. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115964. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115965. * * 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
  115966. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115969. * @param name defines the name of the new line system
  115970. * @param options defines the options used to create the line system
  115971. * @param scene defines the hosting scene
  115972. * @returns a new line system mesh
  115973. */
  115974. static CreateLineSystem(name: string, options: {
  115975. lines: Vector3[][];
  115976. updatable?: boolean;
  115977. instance?: Nullable<LinesMesh>;
  115978. colors?: Nullable<Color4[][]>;
  115979. useVertexAlpha?: boolean;
  115980. }, scene: Nullable<Scene>): LinesMesh;
  115981. /**
  115982. * Creates a line mesh
  115983. * 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
  115984. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115985. * * The parameter `points` is an array successive Vector3
  115986. * * 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
  115987. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115988. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115989. * * When updating an instance, remember that only point positions can change, not the number of points
  115990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115992. * @param name defines the name of the new line system
  115993. * @param options defines the options used to create the line system
  115994. * @param scene defines the hosting scene
  115995. * @returns a new line mesh
  115996. */
  115997. static CreateLines(name: string, options: {
  115998. points: Vector3[];
  115999. updatable?: boolean;
  116000. instance?: Nullable<LinesMesh>;
  116001. colors?: Color4[];
  116002. useVertexAlpha?: boolean;
  116003. }, scene?: Nullable<Scene>): LinesMesh;
  116004. /**
  116005. * Creates a dashed line mesh
  116006. * * 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
  116007. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116008. * * The parameter `points` is an array successive Vector3
  116009. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116010. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116011. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116012. * * 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
  116013. * * When updating an instance, remember that only point positions can change, not the number of points
  116014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116015. * @param name defines the name of the mesh
  116016. * @param options defines the options used to create the mesh
  116017. * @param scene defines the hosting scene
  116018. * @returns the dashed line mesh
  116019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116020. */
  116021. static CreateDashedLines(name: string, options: {
  116022. points: Vector3[];
  116023. dashSize?: number;
  116024. gapSize?: number;
  116025. dashNb?: number;
  116026. updatable?: boolean;
  116027. instance?: LinesMesh;
  116028. }, scene?: Nullable<Scene>): LinesMesh;
  116029. /**
  116030. * 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.
  116031. * * 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.
  116032. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116033. * * 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.
  116034. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116035. * * 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
  116036. * * 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
  116037. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116042. * @param name defines the name of the mesh
  116043. * @param options defines the options used to create the mesh
  116044. * @param scene defines the hosting scene
  116045. * @returns the extruded shape mesh
  116046. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116047. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116048. */
  116049. static ExtrudeShape(name: string, options: {
  116050. shape: Vector3[];
  116051. path: Vector3[];
  116052. scale?: number;
  116053. rotation?: number;
  116054. cap?: number;
  116055. updatable?: boolean;
  116056. sideOrientation?: number;
  116057. frontUVs?: Vector4;
  116058. backUVs?: Vector4;
  116059. instance?: Mesh;
  116060. invertUV?: boolean;
  116061. }, scene?: Nullable<Scene>): Mesh;
  116062. /**
  116063. * Creates an custom extruded shape mesh.
  116064. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116065. * * 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.
  116066. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116067. * * 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
  116068. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116069. * * 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
  116070. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116071. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116072. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  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 custom extruded shape mesh
  116084. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116085. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116087. */
  116088. static ExtrudeShapeCustom(name: string, options: {
  116089. shape: Vector3[];
  116090. path: Vector3[];
  116091. scaleFunction?: any;
  116092. rotationFunction?: any;
  116093. ribbonCloseArray?: boolean;
  116094. ribbonClosePath?: boolean;
  116095. cap?: number;
  116096. updatable?: boolean;
  116097. sideOrientation?: number;
  116098. frontUVs?: Vector4;
  116099. backUVs?: Vector4;
  116100. instance?: Mesh;
  116101. invertUV?: boolean;
  116102. }, scene?: Nullable<Scene>): Mesh;
  116103. /**
  116104. * Creates lathe mesh.
  116105. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116106. * * 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
  116107. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116108. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116109. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116110. * * 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
  116111. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116112. * * 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
  116113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116115. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116117. * @param name defines the name of the mesh
  116118. * @param options defines the options used to create the mesh
  116119. * @param scene defines the hosting scene
  116120. * @returns the lathe mesh
  116121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116122. */
  116123. static CreateLathe(name: string, options: {
  116124. shape: Vector3[];
  116125. radius?: number;
  116126. tessellation?: number;
  116127. clip?: number;
  116128. arc?: number;
  116129. closed?: boolean;
  116130. updatable?: boolean;
  116131. sideOrientation?: number;
  116132. frontUVs?: Vector4;
  116133. backUVs?: Vector4;
  116134. cap?: number;
  116135. invertUV?: boolean;
  116136. }, scene?: Nullable<Scene>): Mesh;
  116137. /**
  116138. * Creates a tiled plane mesh
  116139. * * You can set a limited pattern arrangement with the tiles
  116140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116143. * @param name defines the name of the mesh
  116144. * @param options defines the options used to create the mesh
  116145. * @param scene defines the hosting scene
  116146. * @returns the plane mesh
  116147. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116148. */
  116149. static CreateTiledPlane(name: string, options: {
  116150. pattern?: number;
  116151. tileSize?: number;
  116152. tileWidth?: number;
  116153. tileHeight?: number;
  116154. size?: number;
  116155. width?: number;
  116156. height?: number;
  116157. alignHorizontal?: number;
  116158. alignVertical?: number;
  116159. sideOrientation?: number;
  116160. frontUVs?: Vector4;
  116161. backUVs?: Vector4;
  116162. updatable?: boolean;
  116163. }, scene?: Nullable<Scene>): Mesh;
  116164. /**
  116165. * Creates a plane mesh
  116166. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116167. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116168. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116172. * @param name defines the name of the mesh
  116173. * @param options defines the options used to create the mesh
  116174. * @param scene defines the hosting scene
  116175. * @returns the plane mesh
  116176. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116177. */
  116178. static CreatePlane(name: string, options: {
  116179. size?: number;
  116180. width?: number;
  116181. height?: number;
  116182. sideOrientation?: number;
  116183. frontUVs?: Vector4;
  116184. backUVs?: Vector4;
  116185. updatable?: boolean;
  116186. sourcePlane?: Plane;
  116187. }, scene?: Nullable<Scene>): Mesh;
  116188. /**
  116189. * Creates a ground mesh
  116190. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116191. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116193. * @param name defines the name of the mesh
  116194. * @param options defines the options used to create the mesh
  116195. * @param scene defines the hosting scene
  116196. * @returns the ground mesh
  116197. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116198. */
  116199. static CreateGround(name: string, options: {
  116200. width?: number;
  116201. height?: number;
  116202. subdivisions?: number;
  116203. subdivisionsX?: number;
  116204. subdivisionsY?: number;
  116205. updatable?: boolean;
  116206. }, scene?: Nullable<Scene>): Mesh;
  116207. /**
  116208. * Creates a tiled ground mesh
  116209. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116210. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116211. * * 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
  116212. * * 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
  116213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116214. * @param name defines the name of the mesh
  116215. * @param options defines the options used to create the mesh
  116216. * @param scene defines the hosting scene
  116217. * @returns the tiled ground mesh
  116218. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116219. */
  116220. static CreateTiledGround(name: string, options: {
  116221. xmin: number;
  116222. zmin: number;
  116223. xmax: number;
  116224. zmax: number;
  116225. subdivisions?: {
  116226. w: number;
  116227. h: number;
  116228. };
  116229. precision?: {
  116230. w: number;
  116231. h: number;
  116232. };
  116233. updatable?: boolean;
  116234. }, scene?: Nullable<Scene>): Mesh;
  116235. /**
  116236. * Creates a ground mesh from a height map
  116237. * * The parameter `url` sets the URL of the height map image resource.
  116238. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116239. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116240. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116241. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116242. * * 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.
  116243. * * 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).
  116244. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116246. * @param name defines the name of the mesh
  116247. * @param url defines the url to the height map
  116248. * @param options defines the options used to create the mesh
  116249. * @param scene defines the hosting scene
  116250. * @returns the ground mesh
  116251. * @see https://doc.babylonjs.com/babylon101/height_map
  116252. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116253. */
  116254. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116255. width?: number;
  116256. height?: number;
  116257. subdivisions?: number;
  116258. minHeight?: number;
  116259. maxHeight?: number;
  116260. colorFilter?: Color3;
  116261. alphaFilter?: number;
  116262. updatable?: boolean;
  116263. onReady?: (mesh: GroundMesh) => void;
  116264. }, scene?: Nullable<Scene>): GroundMesh;
  116265. /**
  116266. * Creates a polygon mesh
  116267. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116268. * * 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
  116269. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116272. * * Remember you can only change the shape positions, not their number when updating a polygon
  116273. * @param name defines the name of the mesh
  116274. * @param options defines the options used to create the mesh
  116275. * @param scene defines the hosting scene
  116276. * @param earcutInjection can be used to inject your own earcut reference
  116277. * @returns the polygon mesh
  116278. */
  116279. static CreatePolygon(name: string, options: {
  116280. shape: Vector3[];
  116281. holes?: Vector3[][];
  116282. depth?: number;
  116283. faceUV?: Vector4[];
  116284. faceColors?: Color4[];
  116285. updatable?: boolean;
  116286. sideOrientation?: number;
  116287. frontUVs?: Vector4;
  116288. backUVs?: Vector4;
  116289. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116290. /**
  116291. * Creates an extruded polygon mesh, with depth in the Y direction.
  116292. * * 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)
  116293. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116294. * @param name defines the name of the mesh
  116295. * @param options defines the options used to create the mesh
  116296. * @param scene defines the hosting scene
  116297. * @param earcutInjection can be used to inject your own earcut reference
  116298. * @returns the polygon mesh
  116299. */
  116300. static ExtrudePolygon(name: string, options: {
  116301. shape: Vector3[];
  116302. holes?: Vector3[][];
  116303. depth?: number;
  116304. faceUV?: Vector4[];
  116305. faceColors?: Color4[];
  116306. updatable?: boolean;
  116307. sideOrientation?: number;
  116308. frontUVs?: Vector4;
  116309. backUVs?: Vector4;
  116310. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116311. /**
  116312. * Creates a tube mesh.
  116313. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116314. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116315. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116316. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116317. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116318. * * 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)
  116319. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116320. * * 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
  116321. * * 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
  116322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116324. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116326. * @param name defines the name of the mesh
  116327. * @param options defines the options used to create the mesh
  116328. * @param scene defines the hosting scene
  116329. * @returns the tube mesh
  116330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116331. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116332. */
  116333. static CreateTube(name: string, options: {
  116334. path: Vector3[];
  116335. radius?: number;
  116336. tessellation?: number;
  116337. radiusFunction?: {
  116338. (i: number, distance: number): number;
  116339. };
  116340. cap?: number;
  116341. arc?: number;
  116342. updatable?: boolean;
  116343. sideOrientation?: number;
  116344. frontUVs?: Vector4;
  116345. backUVs?: Vector4;
  116346. instance?: Mesh;
  116347. invertUV?: boolean;
  116348. }, scene?: Nullable<Scene>): Mesh;
  116349. /**
  116350. * Creates a polyhedron mesh
  116351. * * 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
  116352. * * The parameter `size` (positive float, default 1) sets the polygon size
  116353. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116354. * * 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`
  116355. * * 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
  116356. * * 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)`)
  116357. * * 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
  116358. * * 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
  116359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116362. * @param name defines the name of the mesh
  116363. * @param options defines the options used to create the mesh
  116364. * @param scene defines the hosting scene
  116365. * @returns the polyhedron mesh
  116366. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116367. */
  116368. static CreatePolyhedron(name: string, options: {
  116369. type?: number;
  116370. size?: number;
  116371. sizeX?: number;
  116372. sizeY?: number;
  116373. sizeZ?: number;
  116374. custom?: any;
  116375. faceUV?: Vector4[];
  116376. faceColors?: Color4[];
  116377. flat?: boolean;
  116378. updatable?: boolean;
  116379. sideOrientation?: number;
  116380. frontUVs?: Vector4;
  116381. backUVs?: Vector4;
  116382. }, scene?: Nullable<Scene>): Mesh;
  116383. /**
  116384. * Creates a decal mesh.
  116385. * 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
  116386. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116387. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116388. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116389. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116390. * @param name defines the name of the mesh
  116391. * @param sourceMesh defines the mesh where the decal must be applied
  116392. * @param options defines the options used to create the mesh
  116393. * @param scene defines the hosting scene
  116394. * @returns the decal mesh
  116395. * @see https://doc.babylonjs.com/how_to/decals
  116396. */
  116397. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116398. position?: Vector3;
  116399. normal?: Vector3;
  116400. size?: Vector3;
  116401. angle?: number;
  116402. }): Mesh;
  116403. }
  116404. }
  116405. declare module BABYLON {
  116406. /**
  116407. * A simplifier interface for future simplification implementations
  116408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116409. */
  116410. export interface ISimplifier {
  116411. /**
  116412. * Simplification of a given mesh according to the given settings.
  116413. * Since this requires computation, it is assumed that the function runs async.
  116414. * @param settings The settings of the simplification, including quality and distance
  116415. * @param successCallback A callback that will be called after the mesh was simplified.
  116416. * @param errorCallback in case of an error, this callback will be called. optional.
  116417. */
  116418. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116419. }
  116420. /**
  116421. * Expected simplification settings.
  116422. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116423. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116424. */
  116425. export interface ISimplificationSettings {
  116426. /**
  116427. * Gets or sets the expected quality
  116428. */
  116429. quality: number;
  116430. /**
  116431. * Gets or sets the distance when this optimized version should be used
  116432. */
  116433. distance: number;
  116434. /**
  116435. * Gets an already optimized mesh
  116436. */
  116437. optimizeMesh?: boolean;
  116438. }
  116439. /**
  116440. * Class used to specify simplification options
  116441. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116442. */
  116443. export class SimplificationSettings implements ISimplificationSettings {
  116444. /** expected quality */
  116445. quality: number;
  116446. /** distance when this optimized version should be used */
  116447. distance: number;
  116448. /** already optimized mesh */
  116449. optimizeMesh?: boolean | undefined;
  116450. /**
  116451. * Creates a SimplificationSettings
  116452. * @param quality expected quality
  116453. * @param distance distance when this optimized version should be used
  116454. * @param optimizeMesh already optimized mesh
  116455. */
  116456. constructor(
  116457. /** expected quality */
  116458. quality: number,
  116459. /** distance when this optimized version should be used */
  116460. distance: number,
  116461. /** already optimized mesh */
  116462. optimizeMesh?: boolean | undefined);
  116463. }
  116464. /**
  116465. * Interface used to define a simplification task
  116466. */
  116467. export interface ISimplificationTask {
  116468. /**
  116469. * Array of settings
  116470. */
  116471. settings: Array<ISimplificationSettings>;
  116472. /**
  116473. * Simplification type
  116474. */
  116475. simplificationType: SimplificationType;
  116476. /**
  116477. * Mesh to simplify
  116478. */
  116479. mesh: Mesh;
  116480. /**
  116481. * Callback called on success
  116482. */
  116483. successCallback?: () => void;
  116484. /**
  116485. * Defines if parallel processing can be used
  116486. */
  116487. parallelProcessing: boolean;
  116488. }
  116489. /**
  116490. * Queue used to order the simplification tasks
  116491. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116492. */
  116493. export class SimplificationQueue {
  116494. private _simplificationArray;
  116495. /**
  116496. * Gets a boolean indicating that the process is still running
  116497. */
  116498. running: boolean;
  116499. /**
  116500. * Creates a new queue
  116501. */
  116502. constructor();
  116503. /**
  116504. * Adds a new simplification task
  116505. * @param task defines a task to add
  116506. */
  116507. addTask(task: ISimplificationTask): void;
  116508. /**
  116509. * Execute next task
  116510. */
  116511. executeNext(): void;
  116512. /**
  116513. * Execute a simplification task
  116514. * @param task defines the task to run
  116515. */
  116516. runSimplification(task: ISimplificationTask): void;
  116517. private getSimplifier;
  116518. }
  116519. /**
  116520. * The implemented types of simplification
  116521. * At the moment only Quadratic Error Decimation is implemented
  116522. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116523. */
  116524. export enum SimplificationType {
  116525. /** Quadratic error decimation */
  116526. QUADRATIC = 0
  116527. }
  116528. }
  116529. declare module BABYLON {
  116530. interface Scene {
  116531. /** @hidden (Backing field) */
  116532. _simplificationQueue: SimplificationQueue;
  116533. /**
  116534. * Gets or sets the simplification queue attached to the scene
  116535. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116536. */
  116537. simplificationQueue: SimplificationQueue;
  116538. }
  116539. interface Mesh {
  116540. /**
  116541. * Simplify the mesh according to the given array of settings.
  116542. * Function will return immediately and will simplify async
  116543. * @param settings a collection of simplification settings
  116544. * @param parallelProcessing should all levels calculate parallel or one after the other
  116545. * @param simplificationType the type of simplification to run
  116546. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116547. * @returns the current mesh
  116548. */
  116549. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116550. }
  116551. /**
  116552. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116553. * created in a scene
  116554. */
  116555. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116556. /**
  116557. * The component name helpfull to identify the component in the list of scene components.
  116558. */
  116559. readonly name: string;
  116560. /**
  116561. * The scene the component belongs to.
  116562. */
  116563. scene: Scene;
  116564. /**
  116565. * Creates a new instance of the component for the given scene
  116566. * @param scene Defines the scene to register the component in
  116567. */
  116568. constructor(scene: Scene);
  116569. /**
  116570. * Registers the component in a given scene
  116571. */
  116572. register(): void;
  116573. /**
  116574. * Rebuilds the elements related to this component in case of
  116575. * context lost for instance.
  116576. */
  116577. rebuild(): void;
  116578. /**
  116579. * Disposes the component and the associated ressources
  116580. */
  116581. dispose(): void;
  116582. private _beforeCameraUpdate;
  116583. }
  116584. }
  116585. declare module BABYLON {
  116586. /**
  116587. * Class used to enable access to IndexedDB
  116588. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116589. */
  116590. export class Database implements IOfflineProvider {
  116591. private _callbackManifestChecked;
  116592. private _currentSceneUrl;
  116593. private _db;
  116594. private _enableSceneOffline;
  116595. private _enableTexturesOffline;
  116596. private _manifestVersionFound;
  116597. private _mustUpdateRessources;
  116598. private _hasReachedQuota;
  116599. private _isSupported;
  116600. private _idbFactory;
  116601. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116602. private static IsUASupportingBlobStorage;
  116603. /**
  116604. * Gets a boolean indicating if Database storate is enabled (off by default)
  116605. */
  116606. static IDBStorageEnabled: boolean;
  116607. /**
  116608. * Gets a boolean indicating if scene must be saved in the database
  116609. */
  116610. readonly enableSceneOffline: boolean;
  116611. /**
  116612. * Gets a boolean indicating if textures must be saved in the database
  116613. */
  116614. readonly enableTexturesOffline: boolean;
  116615. /**
  116616. * Creates a new Database
  116617. * @param urlToScene defines the url to load the scene
  116618. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116619. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116620. */
  116621. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116622. private static _ParseURL;
  116623. private static _ReturnFullUrlLocation;
  116624. private _checkManifestFile;
  116625. /**
  116626. * Open the database and make it available
  116627. * @param successCallback defines the callback to call on success
  116628. * @param errorCallback defines the callback to call on error
  116629. */
  116630. open(successCallback: () => void, errorCallback: () => void): void;
  116631. /**
  116632. * Loads an image from the database
  116633. * @param url defines the url to load from
  116634. * @param image defines the target DOM image
  116635. */
  116636. loadImage(url: string, image: HTMLImageElement): void;
  116637. private _loadImageFromDBAsync;
  116638. private _saveImageIntoDBAsync;
  116639. private _checkVersionFromDB;
  116640. private _loadVersionFromDBAsync;
  116641. private _saveVersionIntoDBAsync;
  116642. /**
  116643. * Loads a file from database
  116644. * @param url defines the URL to load from
  116645. * @param sceneLoaded defines a callback to call on success
  116646. * @param progressCallBack defines a callback to call when progress changed
  116647. * @param errorCallback defines a callback to call on error
  116648. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116649. */
  116650. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116651. private _loadFileAsync;
  116652. private _saveFileAsync;
  116653. /**
  116654. * Validates if xhr data is correct
  116655. * @param xhr defines the request to validate
  116656. * @param dataType defines the expected data type
  116657. * @returns true if data is correct
  116658. */
  116659. private static _ValidateXHRData;
  116660. }
  116661. }
  116662. declare module BABYLON {
  116663. /** @hidden */
  116664. export var gpuUpdateParticlesPixelShader: {
  116665. name: string;
  116666. shader: string;
  116667. };
  116668. }
  116669. declare module BABYLON {
  116670. /** @hidden */
  116671. export var gpuUpdateParticlesVertexShader: {
  116672. name: string;
  116673. shader: string;
  116674. };
  116675. }
  116676. declare module BABYLON {
  116677. /** @hidden */
  116678. export var clipPlaneFragmentDeclaration2: {
  116679. name: string;
  116680. shader: string;
  116681. };
  116682. }
  116683. declare module BABYLON {
  116684. /** @hidden */
  116685. export var gpuRenderParticlesPixelShader: {
  116686. name: string;
  116687. shader: string;
  116688. };
  116689. }
  116690. declare module BABYLON {
  116691. /** @hidden */
  116692. export var clipPlaneVertexDeclaration2: {
  116693. name: string;
  116694. shader: string;
  116695. };
  116696. }
  116697. declare module BABYLON {
  116698. /** @hidden */
  116699. export var gpuRenderParticlesVertexShader: {
  116700. name: string;
  116701. shader: string;
  116702. };
  116703. }
  116704. declare module BABYLON {
  116705. /**
  116706. * This represents a GPU particle system in Babylon
  116707. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116708. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116709. */
  116710. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116711. /**
  116712. * The layer mask we are rendering the particles through.
  116713. */
  116714. layerMask: number;
  116715. private _capacity;
  116716. private _activeCount;
  116717. private _currentActiveCount;
  116718. private _accumulatedCount;
  116719. private _renderEffect;
  116720. private _updateEffect;
  116721. private _buffer0;
  116722. private _buffer1;
  116723. private _spriteBuffer;
  116724. private _updateVAO;
  116725. private _renderVAO;
  116726. private _targetIndex;
  116727. private _sourceBuffer;
  116728. private _targetBuffer;
  116729. private _engine;
  116730. private _currentRenderId;
  116731. private _started;
  116732. private _stopped;
  116733. private _timeDelta;
  116734. private _randomTexture;
  116735. private _randomTexture2;
  116736. private _attributesStrideSize;
  116737. private _updateEffectOptions;
  116738. private _randomTextureSize;
  116739. private _actualFrame;
  116740. private readonly _rawTextureWidth;
  116741. /**
  116742. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116743. */
  116744. static readonly IsSupported: boolean;
  116745. /**
  116746. * An event triggered when the system is disposed.
  116747. */
  116748. onDisposeObservable: Observable<GPUParticleSystem>;
  116749. /**
  116750. * Gets the maximum number of particles active at the same time.
  116751. * @returns The max number of active particles.
  116752. */
  116753. getCapacity(): number;
  116754. /**
  116755. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116756. * to override the particles.
  116757. */
  116758. forceDepthWrite: boolean;
  116759. /**
  116760. * Gets or set the number of active particles
  116761. */
  116762. activeParticleCount: number;
  116763. private _preWarmDone;
  116764. /**
  116765. * Is this system ready to be used/rendered
  116766. * @return true if the system is ready
  116767. */
  116768. isReady(): boolean;
  116769. /**
  116770. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116771. * @returns True if it has been started, otherwise false.
  116772. */
  116773. isStarted(): boolean;
  116774. /**
  116775. * Starts the particle system and begins to emit
  116776. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116777. */
  116778. start(delay?: number): void;
  116779. /**
  116780. * Stops the particle system.
  116781. */
  116782. stop(): void;
  116783. /**
  116784. * Remove all active particles
  116785. */
  116786. reset(): void;
  116787. /**
  116788. * Returns the string "GPUParticleSystem"
  116789. * @returns a string containing the class name
  116790. */
  116791. getClassName(): string;
  116792. private _colorGradientsTexture;
  116793. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116794. /**
  116795. * Adds a new color gradient
  116796. * @param gradient defines the gradient to use (between 0 and 1)
  116797. * @param color1 defines the color to affect to the specified gradient
  116798. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116799. * @returns the current particle system
  116800. */
  116801. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116802. /**
  116803. * Remove a specific color gradient
  116804. * @param gradient defines the gradient to remove
  116805. * @returns the current particle system
  116806. */
  116807. removeColorGradient(gradient: number): GPUParticleSystem;
  116808. private _angularSpeedGradientsTexture;
  116809. private _sizeGradientsTexture;
  116810. private _velocityGradientsTexture;
  116811. private _limitVelocityGradientsTexture;
  116812. private _dragGradientsTexture;
  116813. private _addFactorGradient;
  116814. /**
  116815. * Adds a new size gradient
  116816. * @param gradient defines the gradient to use (between 0 and 1)
  116817. * @param factor defines the size factor to affect to the specified gradient
  116818. * @returns the current particle system
  116819. */
  116820. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116821. /**
  116822. * Remove a specific size gradient
  116823. * @param gradient defines the gradient to remove
  116824. * @returns the current particle system
  116825. */
  116826. removeSizeGradient(gradient: number): GPUParticleSystem;
  116827. /**
  116828. * Adds a new angular speed gradient
  116829. * @param gradient defines the gradient to use (between 0 and 1)
  116830. * @param factor defines the angular speed to affect to the specified gradient
  116831. * @returns the current particle system
  116832. */
  116833. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116834. /**
  116835. * Remove a specific angular speed gradient
  116836. * @param gradient defines the gradient to remove
  116837. * @returns the current particle system
  116838. */
  116839. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116840. /**
  116841. * Adds a new velocity gradient
  116842. * @param gradient defines the gradient to use (between 0 and 1)
  116843. * @param factor defines the velocity to affect to the specified gradient
  116844. * @returns the current particle system
  116845. */
  116846. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116847. /**
  116848. * Remove a specific velocity gradient
  116849. * @param gradient defines the gradient to remove
  116850. * @returns the current particle system
  116851. */
  116852. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116853. /**
  116854. * Adds a new limit velocity gradient
  116855. * @param gradient defines the gradient to use (between 0 and 1)
  116856. * @param factor defines the limit velocity value to affect to the specified gradient
  116857. * @returns the current particle system
  116858. */
  116859. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116860. /**
  116861. * Remove a specific limit velocity gradient
  116862. * @param gradient defines the gradient to remove
  116863. * @returns the current particle system
  116864. */
  116865. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116866. /**
  116867. * Adds a new drag gradient
  116868. * @param gradient defines the gradient to use (between 0 and 1)
  116869. * @param factor defines the drag value to affect to the specified gradient
  116870. * @returns the current particle system
  116871. */
  116872. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116873. /**
  116874. * Remove a specific drag gradient
  116875. * @param gradient defines the gradient to remove
  116876. * @returns the current particle system
  116877. */
  116878. removeDragGradient(gradient: number): GPUParticleSystem;
  116879. /**
  116880. * Not supported by GPUParticleSystem
  116881. * @param gradient defines the gradient to use (between 0 and 1)
  116882. * @param factor defines the emit rate value to affect to the specified gradient
  116883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116884. * @returns the current particle system
  116885. */
  116886. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116887. /**
  116888. * Not supported by GPUParticleSystem
  116889. * @param gradient defines the gradient to remove
  116890. * @returns the current particle system
  116891. */
  116892. removeEmitRateGradient(gradient: number): IParticleSystem;
  116893. /**
  116894. * Not supported by GPUParticleSystem
  116895. * @param gradient defines the gradient to use (between 0 and 1)
  116896. * @param factor defines the start size value to affect to the specified gradient
  116897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116898. * @returns the current particle system
  116899. */
  116900. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116901. /**
  116902. * Not supported by GPUParticleSystem
  116903. * @param gradient defines the gradient to remove
  116904. * @returns the current particle system
  116905. */
  116906. removeStartSizeGradient(gradient: number): IParticleSystem;
  116907. /**
  116908. * Not supported by GPUParticleSystem
  116909. * @param gradient defines the gradient to use (between 0 and 1)
  116910. * @param min defines the color remap minimal range
  116911. * @param max defines the color remap maximal range
  116912. * @returns the current particle system
  116913. */
  116914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116915. /**
  116916. * Not supported by GPUParticleSystem
  116917. * @param gradient defines the gradient to remove
  116918. * @returns the current particle system
  116919. */
  116920. removeColorRemapGradient(): IParticleSystem;
  116921. /**
  116922. * Not supported by GPUParticleSystem
  116923. * @param gradient defines the gradient to use (between 0 and 1)
  116924. * @param min defines the alpha remap minimal range
  116925. * @param max defines the alpha remap maximal range
  116926. * @returns the current particle system
  116927. */
  116928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116929. /**
  116930. * Not supported by GPUParticleSystem
  116931. * @param gradient defines the gradient to remove
  116932. * @returns the current particle system
  116933. */
  116934. removeAlphaRemapGradient(): IParticleSystem;
  116935. /**
  116936. * Not supported by GPUParticleSystem
  116937. * @param gradient defines the gradient to use (between 0 and 1)
  116938. * @param color defines the color to affect to the specified gradient
  116939. * @returns the current particle system
  116940. */
  116941. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116942. /**
  116943. * Not supported by GPUParticleSystem
  116944. * @param gradient defines the gradient to remove
  116945. * @returns the current particle system
  116946. */
  116947. removeRampGradient(): IParticleSystem;
  116948. /**
  116949. * Not supported by GPUParticleSystem
  116950. * @returns the list of ramp gradients
  116951. */
  116952. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116953. /**
  116954. * Not supported by GPUParticleSystem
  116955. * Gets or sets a boolean indicating that ramp gradients must be used
  116956. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116957. */
  116958. useRampGradients: boolean;
  116959. /**
  116960. * Not supported by GPUParticleSystem
  116961. * @param gradient defines the gradient to use (between 0 and 1)
  116962. * @param factor defines the life time factor to affect to the specified gradient
  116963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116964. * @returns the current particle system
  116965. */
  116966. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116967. /**
  116968. * Not supported by GPUParticleSystem
  116969. * @param gradient defines the gradient to remove
  116970. * @returns the current particle system
  116971. */
  116972. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116973. /**
  116974. * Instantiates a GPU particle system.
  116975. * 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.
  116976. * @param name The name of the particle system
  116977. * @param options The options used to create the system
  116978. * @param scene The scene the particle system belongs to
  116979. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116980. */
  116981. constructor(name: string, options: Partial<{
  116982. capacity: number;
  116983. randomTextureSize: number;
  116984. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116985. protected _reset(): void;
  116986. private _createUpdateVAO;
  116987. private _createRenderVAO;
  116988. private _initialize;
  116989. /** @hidden */
  116990. _recreateUpdateEffect(): void;
  116991. /** @hidden */
  116992. _recreateRenderEffect(): void;
  116993. /**
  116994. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116995. * @param preWarm defines if we are in the pre-warmimg phase
  116996. */
  116997. animate(preWarm?: boolean): void;
  116998. private _createFactorGradientTexture;
  116999. private _createSizeGradientTexture;
  117000. private _createAngularSpeedGradientTexture;
  117001. private _createVelocityGradientTexture;
  117002. private _createLimitVelocityGradientTexture;
  117003. private _createDragGradientTexture;
  117004. private _createColorGradientTexture;
  117005. /**
  117006. * Renders the particle system in its current state
  117007. * @param preWarm defines if the system should only update the particles but not render them
  117008. * @returns the current number of particles
  117009. */
  117010. render(preWarm?: boolean): number;
  117011. /**
  117012. * Rebuilds the particle system
  117013. */
  117014. rebuild(): void;
  117015. private _releaseBuffers;
  117016. private _releaseVAOs;
  117017. /**
  117018. * Disposes the particle system and free the associated resources
  117019. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  117020. */
  117021. dispose(disposeTexture?: boolean): void;
  117022. /**
  117023. * Clones the particle system.
  117024. * @param name The name of the cloned object
  117025. * @param newEmitter The new emitter to use
  117026. * @returns the cloned particle system
  117027. */
  117028. clone(name: string, newEmitter: any): GPUParticleSystem;
  117029. /**
  117030. * Serializes the particle system to a JSON object.
  117031. * @returns the JSON object
  117032. */
  117033. serialize(): any;
  117034. /**
  117035. * Parses a JSON object to create a GPU particle system.
  117036. * @param parsedParticleSystem The JSON object to parse
  117037. * @param scene The scene to create the particle system in
  117038. * @param rootUrl The root url to use to load external dependencies like texture
  117039. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  117040. * @returns the parsed GPU particle system
  117041. */
  117042. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  117043. }
  117044. }
  117045. declare module BABYLON {
  117046. /**
  117047. * Represents a set of particle systems working together to create a specific effect
  117048. */
  117049. export class ParticleSystemSet implements IDisposable {
  117050. private _emitterCreationOptions;
  117051. private _emitterNode;
  117052. /**
  117053. * Gets the particle system list
  117054. */
  117055. systems: IParticleSystem[];
  117056. /**
  117057. * Gets the emitter node used with this set
  117058. */
  117059. readonly emitterNode: Nullable<TransformNode>;
  117060. /**
  117061. * Creates a new emitter mesh as a sphere
  117062. * @param options defines the options used to create the sphere
  117063. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  117064. * @param scene defines the hosting scene
  117065. */
  117066. setEmitterAsSphere(options: {
  117067. diameter: number;
  117068. segments: number;
  117069. color: Color3;
  117070. }, renderingGroupId: number, scene: Scene): void;
  117071. /**
  117072. * Starts all particle systems of the set
  117073. * @param emitter defines an optional mesh to use as emitter for the particle systems
  117074. */
  117075. start(emitter?: AbstractMesh): void;
  117076. /**
  117077. * Release all associated resources
  117078. */
  117079. dispose(): void;
  117080. /**
  117081. * Serialize the set into a JSON compatible object
  117082. * @returns a JSON compatible representation of the set
  117083. */
  117084. serialize(): any;
  117085. /**
  117086. * Parse a new ParticleSystemSet from a serialized source
  117087. * @param data defines a JSON compatible representation of the set
  117088. * @param scene defines the hosting scene
  117089. * @param gpu defines if we want GPU particles or CPU particles
  117090. * @returns a new ParticleSystemSet
  117091. */
  117092. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117093. }
  117094. }
  117095. declare module BABYLON {
  117096. /**
  117097. * This class is made for on one-liner static method to help creating particle system set.
  117098. */
  117099. export class ParticleHelper {
  117100. /**
  117101. * Gets or sets base Assets URL
  117102. */
  117103. static BaseAssetsUrl: string;
  117104. /**
  117105. * Create a default particle system that you can tweak
  117106. * @param emitter defines the emitter to use
  117107. * @param capacity defines the system capacity (default is 500 particles)
  117108. * @param scene defines the hosting scene
  117109. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117110. * @returns the new Particle system
  117111. */
  117112. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117113. /**
  117114. * This is the main static method (one-liner) of this helper to create different particle systems
  117115. * @param type This string represents the type to the particle system to create
  117116. * @param scene The scene where the particle system should live
  117117. * @param gpu If the system will use gpu
  117118. * @returns the ParticleSystemSet created
  117119. */
  117120. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117121. /**
  117122. * Static function used to export a particle system to a ParticleSystemSet variable.
  117123. * Please note that the emitter shape is not exported
  117124. * @param systems defines the particle systems to export
  117125. * @returns the created particle system set
  117126. */
  117127. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117128. }
  117129. }
  117130. declare module BABYLON {
  117131. interface Engine {
  117132. /**
  117133. * Create an effect to use with particle systems.
  117134. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117135. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117136. * @param uniformsNames defines a list of attribute names
  117137. * @param samplers defines an array of string used to represent textures
  117138. * @param defines defines the string containing the defines to use to compile the shaders
  117139. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117140. * @param onCompiled defines a function to call when the effect creation is successful
  117141. * @param onError defines a function to call when the effect creation has failed
  117142. * @returns the new Effect
  117143. */
  117144. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117145. }
  117146. interface Mesh {
  117147. /**
  117148. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117149. * @returns an array of IParticleSystem
  117150. */
  117151. getEmittedParticleSystems(): IParticleSystem[];
  117152. /**
  117153. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117154. * @returns an array of IParticleSystem
  117155. */
  117156. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117157. }
  117158. /**
  117159. * @hidden
  117160. */
  117161. export var _IDoNeedToBeInTheBuild: number;
  117162. }
  117163. declare module BABYLON {
  117164. interface Scene {
  117165. /** @hidden (Backing field) */
  117166. _physicsEngine: Nullable<IPhysicsEngine>;
  117167. /**
  117168. * Gets the current physics engine
  117169. * @returns a IPhysicsEngine or null if none attached
  117170. */
  117171. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117172. /**
  117173. * Enables physics to the current scene
  117174. * @param gravity defines the scene's gravity for the physics engine
  117175. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117176. * @return a boolean indicating if the physics engine was initialized
  117177. */
  117178. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117179. /**
  117180. * Disables and disposes the physics engine associated with the scene
  117181. */
  117182. disablePhysicsEngine(): void;
  117183. /**
  117184. * Gets a boolean indicating if there is an active physics engine
  117185. * @returns a boolean indicating if there is an active physics engine
  117186. */
  117187. isPhysicsEnabled(): boolean;
  117188. /**
  117189. * Deletes a physics compound impostor
  117190. * @param compound defines the compound to delete
  117191. */
  117192. deleteCompoundImpostor(compound: any): void;
  117193. /**
  117194. * An event triggered when physic simulation is about to be run
  117195. */
  117196. onBeforePhysicsObservable: Observable<Scene>;
  117197. /**
  117198. * An event triggered when physic simulation has been done
  117199. */
  117200. onAfterPhysicsObservable: Observable<Scene>;
  117201. }
  117202. interface AbstractMesh {
  117203. /** @hidden */
  117204. _physicsImpostor: Nullable<PhysicsImpostor>;
  117205. /**
  117206. * Gets or sets impostor used for physic simulation
  117207. * @see http://doc.babylonjs.com/features/physics_engine
  117208. */
  117209. physicsImpostor: Nullable<PhysicsImpostor>;
  117210. /**
  117211. * Gets the current physics impostor
  117212. * @see http://doc.babylonjs.com/features/physics_engine
  117213. * @returns a physics impostor or null
  117214. */
  117215. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117216. /** Apply a physic impulse to the mesh
  117217. * @param force defines the force to apply
  117218. * @param contactPoint defines where to apply the force
  117219. * @returns the current mesh
  117220. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117221. */
  117222. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117223. /**
  117224. * Creates a physic joint between two meshes
  117225. * @param otherMesh defines the other mesh to use
  117226. * @param pivot1 defines the pivot to use on this mesh
  117227. * @param pivot2 defines the pivot to use on the other mesh
  117228. * @param options defines additional options (can be plugin dependent)
  117229. * @returns the current mesh
  117230. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117231. */
  117232. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117233. /** @hidden */
  117234. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117235. }
  117236. /**
  117237. * Defines the physics engine scene component responsible to manage a physics engine
  117238. */
  117239. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117240. /**
  117241. * The component name helpful to identify the component in the list of scene components.
  117242. */
  117243. readonly name: string;
  117244. /**
  117245. * The scene the component belongs to.
  117246. */
  117247. scene: Scene;
  117248. /**
  117249. * Creates a new instance of the component for the given scene
  117250. * @param scene Defines the scene to register the component in
  117251. */
  117252. constructor(scene: Scene);
  117253. /**
  117254. * Registers the component in a given scene
  117255. */
  117256. register(): void;
  117257. /**
  117258. * Rebuilds the elements related to this component in case of
  117259. * context lost for instance.
  117260. */
  117261. rebuild(): void;
  117262. /**
  117263. * Disposes the component and the associated ressources
  117264. */
  117265. dispose(): void;
  117266. }
  117267. }
  117268. declare module BABYLON {
  117269. /**
  117270. * A helper for physics simulations
  117271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117272. */
  117273. export class PhysicsHelper {
  117274. private _scene;
  117275. private _physicsEngine;
  117276. /**
  117277. * Initializes the Physics helper
  117278. * @param scene Babylon.js scene
  117279. */
  117280. constructor(scene: Scene);
  117281. /**
  117282. * Applies a radial explosion impulse
  117283. * @param origin the origin of the explosion
  117284. * @param radiusOrEventOptions the radius or the options of radial explosion
  117285. * @param strength the explosion strength
  117286. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117287. * @returns A physics radial explosion event, or null
  117288. */
  117289. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117290. /**
  117291. * Applies a radial explosion force
  117292. * @param origin the origin of the explosion
  117293. * @param radiusOrEventOptions the radius or the options of radial explosion
  117294. * @param strength the explosion strength
  117295. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117296. * @returns A physics radial explosion event, or null
  117297. */
  117298. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117299. /**
  117300. * Creates a gravitational field
  117301. * @param origin the origin of the explosion
  117302. * @param radiusOrEventOptions the radius or the options of radial explosion
  117303. * @param strength the explosion strength
  117304. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117305. * @returns A physics gravitational field event, or null
  117306. */
  117307. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117308. /**
  117309. * Creates a physics updraft event
  117310. * @param origin the origin of the updraft
  117311. * @param radiusOrEventOptions the radius or the options of the updraft
  117312. * @param strength the strength of the updraft
  117313. * @param height the height of the updraft
  117314. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117315. * @returns A physics updraft event, or null
  117316. */
  117317. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117318. /**
  117319. * Creates a physics vortex event
  117320. * @param origin the of the vortex
  117321. * @param radiusOrEventOptions the radius or the options of the vortex
  117322. * @param strength the strength of the vortex
  117323. * @param height the height of the vortex
  117324. * @returns a Physics vortex event, or null
  117325. * A physics vortex event or null
  117326. */
  117327. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117328. }
  117329. /**
  117330. * Represents a physics radial explosion event
  117331. */
  117332. class PhysicsRadialExplosionEvent {
  117333. private _scene;
  117334. private _options;
  117335. private _sphere;
  117336. private _dataFetched;
  117337. /**
  117338. * Initializes a radial explosioin event
  117339. * @param _scene BabylonJS scene
  117340. * @param _options The options for the vortex event
  117341. */
  117342. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117343. /**
  117344. * Returns the data related to the radial explosion event (sphere).
  117345. * @returns The radial explosion event data
  117346. */
  117347. getData(): PhysicsRadialExplosionEventData;
  117348. /**
  117349. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117350. * @param impostor A physics imposter
  117351. * @param origin the origin of the explosion
  117352. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117353. */
  117354. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117355. /**
  117356. * Triggers affecterd impostors callbacks
  117357. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117358. */
  117359. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117360. /**
  117361. * Disposes the sphere.
  117362. * @param force Specifies if the sphere should be disposed by force
  117363. */
  117364. dispose(force?: boolean): void;
  117365. /*** Helpers ***/
  117366. private _prepareSphere;
  117367. private _intersectsWithSphere;
  117368. }
  117369. /**
  117370. * Represents a gravitational field event
  117371. */
  117372. class PhysicsGravitationalFieldEvent {
  117373. private _physicsHelper;
  117374. private _scene;
  117375. private _origin;
  117376. private _options;
  117377. private _tickCallback;
  117378. private _sphere;
  117379. private _dataFetched;
  117380. /**
  117381. * Initializes the physics gravitational field event
  117382. * @param _physicsHelper A physics helper
  117383. * @param _scene BabylonJS scene
  117384. * @param _origin The origin position of the gravitational field event
  117385. * @param _options The options for the vortex event
  117386. */
  117387. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117388. /**
  117389. * Returns the data related to the gravitational field event (sphere).
  117390. * @returns A gravitational field event
  117391. */
  117392. getData(): PhysicsGravitationalFieldEventData;
  117393. /**
  117394. * Enables the gravitational field.
  117395. */
  117396. enable(): void;
  117397. /**
  117398. * Disables the gravitational field.
  117399. */
  117400. disable(): void;
  117401. /**
  117402. * Disposes the sphere.
  117403. * @param force The force to dispose from the gravitational field event
  117404. */
  117405. dispose(force?: boolean): void;
  117406. private _tick;
  117407. }
  117408. /**
  117409. * Represents a physics updraft event
  117410. */
  117411. class PhysicsUpdraftEvent {
  117412. private _scene;
  117413. private _origin;
  117414. private _options;
  117415. private _physicsEngine;
  117416. private _originTop;
  117417. private _originDirection;
  117418. private _tickCallback;
  117419. private _cylinder;
  117420. private _cylinderPosition;
  117421. private _dataFetched;
  117422. /**
  117423. * Initializes the physics updraft event
  117424. * @param _scene BabylonJS scene
  117425. * @param _origin The origin position of the updraft
  117426. * @param _options The options for the updraft event
  117427. */
  117428. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117429. /**
  117430. * Returns the data related to the updraft event (cylinder).
  117431. * @returns A physics updraft event
  117432. */
  117433. getData(): PhysicsUpdraftEventData;
  117434. /**
  117435. * Enables the updraft.
  117436. */
  117437. enable(): void;
  117438. /**
  117439. * Disables the updraft.
  117440. */
  117441. disable(): void;
  117442. /**
  117443. * Disposes the cylinder.
  117444. * @param force Specifies if the updraft should be disposed by force
  117445. */
  117446. dispose(force?: boolean): void;
  117447. private getImpostorHitData;
  117448. private _tick;
  117449. /*** Helpers ***/
  117450. private _prepareCylinder;
  117451. private _intersectsWithCylinder;
  117452. }
  117453. /**
  117454. * Represents a physics vortex event
  117455. */
  117456. class PhysicsVortexEvent {
  117457. private _scene;
  117458. private _origin;
  117459. private _options;
  117460. private _physicsEngine;
  117461. private _originTop;
  117462. private _tickCallback;
  117463. private _cylinder;
  117464. private _cylinderPosition;
  117465. private _dataFetched;
  117466. /**
  117467. * Initializes the physics vortex event
  117468. * @param _scene The BabylonJS scene
  117469. * @param _origin The origin position of the vortex
  117470. * @param _options The options for the vortex event
  117471. */
  117472. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117473. /**
  117474. * Returns the data related to the vortex event (cylinder).
  117475. * @returns The physics vortex event data
  117476. */
  117477. getData(): PhysicsVortexEventData;
  117478. /**
  117479. * Enables the vortex.
  117480. */
  117481. enable(): void;
  117482. /**
  117483. * Disables the cortex.
  117484. */
  117485. disable(): void;
  117486. /**
  117487. * Disposes the sphere.
  117488. * @param force
  117489. */
  117490. dispose(force?: boolean): void;
  117491. private getImpostorHitData;
  117492. private _tick;
  117493. /*** Helpers ***/
  117494. private _prepareCylinder;
  117495. private _intersectsWithCylinder;
  117496. }
  117497. /**
  117498. * Options fot the radial explosion event
  117499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117500. */
  117501. export class PhysicsRadialExplosionEventOptions {
  117502. /**
  117503. * The radius of the sphere for the radial explosion.
  117504. */
  117505. radius: number;
  117506. /**
  117507. * The strenth of the explosion.
  117508. */
  117509. strength: number;
  117510. /**
  117511. * The strenght of the force in correspondence to the distance of the affected object
  117512. */
  117513. falloff: PhysicsRadialImpulseFalloff;
  117514. /**
  117515. * Sphere options for the radial explosion.
  117516. */
  117517. sphere: {
  117518. segments: number;
  117519. diameter: number;
  117520. };
  117521. /**
  117522. * Sphere options for the radial explosion.
  117523. */
  117524. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117525. }
  117526. /**
  117527. * Options fot the updraft event
  117528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117529. */
  117530. export class PhysicsUpdraftEventOptions {
  117531. /**
  117532. * The radius of the cylinder for the vortex
  117533. */
  117534. radius: number;
  117535. /**
  117536. * The strenth of the updraft.
  117537. */
  117538. strength: number;
  117539. /**
  117540. * The height of the cylinder for the updraft.
  117541. */
  117542. height: number;
  117543. /**
  117544. * The mode for the the updraft.
  117545. */
  117546. updraftMode: PhysicsUpdraftMode;
  117547. }
  117548. /**
  117549. * Options fot the vortex event
  117550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117551. */
  117552. export class PhysicsVortexEventOptions {
  117553. /**
  117554. * The radius of the cylinder for the vortex
  117555. */
  117556. radius: number;
  117557. /**
  117558. * The strenth of the vortex.
  117559. */
  117560. strength: number;
  117561. /**
  117562. * The height of the cylinder for the vortex.
  117563. */
  117564. height: number;
  117565. /**
  117566. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117567. */
  117568. centripetalForceThreshold: number;
  117569. /**
  117570. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117571. */
  117572. centripetalForceMultiplier: number;
  117573. /**
  117574. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117575. */
  117576. centrifugalForceMultiplier: number;
  117577. /**
  117578. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117579. */
  117580. updraftForceMultiplier: number;
  117581. }
  117582. /**
  117583. * The strenght of the force in correspondence to the distance of the affected object
  117584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117585. */
  117586. export enum PhysicsRadialImpulseFalloff {
  117587. /** Defines that impulse is constant in strength across it's whole radius */
  117588. Constant = 0,
  117589. /** Defines that impulse gets weaker if it's further from the origin */
  117590. Linear = 1
  117591. }
  117592. /**
  117593. * The strength of the force in correspondence to the distance of the affected object
  117594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117595. */
  117596. export enum PhysicsUpdraftMode {
  117597. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117598. Center = 0,
  117599. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117600. Perpendicular = 1
  117601. }
  117602. /**
  117603. * Interface for a physics hit data
  117604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117605. */
  117606. export interface PhysicsHitData {
  117607. /**
  117608. * The force applied at the contact point
  117609. */
  117610. force: Vector3;
  117611. /**
  117612. * The contact point
  117613. */
  117614. contactPoint: Vector3;
  117615. /**
  117616. * The distance from the origin to the contact point
  117617. */
  117618. distanceFromOrigin: number;
  117619. }
  117620. /**
  117621. * Interface for radial explosion event data
  117622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117623. */
  117624. export interface PhysicsRadialExplosionEventData {
  117625. /**
  117626. * A sphere used for the radial explosion event
  117627. */
  117628. sphere: Mesh;
  117629. }
  117630. /**
  117631. * Interface for gravitational field event data
  117632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117633. */
  117634. export interface PhysicsGravitationalFieldEventData {
  117635. /**
  117636. * A sphere mesh used for the gravitational field event
  117637. */
  117638. sphere: Mesh;
  117639. }
  117640. /**
  117641. * Interface for updraft event data
  117642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117643. */
  117644. export interface PhysicsUpdraftEventData {
  117645. /**
  117646. * A cylinder used for the updraft event
  117647. */
  117648. cylinder: Mesh;
  117649. }
  117650. /**
  117651. * Interface for vortex event data
  117652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117653. */
  117654. export interface PhysicsVortexEventData {
  117655. /**
  117656. * A cylinder used for the vortex event
  117657. */
  117658. cylinder: Mesh;
  117659. }
  117660. /**
  117661. * Interface for an affected physics impostor
  117662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117663. */
  117664. export interface PhysicsAffectedImpostorWithData {
  117665. /**
  117666. * The impostor affected by the effect
  117667. */
  117668. impostor: PhysicsImpostor;
  117669. /**
  117670. * The data about the hit/horce from the explosion
  117671. */
  117672. hitData: PhysicsHitData;
  117673. }
  117674. }
  117675. declare module BABYLON {
  117676. /** @hidden */
  117677. export var blackAndWhitePixelShader: {
  117678. name: string;
  117679. shader: string;
  117680. };
  117681. }
  117682. declare module BABYLON {
  117683. /**
  117684. * Post process used to render in black and white
  117685. */
  117686. export class BlackAndWhitePostProcess extends PostProcess {
  117687. /**
  117688. * Linear about to convert he result to black and white (default: 1)
  117689. */
  117690. degree: number;
  117691. /**
  117692. * Creates a black and white post process
  117693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117694. * @param name The name of the effect.
  117695. * @param options The required width/height ratio to downsize to before computing the render pass.
  117696. * @param camera The camera to apply the render pass to.
  117697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117698. * @param engine The engine which the post process will be applied. (default: current engine)
  117699. * @param reusable If the post process can be reused on the same frame. (default: false)
  117700. */
  117701. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117702. }
  117703. }
  117704. declare module BABYLON {
  117705. /**
  117706. * This represents a set of one or more post processes in Babylon.
  117707. * A post process can be used to apply a shader to a texture after it is rendered.
  117708. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117709. */
  117710. export class PostProcessRenderEffect {
  117711. private _postProcesses;
  117712. private _getPostProcesses;
  117713. private _singleInstance;
  117714. private _cameras;
  117715. private _indicesForCamera;
  117716. /**
  117717. * Name of the effect
  117718. * @hidden
  117719. */
  117720. _name: string;
  117721. /**
  117722. * Instantiates a post process render effect.
  117723. * A post process can be used to apply a shader to a texture after it is rendered.
  117724. * @param engine The engine the effect is tied to
  117725. * @param name The name of the effect
  117726. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117727. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117728. */
  117729. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117730. /**
  117731. * Checks if all the post processes in the effect are supported.
  117732. */
  117733. readonly isSupported: boolean;
  117734. /**
  117735. * Updates the current state of the effect
  117736. * @hidden
  117737. */
  117738. _update(): void;
  117739. /**
  117740. * Attaches the effect on cameras
  117741. * @param cameras The camera to attach to.
  117742. * @hidden
  117743. */
  117744. _attachCameras(cameras: Camera): void;
  117745. /**
  117746. * Attaches the effect on cameras
  117747. * @param cameras The camera to attach to.
  117748. * @hidden
  117749. */
  117750. _attachCameras(cameras: Camera[]): void;
  117751. /**
  117752. * Detaches the effect on cameras
  117753. * @param cameras The camera to detatch from.
  117754. * @hidden
  117755. */
  117756. _detachCameras(cameras: Camera): void;
  117757. /**
  117758. * Detatches the effect on cameras
  117759. * @param cameras The camera to detatch from.
  117760. * @hidden
  117761. */
  117762. _detachCameras(cameras: Camera[]): void;
  117763. /**
  117764. * Enables the effect on given cameras
  117765. * @param cameras The camera to enable.
  117766. * @hidden
  117767. */
  117768. _enable(cameras: Camera): void;
  117769. /**
  117770. * Enables the effect on given cameras
  117771. * @param cameras The camera to enable.
  117772. * @hidden
  117773. */
  117774. _enable(cameras: Nullable<Camera[]>): void;
  117775. /**
  117776. * Disables the effect on the given cameras
  117777. * @param cameras The camera to disable.
  117778. * @hidden
  117779. */
  117780. _disable(cameras: Camera): void;
  117781. /**
  117782. * Disables the effect on the given cameras
  117783. * @param cameras The camera to disable.
  117784. * @hidden
  117785. */
  117786. _disable(cameras: Nullable<Camera[]>): void;
  117787. /**
  117788. * Gets a list of the post processes contained in the effect.
  117789. * @param camera The camera to get the post processes on.
  117790. * @returns The list of the post processes in the effect.
  117791. */
  117792. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117793. }
  117794. }
  117795. declare module BABYLON {
  117796. /** @hidden */
  117797. export var extractHighlightsPixelShader: {
  117798. name: string;
  117799. shader: string;
  117800. };
  117801. }
  117802. declare module BABYLON {
  117803. /**
  117804. * 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.
  117805. */
  117806. export class ExtractHighlightsPostProcess extends PostProcess {
  117807. /**
  117808. * The luminance threshold, pixels below this value will be set to black.
  117809. */
  117810. threshold: number;
  117811. /** @hidden */
  117812. _exposure: number;
  117813. /**
  117814. * Post process which has the input texture to be used when performing highlight extraction
  117815. * @hidden
  117816. */
  117817. _inputPostProcess: Nullable<PostProcess>;
  117818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117819. }
  117820. }
  117821. declare module BABYLON {
  117822. /** @hidden */
  117823. export var bloomMergePixelShader: {
  117824. name: string;
  117825. shader: string;
  117826. };
  117827. }
  117828. declare module BABYLON {
  117829. /**
  117830. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117831. */
  117832. export class BloomMergePostProcess extends PostProcess {
  117833. /** Weight of the bloom to be added to the original input. */
  117834. weight: number;
  117835. /**
  117836. * Creates a new instance of @see BloomMergePostProcess
  117837. * @param name The name of the effect.
  117838. * @param originalFromInput Post process which's input will be used for the merge.
  117839. * @param blurred Blurred highlights post process which's output will be used.
  117840. * @param weight Weight of the bloom to be added to the original input.
  117841. * @param options The required width/height ratio to downsize to before computing the render pass.
  117842. * @param camera The camera to apply the render pass to.
  117843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117844. * @param engine The engine which the post process will be applied. (default: current engine)
  117845. * @param reusable If the post process can be reused on the same frame. (default: false)
  117846. * @param textureType Type of textures used when performing the post process. (default: 0)
  117847. * @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)
  117848. */
  117849. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117850. /** Weight of the bloom to be added to the original input. */
  117851. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117852. }
  117853. }
  117854. declare module BABYLON {
  117855. /**
  117856. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117857. */
  117858. export class BloomEffect extends PostProcessRenderEffect {
  117859. private bloomScale;
  117860. /**
  117861. * @hidden Internal
  117862. */
  117863. _effects: Array<PostProcess>;
  117864. /**
  117865. * @hidden Internal
  117866. */
  117867. _downscale: ExtractHighlightsPostProcess;
  117868. private _blurX;
  117869. private _blurY;
  117870. private _merge;
  117871. /**
  117872. * The luminance threshold to find bright areas of the image to bloom.
  117873. */
  117874. threshold: number;
  117875. /**
  117876. * The strength of the bloom.
  117877. */
  117878. weight: number;
  117879. /**
  117880. * Specifies the size of the bloom blur kernel, relative to the final output size
  117881. */
  117882. kernel: number;
  117883. /**
  117884. * Creates a new instance of @see BloomEffect
  117885. * @param scene The scene the effect belongs to.
  117886. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117887. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117888. * @param bloomWeight The the strength of bloom.
  117889. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117890. * @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)
  117891. */
  117892. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117893. /**
  117894. * Disposes each of the internal effects for a given camera.
  117895. * @param camera The camera to dispose the effect on.
  117896. */
  117897. disposeEffects(camera: Camera): void;
  117898. /**
  117899. * @hidden Internal
  117900. */
  117901. _updateEffects(): void;
  117902. /**
  117903. * Internal
  117904. * @returns if all the contained post processes are ready.
  117905. * @hidden
  117906. */
  117907. _isReady(): boolean;
  117908. }
  117909. }
  117910. declare module BABYLON {
  117911. /** @hidden */
  117912. export var chromaticAberrationPixelShader: {
  117913. name: string;
  117914. shader: string;
  117915. };
  117916. }
  117917. declare module BABYLON {
  117918. /**
  117919. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117920. */
  117921. export class ChromaticAberrationPostProcess extends PostProcess {
  117922. /**
  117923. * The amount of seperation of rgb channels (default: 30)
  117924. */
  117925. aberrationAmount: number;
  117926. /**
  117927. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117928. */
  117929. radialIntensity: number;
  117930. /**
  117931. * 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))
  117932. */
  117933. direction: Vector2;
  117934. /**
  117935. * 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))
  117936. */
  117937. centerPosition: Vector2;
  117938. /**
  117939. * Creates a new instance ChromaticAberrationPostProcess
  117940. * @param name The name of the effect.
  117941. * @param screenWidth The width of the screen to apply the effect on.
  117942. * @param screenHeight The height of the screen to apply the effect on.
  117943. * @param options The required width/height ratio to downsize to before computing the render pass.
  117944. * @param camera The camera to apply the render pass to.
  117945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117946. * @param engine The engine which the post process will be applied. (default: current engine)
  117947. * @param reusable If the post process can be reused on the same frame. (default: false)
  117948. * @param textureType Type of textures used when performing the post process. (default: 0)
  117949. * @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)
  117950. */
  117951. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. /** @hidden */
  117956. export var circleOfConfusionPixelShader: {
  117957. name: string;
  117958. shader: string;
  117959. };
  117960. }
  117961. declare module BABYLON {
  117962. /**
  117963. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117964. */
  117965. export class CircleOfConfusionPostProcess extends PostProcess {
  117966. /**
  117967. * 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.
  117968. */
  117969. lensSize: number;
  117970. /**
  117971. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117972. */
  117973. fStop: number;
  117974. /**
  117975. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117976. */
  117977. focusDistance: number;
  117978. /**
  117979. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117980. */
  117981. focalLength: number;
  117982. private _depthTexture;
  117983. /**
  117984. * Creates a new instance CircleOfConfusionPostProcess
  117985. * @param name The name of the effect.
  117986. * @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.
  117987. * @param options The required width/height ratio to downsize to before computing the render pass.
  117988. * @param camera The camera to apply the render pass to.
  117989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117990. * @param engine The engine which the post process will be applied. (default: current engine)
  117991. * @param reusable If the post process can be reused on the same frame. (default: false)
  117992. * @param textureType Type of textures used when performing the post process. (default: 0)
  117993. * @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)
  117994. */
  117995. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117996. /**
  117997. * 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.
  117998. */
  117999. depthTexture: RenderTargetTexture;
  118000. }
  118001. }
  118002. declare module BABYLON {
  118003. /** @hidden */
  118004. export var colorCorrectionPixelShader: {
  118005. name: string;
  118006. shader: string;
  118007. };
  118008. }
  118009. declare module BABYLON {
  118010. /**
  118011. *
  118012. * This post-process allows the modification of rendered colors by using
  118013. * a 'look-up table' (LUT). This effect is also called Color Grading.
  118014. *
  118015. * The object needs to be provided an url to a texture containing the color
  118016. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  118017. * Use an image editing software to tweak the LUT to match your needs.
  118018. *
  118019. * For an example of a color LUT, see here:
  118020. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  118021. * For explanations on color grading, see here:
  118022. * @see http://udn.epicgames.com/Three/ColorGrading.html
  118023. *
  118024. */
  118025. export class ColorCorrectionPostProcess extends PostProcess {
  118026. private _colorTableTexture;
  118027. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118028. }
  118029. }
  118030. declare module BABYLON {
  118031. /** @hidden */
  118032. export var convolutionPixelShader: {
  118033. name: string;
  118034. shader: string;
  118035. };
  118036. }
  118037. declare module BABYLON {
  118038. /**
  118039. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  118040. * input texture to perform effects such as edge detection or sharpening
  118041. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118042. */
  118043. export class ConvolutionPostProcess extends PostProcess {
  118044. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118045. kernel: number[];
  118046. /**
  118047. * Creates a new instance ConvolutionPostProcess
  118048. * @param name The name of the effect.
  118049. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  118050. * @param options The required width/height ratio to downsize to before computing the render pass.
  118051. * @param camera The camera to apply the render pass to.
  118052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118053. * @param engine The engine which the post process will be applied. (default: current engine)
  118054. * @param reusable If the post process can be reused on the same frame. (default: false)
  118055. * @param textureType Type of textures used when performing the post process. (default: 0)
  118056. */
  118057. constructor(name: string,
  118058. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  118059. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118060. /**
  118061. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118062. */
  118063. static EdgeDetect0Kernel: number[];
  118064. /**
  118065. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118066. */
  118067. static EdgeDetect1Kernel: number[];
  118068. /**
  118069. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118070. */
  118071. static EdgeDetect2Kernel: number[];
  118072. /**
  118073. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118074. */
  118075. static SharpenKernel: number[];
  118076. /**
  118077. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118078. */
  118079. static EmbossKernel: number[];
  118080. /**
  118081. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  118082. */
  118083. static GaussianKernel: number[];
  118084. }
  118085. }
  118086. declare module BABYLON {
  118087. /**
  118088. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118089. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118090. * based on samples that have a large difference in distance than the center pixel.
  118091. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118092. */
  118093. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118094. direction: Vector2;
  118095. /**
  118096. * Creates a new instance CircleOfConfusionPostProcess
  118097. * @param name The name of the effect.
  118098. * @param scene The scene the effect belongs to.
  118099. * @param direction The direction the blur should be applied.
  118100. * @param kernel The size of the kernel used to blur.
  118101. * @param options The required width/height ratio to downsize to before computing the render pass.
  118102. * @param camera The camera to apply the render pass to.
  118103. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118104. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118106. * @param engine The engine which the post process will be applied. (default: current engine)
  118107. * @param reusable If the post process can be reused on the same frame. (default: false)
  118108. * @param textureType Type of textures used when performing the post process. (default: 0)
  118109. * @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)
  118110. */
  118111. 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);
  118112. }
  118113. }
  118114. declare module BABYLON {
  118115. /** @hidden */
  118116. export var depthOfFieldMergePixelShader: {
  118117. name: string;
  118118. shader: string;
  118119. };
  118120. }
  118121. declare module BABYLON {
  118122. /**
  118123. * Options to be set when merging outputs from the default pipeline.
  118124. */
  118125. export class DepthOfFieldMergePostProcessOptions {
  118126. /**
  118127. * The original image to merge on top of
  118128. */
  118129. originalFromInput: PostProcess;
  118130. /**
  118131. * Parameters to perform the merge of the depth of field effect
  118132. */
  118133. depthOfField?: {
  118134. circleOfConfusion: PostProcess;
  118135. blurSteps: Array<PostProcess>;
  118136. };
  118137. /**
  118138. * Parameters to perform the merge of bloom effect
  118139. */
  118140. bloom?: {
  118141. blurred: PostProcess;
  118142. weight: number;
  118143. };
  118144. }
  118145. /**
  118146. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118147. */
  118148. export class DepthOfFieldMergePostProcess extends PostProcess {
  118149. private blurSteps;
  118150. /**
  118151. * Creates a new instance of DepthOfFieldMergePostProcess
  118152. * @param name The name of the effect.
  118153. * @param originalFromInput Post process which's input will be used for the merge.
  118154. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118155. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118156. * @param options The required width/height ratio to downsize to before computing the render pass.
  118157. * @param camera The camera to apply the render pass to.
  118158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118159. * @param engine The engine which the post process will be applied. (default: current engine)
  118160. * @param reusable If the post process can be reused on the same frame. (default: false)
  118161. * @param textureType Type of textures used when performing the post process. (default: 0)
  118162. * @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)
  118163. */
  118164. 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);
  118165. /**
  118166. * Updates the effect with the current post process compile time values and recompiles the shader.
  118167. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118168. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118169. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118170. * @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
  118171. * @param onCompiled Called when the shader has been compiled.
  118172. * @param onError Called if there is an error when compiling a shader.
  118173. */
  118174. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118175. }
  118176. }
  118177. declare module BABYLON {
  118178. /**
  118179. * Specifies the level of max blur that should be applied when using the depth of field effect
  118180. */
  118181. export enum DepthOfFieldEffectBlurLevel {
  118182. /**
  118183. * Subtle blur
  118184. */
  118185. Low = 0,
  118186. /**
  118187. * Medium blur
  118188. */
  118189. Medium = 1,
  118190. /**
  118191. * Large blur
  118192. */
  118193. High = 2
  118194. }
  118195. /**
  118196. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118197. */
  118198. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118199. private _circleOfConfusion;
  118200. /**
  118201. * @hidden Internal, blurs from high to low
  118202. */
  118203. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118204. private _depthOfFieldBlurY;
  118205. private _dofMerge;
  118206. /**
  118207. * @hidden Internal post processes in depth of field effect
  118208. */
  118209. _effects: Array<PostProcess>;
  118210. /**
  118211. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118212. */
  118213. focalLength: number;
  118214. /**
  118215. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118216. */
  118217. fStop: number;
  118218. /**
  118219. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118220. */
  118221. focusDistance: number;
  118222. /**
  118223. * 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.
  118224. */
  118225. lensSize: number;
  118226. /**
  118227. * Creates a new instance DepthOfFieldEffect
  118228. * @param scene The scene the effect belongs to.
  118229. * @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.
  118230. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118231. * @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)
  118232. */
  118233. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118234. /**
  118235. * Get the current class name of the current effet
  118236. * @returns "DepthOfFieldEffect"
  118237. */
  118238. getClassName(): string;
  118239. /**
  118240. * 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.
  118241. */
  118242. depthTexture: RenderTargetTexture;
  118243. /**
  118244. * Disposes each of the internal effects for a given camera.
  118245. * @param camera The camera to dispose the effect on.
  118246. */
  118247. disposeEffects(camera: Camera): void;
  118248. /**
  118249. * @hidden Internal
  118250. */
  118251. _updateEffects(): void;
  118252. /**
  118253. * Internal
  118254. * @returns if all the contained post processes are ready.
  118255. * @hidden
  118256. */
  118257. _isReady(): boolean;
  118258. }
  118259. }
  118260. declare module BABYLON {
  118261. /** @hidden */
  118262. export var displayPassPixelShader: {
  118263. name: string;
  118264. shader: string;
  118265. };
  118266. }
  118267. declare module BABYLON {
  118268. /**
  118269. * DisplayPassPostProcess which produces an output the same as it's input
  118270. */
  118271. export class DisplayPassPostProcess extends PostProcess {
  118272. /**
  118273. * Creates the DisplayPassPostProcess
  118274. * @param name The name of the effect.
  118275. * @param options The required width/height ratio to downsize to before computing the render pass.
  118276. * @param camera The camera to apply the render pass to.
  118277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118278. * @param engine The engine which the post process will be applied. (default: current engine)
  118279. * @param reusable If the post process can be reused on the same frame. (default: false)
  118280. */
  118281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118282. }
  118283. }
  118284. declare module BABYLON {
  118285. /** @hidden */
  118286. export var filterPixelShader: {
  118287. name: string;
  118288. shader: string;
  118289. };
  118290. }
  118291. declare module BABYLON {
  118292. /**
  118293. * Applies a kernel filter to the image
  118294. */
  118295. export class FilterPostProcess extends PostProcess {
  118296. /** The matrix to be applied to the image */
  118297. kernelMatrix: Matrix;
  118298. /**
  118299. *
  118300. * @param name The name of the effect.
  118301. * @param kernelMatrix The matrix to be applied to the image
  118302. * @param options The required width/height ratio to downsize to before computing the render pass.
  118303. * @param camera The camera to apply the render pass to.
  118304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118305. * @param engine The engine which the post process will be applied. (default: current engine)
  118306. * @param reusable If the post process can be reused on the same frame. (default: false)
  118307. */
  118308. constructor(name: string,
  118309. /** The matrix to be applied to the image */
  118310. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118311. }
  118312. }
  118313. declare module BABYLON {
  118314. /** @hidden */
  118315. export var fxaaPixelShader: {
  118316. name: string;
  118317. shader: string;
  118318. };
  118319. }
  118320. declare module BABYLON {
  118321. /** @hidden */
  118322. export var fxaaVertexShader: {
  118323. name: string;
  118324. shader: string;
  118325. };
  118326. }
  118327. declare module BABYLON {
  118328. /**
  118329. * Fxaa post process
  118330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118331. */
  118332. export class FxaaPostProcess extends PostProcess {
  118333. /** @hidden */
  118334. texelWidth: number;
  118335. /** @hidden */
  118336. texelHeight: number;
  118337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118338. private _getDefines;
  118339. }
  118340. }
  118341. declare module BABYLON {
  118342. /** @hidden */
  118343. export var grainPixelShader: {
  118344. name: string;
  118345. shader: string;
  118346. };
  118347. }
  118348. declare module BABYLON {
  118349. /**
  118350. * The GrainPostProcess adds noise to the image at mid luminance levels
  118351. */
  118352. export class GrainPostProcess extends PostProcess {
  118353. /**
  118354. * The intensity of the grain added (default: 30)
  118355. */
  118356. intensity: number;
  118357. /**
  118358. * If the grain should be randomized on every frame
  118359. */
  118360. animated: boolean;
  118361. /**
  118362. * Creates a new instance of @see GrainPostProcess
  118363. * @param name The name of the effect.
  118364. * @param options The required width/height ratio to downsize to before computing the render pass.
  118365. * @param camera The camera to apply the render pass to.
  118366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118367. * @param engine The engine which the post process will be applied. (default: current engine)
  118368. * @param reusable If the post process can be reused on the same frame. (default: false)
  118369. * @param textureType Type of textures used when performing the post process. (default: 0)
  118370. * @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)
  118371. */
  118372. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118373. }
  118374. }
  118375. declare module BABYLON {
  118376. /** @hidden */
  118377. export var highlightsPixelShader: {
  118378. name: string;
  118379. shader: string;
  118380. };
  118381. }
  118382. declare module BABYLON {
  118383. /**
  118384. * Extracts highlights from the image
  118385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118386. */
  118387. export class HighlightsPostProcess extends PostProcess {
  118388. /**
  118389. * Extracts highlights from the image
  118390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118391. * @param name The name of the effect.
  118392. * @param options The required width/height ratio to downsize to before computing the render pass.
  118393. * @param camera The camera to apply the render pass to.
  118394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118395. * @param engine The engine which the post process will be applied. (default: current engine)
  118396. * @param reusable If the post process can be reused on the same frame. (default: false)
  118397. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118398. */
  118399. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118400. }
  118401. }
  118402. declare module BABYLON {
  118403. /** @hidden */
  118404. export var mrtFragmentDeclaration: {
  118405. name: string;
  118406. shader: string;
  118407. };
  118408. }
  118409. declare module BABYLON {
  118410. /** @hidden */
  118411. export var geometryPixelShader: {
  118412. name: string;
  118413. shader: string;
  118414. };
  118415. }
  118416. declare module BABYLON {
  118417. /** @hidden */
  118418. export var geometryVertexShader: {
  118419. name: string;
  118420. shader: string;
  118421. };
  118422. }
  118423. declare module BABYLON {
  118424. /** @hidden */
  118425. interface ISavedTransformationMatrix {
  118426. world: Matrix;
  118427. viewProjection: Matrix;
  118428. }
  118429. /**
  118430. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118431. */
  118432. export class GeometryBufferRenderer {
  118433. /**
  118434. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118435. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118436. */
  118437. static readonly POSITION_TEXTURE_TYPE: number;
  118438. /**
  118439. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118440. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118441. */
  118442. static readonly VELOCITY_TEXTURE_TYPE: number;
  118443. /**
  118444. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118445. * in order to compute objects velocities when enableVelocity is set to "true"
  118446. * @hidden
  118447. */
  118448. _previousTransformationMatrices: {
  118449. [index: number]: ISavedTransformationMatrix;
  118450. };
  118451. /**
  118452. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118453. * in order to compute objects velocities when enableVelocity is set to "true"
  118454. * @hidden
  118455. */
  118456. _previousBonesTransformationMatrices: {
  118457. [index: number]: Float32Array;
  118458. };
  118459. /**
  118460. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118461. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118462. */
  118463. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118464. private _scene;
  118465. private _multiRenderTarget;
  118466. private _ratio;
  118467. private _enablePosition;
  118468. private _enableVelocity;
  118469. private _positionIndex;
  118470. private _velocityIndex;
  118471. protected _effect: Effect;
  118472. protected _cachedDefines: string;
  118473. /**
  118474. * Set the render list (meshes to be rendered) used in the G buffer.
  118475. */
  118476. renderList: Mesh[];
  118477. /**
  118478. * Gets wether or not G buffer are supported by the running hardware.
  118479. * This requires draw buffer supports
  118480. */
  118481. readonly isSupported: boolean;
  118482. /**
  118483. * Returns the index of the given texture type in the G-Buffer textures array
  118484. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118485. * @returns the index of the given texture type in the G-Buffer textures array
  118486. */
  118487. getTextureIndex(textureType: number): number;
  118488. /**
  118489. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118490. */
  118491. /**
  118492. * Sets whether or not objects positions are enabled for the G buffer.
  118493. */
  118494. enablePosition: boolean;
  118495. /**
  118496. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118497. */
  118498. /**
  118499. * Sets wether or not objects velocities are enabled for the G buffer.
  118500. */
  118501. enableVelocity: boolean;
  118502. /**
  118503. * Gets the scene associated with the buffer.
  118504. */
  118505. readonly scene: Scene;
  118506. /**
  118507. * Gets the ratio used by the buffer during its creation.
  118508. * How big is the buffer related to the main canvas.
  118509. */
  118510. readonly ratio: number;
  118511. /** @hidden */
  118512. static _SceneComponentInitialization: (scene: Scene) => void;
  118513. /**
  118514. * Creates a new G Buffer for the scene
  118515. * @param scene The scene the buffer belongs to
  118516. * @param ratio How big is the buffer related to the main canvas.
  118517. */
  118518. constructor(scene: Scene, ratio?: number);
  118519. /**
  118520. * Checks wether everything is ready to render a submesh to the G buffer.
  118521. * @param subMesh the submesh to check readiness for
  118522. * @param useInstances is the mesh drawn using instance or not
  118523. * @returns true if ready otherwise false
  118524. */
  118525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118526. /**
  118527. * Gets the current underlying G Buffer.
  118528. * @returns the buffer
  118529. */
  118530. getGBuffer(): MultiRenderTarget;
  118531. /**
  118532. * Gets the number of samples used to render the buffer (anti aliasing).
  118533. */
  118534. /**
  118535. * Sets the number of samples used to render the buffer (anti aliasing).
  118536. */
  118537. samples: number;
  118538. /**
  118539. * Disposes the renderer and frees up associated resources.
  118540. */
  118541. dispose(): void;
  118542. protected _createRenderTargets(): void;
  118543. private _copyBonesTransformationMatrices;
  118544. }
  118545. }
  118546. declare module BABYLON {
  118547. interface Scene {
  118548. /** @hidden (Backing field) */
  118549. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118550. /**
  118551. * Gets or Sets the current geometry buffer associated to the scene.
  118552. */
  118553. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118554. /**
  118555. * Enables a GeometryBufferRender and associates it with the scene
  118556. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118557. * @returns the GeometryBufferRenderer
  118558. */
  118559. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118560. /**
  118561. * Disables the GeometryBufferRender associated with the scene
  118562. */
  118563. disableGeometryBufferRenderer(): void;
  118564. }
  118565. /**
  118566. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118567. * in several rendering techniques.
  118568. */
  118569. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118570. /**
  118571. * The component name helpful to identify the component in the list of scene components.
  118572. */
  118573. readonly name: string;
  118574. /**
  118575. * The scene the component belongs to.
  118576. */
  118577. scene: Scene;
  118578. /**
  118579. * Creates a new instance of the component for the given scene
  118580. * @param scene Defines the scene to register the component in
  118581. */
  118582. constructor(scene: Scene);
  118583. /**
  118584. * Registers the component in a given scene
  118585. */
  118586. register(): void;
  118587. /**
  118588. * Rebuilds the elements related to this component in case of
  118589. * context lost for instance.
  118590. */
  118591. rebuild(): void;
  118592. /**
  118593. * Disposes the component and the associated ressources
  118594. */
  118595. dispose(): void;
  118596. private _gatherRenderTargets;
  118597. }
  118598. }
  118599. declare module BABYLON {
  118600. /** @hidden */
  118601. export var motionBlurPixelShader: {
  118602. name: string;
  118603. shader: string;
  118604. };
  118605. }
  118606. declare module BABYLON {
  118607. /**
  118608. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118609. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118610. * As an example, all you have to do is to create the post-process:
  118611. * var mb = new BABYLON.MotionBlurPostProcess(
  118612. * 'mb', // The name of the effect.
  118613. * scene, // The scene containing the objects to blur according to their velocity.
  118614. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118615. * camera // The camera to apply the render pass to.
  118616. * );
  118617. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118618. */
  118619. export class MotionBlurPostProcess extends PostProcess {
  118620. /**
  118621. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118622. */
  118623. motionStrength: number;
  118624. /**
  118625. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118626. */
  118627. /**
  118628. * Sets the number of iterations to be used for motion blur quality
  118629. */
  118630. motionBlurSamples: number;
  118631. private _motionBlurSamples;
  118632. private _geometryBufferRenderer;
  118633. /**
  118634. * Creates a new instance MotionBlurPostProcess
  118635. * @param name The name of the effect.
  118636. * @param scene The scene containing the objects to blur according to their velocity.
  118637. * @param options The required width/height ratio to downsize to before computing the render pass.
  118638. * @param camera The camera to apply the render pass to.
  118639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118640. * @param engine The engine which the post process will be applied. (default: current engine)
  118641. * @param reusable If the post process can be reused on the same frame. (default: false)
  118642. * @param textureType Type of textures used when performing the post process. (default: 0)
  118643. * @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)
  118644. */
  118645. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118646. /**
  118647. * Excludes the given skinned mesh from computing bones velocities.
  118648. * 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.
  118649. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118650. */
  118651. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118652. /**
  118653. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118654. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118655. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118656. */
  118657. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118658. /**
  118659. * Disposes the post process.
  118660. * @param camera The camera to dispose the post process on.
  118661. */
  118662. dispose(camera?: Camera): void;
  118663. }
  118664. }
  118665. declare module BABYLON {
  118666. /** @hidden */
  118667. export var refractionPixelShader: {
  118668. name: string;
  118669. shader: string;
  118670. };
  118671. }
  118672. declare module BABYLON {
  118673. /**
  118674. * Post process which applies a refractin texture
  118675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118676. */
  118677. export class RefractionPostProcess extends PostProcess {
  118678. /** the base color of the refraction (used to taint the rendering) */
  118679. color: Color3;
  118680. /** simulated refraction depth */
  118681. depth: number;
  118682. /** the coefficient of the base color (0 to remove base color tainting) */
  118683. colorLevel: number;
  118684. private _refTexture;
  118685. private _ownRefractionTexture;
  118686. /**
  118687. * Gets or sets the refraction texture
  118688. * Please note that you are responsible for disposing the texture if you set it manually
  118689. */
  118690. refractionTexture: Texture;
  118691. /**
  118692. * Initializes the RefractionPostProcess
  118693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118694. * @param name The name of the effect.
  118695. * @param refractionTextureUrl Url of the refraction texture to use
  118696. * @param color the base color of the refraction (used to taint the rendering)
  118697. * @param depth simulated refraction depth
  118698. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118699. * @param camera The camera to apply the render pass to.
  118700. * @param options The required width/height ratio to downsize to before computing the render pass.
  118701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118702. * @param engine The engine which the post process will be applied. (default: current engine)
  118703. * @param reusable If the post process can be reused on the same frame. (default: false)
  118704. */
  118705. constructor(name: string, refractionTextureUrl: string,
  118706. /** the base color of the refraction (used to taint the rendering) */
  118707. color: Color3,
  118708. /** simulated refraction depth */
  118709. depth: number,
  118710. /** the coefficient of the base color (0 to remove base color tainting) */
  118711. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118712. /**
  118713. * Disposes of the post process
  118714. * @param camera Camera to dispose post process on
  118715. */
  118716. dispose(camera: Camera): void;
  118717. }
  118718. }
  118719. declare module BABYLON {
  118720. /** @hidden */
  118721. export var sharpenPixelShader: {
  118722. name: string;
  118723. shader: string;
  118724. };
  118725. }
  118726. declare module BABYLON {
  118727. /**
  118728. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118729. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118730. */
  118731. export class SharpenPostProcess extends PostProcess {
  118732. /**
  118733. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118734. */
  118735. colorAmount: number;
  118736. /**
  118737. * How much sharpness should be applied (default: 0.3)
  118738. */
  118739. edgeAmount: number;
  118740. /**
  118741. * Creates a new instance ConvolutionPostProcess
  118742. * @param name The name of the effect.
  118743. * @param options The required width/height ratio to downsize to before computing the render pass.
  118744. * @param camera The camera to apply the render pass to.
  118745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118746. * @param engine The engine which the post process will be applied. (default: current engine)
  118747. * @param reusable If the post process can be reused on the same frame. (default: false)
  118748. * @param textureType Type of textures used when performing the post process. (default: 0)
  118749. * @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)
  118750. */
  118751. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118752. }
  118753. }
  118754. declare module BABYLON {
  118755. /**
  118756. * PostProcessRenderPipeline
  118757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118758. */
  118759. export class PostProcessRenderPipeline {
  118760. private engine;
  118761. private _renderEffects;
  118762. private _renderEffectsForIsolatedPass;
  118763. /**
  118764. * List of inspectable custom properties (used by the Inspector)
  118765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118766. */
  118767. inspectableCustomProperties: IInspectable[];
  118768. /**
  118769. * @hidden
  118770. */
  118771. protected _cameras: Camera[];
  118772. /** @hidden */
  118773. _name: string;
  118774. /**
  118775. * Gets pipeline name
  118776. */
  118777. readonly name: string;
  118778. /**
  118779. * Initializes a PostProcessRenderPipeline
  118780. * @param engine engine to add the pipeline to
  118781. * @param name name of the pipeline
  118782. */
  118783. constructor(engine: Engine, name: string);
  118784. /**
  118785. * Gets the class name
  118786. * @returns "PostProcessRenderPipeline"
  118787. */
  118788. getClassName(): string;
  118789. /**
  118790. * If all the render effects in the pipeline are supported
  118791. */
  118792. readonly isSupported: boolean;
  118793. /**
  118794. * Adds an effect to the pipeline
  118795. * @param renderEffect the effect to add
  118796. */
  118797. addEffect(renderEffect: PostProcessRenderEffect): void;
  118798. /** @hidden */
  118799. _rebuild(): void;
  118800. /** @hidden */
  118801. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118802. /** @hidden */
  118803. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118804. /** @hidden */
  118805. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118806. /** @hidden */
  118807. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118808. /** @hidden */
  118809. _attachCameras(cameras: Camera, unique: boolean): void;
  118810. /** @hidden */
  118811. _attachCameras(cameras: Camera[], unique: boolean): void;
  118812. /** @hidden */
  118813. _detachCameras(cameras: Camera): void;
  118814. /** @hidden */
  118815. _detachCameras(cameras: Nullable<Camera[]>): void;
  118816. /** @hidden */
  118817. _update(): void;
  118818. /** @hidden */
  118819. _reset(): void;
  118820. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118821. /**
  118822. * Disposes of the pipeline
  118823. */
  118824. dispose(): void;
  118825. }
  118826. }
  118827. declare module BABYLON {
  118828. /**
  118829. * PostProcessRenderPipelineManager class
  118830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118831. */
  118832. export class PostProcessRenderPipelineManager {
  118833. private _renderPipelines;
  118834. /**
  118835. * Initializes a PostProcessRenderPipelineManager
  118836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118837. */
  118838. constructor();
  118839. /**
  118840. * Gets the list of supported render pipelines
  118841. */
  118842. readonly supportedPipelines: PostProcessRenderPipeline[];
  118843. /**
  118844. * Adds a pipeline to the manager
  118845. * @param renderPipeline The pipeline to add
  118846. */
  118847. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118848. /**
  118849. * Attaches a camera to the pipeline
  118850. * @param renderPipelineName The name of the pipeline to attach to
  118851. * @param cameras the camera to attach
  118852. * @param unique if the camera can be attached multiple times to the pipeline
  118853. */
  118854. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118855. /**
  118856. * Detaches a camera from the pipeline
  118857. * @param renderPipelineName The name of the pipeline to detach from
  118858. * @param cameras the camera to detach
  118859. */
  118860. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118861. /**
  118862. * Enables an effect by name on a pipeline
  118863. * @param renderPipelineName the name of the pipeline to enable the effect in
  118864. * @param renderEffectName the name of the effect to enable
  118865. * @param cameras the cameras that the effect should be enabled on
  118866. */
  118867. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118868. /**
  118869. * Disables an effect by name on a pipeline
  118870. * @param renderPipelineName the name of the pipeline to disable the effect in
  118871. * @param renderEffectName the name of the effect to disable
  118872. * @param cameras the cameras that the effect should be disabled on
  118873. */
  118874. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118875. /**
  118876. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118877. */
  118878. update(): void;
  118879. /** @hidden */
  118880. _rebuild(): void;
  118881. /**
  118882. * Disposes of the manager and pipelines
  118883. */
  118884. dispose(): void;
  118885. }
  118886. }
  118887. declare module BABYLON {
  118888. interface Scene {
  118889. /** @hidden (Backing field) */
  118890. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118891. /**
  118892. * Gets the postprocess render pipeline manager
  118893. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118894. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118895. */
  118896. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118897. }
  118898. /**
  118899. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118900. */
  118901. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118902. /**
  118903. * The component name helpfull to identify the component in the list of scene components.
  118904. */
  118905. readonly name: string;
  118906. /**
  118907. * The scene the component belongs to.
  118908. */
  118909. scene: Scene;
  118910. /**
  118911. * Creates a new instance of the component for the given scene
  118912. * @param scene Defines the scene to register the component in
  118913. */
  118914. constructor(scene: Scene);
  118915. /**
  118916. * Registers the component in a given scene
  118917. */
  118918. register(): void;
  118919. /**
  118920. * Rebuilds the elements related to this component in case of
  118921. * context lost for instance.
  118922. */
  118923. rebuild(): void;
  118924. /**
  118925. * Disposes the component and the associated ressources
  118926. */
  118927. dispose(): void;
  118928. private _gatherRenderTargets;
  118929. }
  118930. }
  118931. declare module BABYLON {
  118932. /**
  118933. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118934. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118935. */
  118936. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118937. private _scene;
  118938. private _camerasToBeAttached;
  118939. /**
  118940. * ID of the sharpen post process,
  118941. */
  118942. private readonly SharpenPostProcessId;
  118943. /**
  118944. * @ignore
  118945. * ID of the image processing post process;
  118946. */
  118947. readonly ImageProcessingPostProcessId: string;
  118948. /**
  118949. * @ignore
  118950. * ID of the Fast Approximate Anti-Aliasing post process;
  118951. */
  118952. readonly FxaaPostProcessId: string;
  118953. /**
  118954. * ID of the chromatic aberration post process,
  118955. */
  118956. private readonly ChromaticAberrationPostProcessId;
  118957. /**
  118958. * ID of the grain post process
  118959. */
  118960. private readonly GrainPostProcessId;
  118961. /**
  118962. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118963. */
  118964. sharpen: SharpenPostProcess;
  118965. private _sharpenEffect;
  118966. private bloom;
  118967. /**
  118968. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118969. */
  118970. depthOfField: DepthOfFieldEffect;
  118971. /**
  118972. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118973. */
  118974. fxaa: FxaaPostProcess;
  118975. /**
  118976. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118977. */
  118978. imageProcessing: ImageProcessingPostProcess;
  118979. /**
  118980. * Chromatic aberration post process which will shift rgb colors in the image
  118981. */
  118982. chromaticAberration: ChromaticAberrationPostProcess;
  118983. private _chromaticAberrationEffect;
  118984. /**
  118985. * Grain post process which add noise to the image
  118986. */
  118987. grain: GrainPostProcess;
  118988. private _grainEffect;
  118989. /**
  118990. * Glow post process which adds a glow to emissive areas of the image
  118991. */
  118992. private _glowLayer;
  118993. /**
  118994. * Animations which can be used to tweak settings over a period of time
  118995. */
  118996. animations: Animation[];
  118997. private _imageProcessingConfigurationObserver;
  118998. private _sharpenEnabled;
  118999. private _bloomEnabled;
  119000. private _depthOfFieldEnabled;
  119001. private _depthOfFieldBlurLevel;
  119002. private _fxaaEnabled;
  119003. private _imageProcessingEnabled;
  119004. private _defaultPipelineTextureType;
  119005. private _bloomScale;
  119006. private _chromaticAberrationEnabled;
  119007. private _grainEnabled;
  119008. private _buildAllowed;
  119009. /**
  119010. * Gets active scene
  119011. */
  119012. readonly scene: Scene;
  119013. /**
  119014. * Enable or disable the sharpen process from the pipeline
  119015. */
  119016. sharpenEnabled: boolean;
  119017. private _resizeObserver;
  119018. private _hardwareScaleLevel;
  119019. private _bloomKernel;
  119020. /**
  119021. * Specifies the size of the bloom blur kernel, relative to the final output size
  119022. */
  119023. bloomKernel: number;
  119024. /**
  119025. * Specifies the weight of the bloom in the final rendering
  119026. */
  119027. private _bloomWeight;
  119028. /**
  119029. * Specifies the luma threshold for the area that will be blurred by the bloom
  119030. */
  119031. private _bloomThreshold;
  119032. private _hdr;
  119033. /**
  119034. * The strength of the bloom.
  119035. */
  119036. bloomWeight: number;
  119037. /**
  119038. * The strength of the bloom.
  119039. */
  119040. bloomThreshold: number;
  119041. /**
  119042. * The scale of the bloom, lower value will provide better performance.
  119043. */
  119044. bloomScale: number;
  119045. /**
  119046. * Enable or disable the bloom from the pipeline
  119047. */
  119048. bloomEnabled: boolean;
  119049. private _rebuildBloom;
  119050. /**
  119051. * If the depth of field is enabled.
  119052. */
  119053. depthOfFieldEnabled: boolean;
  119054. /**
  119055. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119056. */
  119057. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  119058. /**
  119059. * If the anti aliasing is enabled.
  119060. */
  119061. fxaaEnabled: boolean;
  119062. private _samples;
  119063. /**
  119064. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119065. */
  119066. samples: number;
  119067. /**
  119068. * If image processing is enabled.
  119069. */
  119070. imageProcessingEnabled: boolean;
  119071. /**
  119072. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119073. */
  119074. glowLayerEnabled: boolean;
  119075. /**
  119076. * Gets the glow layer (or null if not defined)
  119077. */
  119078. readonly glowLayer: Nullable<GlowLayer>;
  119079. /**
  119080. * Enable or disable the chromaticAberration process from the pipeline
  119081. */
  119082. chromaticAberrationEnabled: boolean;
  119083. /**
  119084. * Enable or disable the grain process from the pipeline
  119085. */
  119086. grainEnabled: boolean;
  119087. /**
  119088. * @constructor
  119089. * @param name - The rendering pipeline name (default: "")
  119090. * @param hdr - If high dynamic range textures should be used (default: true)
  119091. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119092. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119093. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119094. */
  119095. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119096. /**
  119097. * Get the class name
  119098. * @returns "DefaultRenderingPipeline"
  119099. */
  119100. getClassName(): string;
  119101. /**
  119102. * Force the compilation of the entire pipeline.
  119103. */
  119104. prepare(): void;
  119105. private _hasCleared;
  119106. private _prevPostProcess;
  119107. private _prevPrevPostProcess;
  119108. private _setAutoClearAndTextureSharing;
  119109. private _depthOfFieldSceneObserver;
  119110. private _buildPipeline;
  119111. private _disposePostProcesses;
  119112. /**
  119113. * Adds a camera to the pipeline
  119114. * @param camera the camera to be added
  119115. */
  119116. addCamera(camera: Camera): void;
  119117. /**
  119118. * Removes a camera from the pipeline
  119119. * @param camera the camera to remove
  119120. */
  119121. removeCamera(camera: Camera): void;
  119122. /**
  119123. * Dispose of the pipeline and stop all post processes
  119124. */
  119125. dispose(): void;
  119126. /**
  119127. * Serialize the rendering pipeline (Used when exporting)
  119128. * @returns the serialized object
  119129. */
  119130. serialize(): any;
  119131. /**
  119132. * Parse the serialized pipeline
  119133. * @param source Source pipeline.
  119134. * @param scene The scene to load the pipeline to.
  119135. * @param rootUrl The URL of the serialized pipeline.
  119136. * @returns An instantiated pipeline from the serialized object.
  119137. */
  119138. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119139. }
  119140. }
  119141. declare module BABYLON {
  119142. /** @hidden */
  119143. export var lensHighlightsPixelShader: {
  119144. name: string;
  119145. shader: string;
  119146. };
  119147. }
  119148. declare module BABYLON {
  119149. /** @hidden */
  119150. export var depthOfFieldPixelShader: {
  119151. name: string;
  119152. shader: string;
  119153. };
  119154. }
  119155. declare module BABYLON {
  119156. /**
  119157. * BABYLON.JS Chromatic Aberration GLSL Shader
  119158. * Author: Olivier Guyot
  119159. * Separates very slightly R, G and B colors on the edges of the screen
  119160. * Inspired by Francois Tarlier & Martins Upitis
  119161. */
  119162. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119163. /**
  119164. * @ignore
  119165. * The chromatic aberration PostProcess id in the pipeline
  119166. */
  119167. LensChromaticAberrationEffect: string;
  119168. /**
  119169. * @ignore
  119170. * The highlights enhancing PostProcess id in the pipeline
  119171. */
  119172. HighlightsEnhancingEffect: string;
  119173. /**
  119174. * @ignore
  119175. * The depth-of-field PostProcess id in the pipeline
  119176. */
  119177. LensDepthOfFieldEffect: string;
  119178. private _scene;
  119179. private _depthTexture;
  119180. private _grainTexture;
  119181. private _chromaticAberrationPostProcess;
  119182. private _highlightsPostProcess;
  119183. private _depthOfFieldPostProcess;
  119184. private _edgeBlur;
  119185. private _grainAmount;
  119186. private _chromaticAberration;
  119187. private _distortion;
  119188. private _highlightsGain;
  119189. private _highlightsThreshold;
  119190. private _dofDistance;
  119191. private _dofAperture;
  119192. private _dofDarken;
  119193. private _dofPentagon;
  119194. private _blurNoise;
  119195. /**
  119196. * @constructor
  119197. *
  119198. * Effect parameters are as follow:
  119199. * {
  119200. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119201. * edge_blur: number; // from 0 to x (1 for realism)
  119202. * distortion: number; // from 0 to x (1 for realism)
  119203. * grain_amount: number; // from 0 to 1
  119204. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119205. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119206. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119207. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119208. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119209. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119210. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119211. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119212. * }
  119213. * Note: if an effect parameter is unset, effect is disabled
  119214. *
  119215. * @param name The rendering pipeline name
  119216. * @param parameters - An object containing all parameters (see above)
  119217. * @param scene The scene linked to this pipeline
  119218. * @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)
  119219. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119220. */
  119221. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119222. /**
  119223. * Get the class name
  119224. * @returns "LensRenderingPipeline"
  119225. */
  119226. getClassName(): string;
  119227. /**
  119228. * Gets associated scene
  119229. */
  119230. readonly scene: Scene;
  119231. /**
  119232. * Gets or sets the edge blur
  119233. */
  119234. edgeBlur: number;
  119235. /**
  119236. * Gets or sets the grain amount
  119237. */
  119238. grainAmount: number;
  119239. /**
  119240. * Gets or sets the chromatic aberration amount
  119241. */
  119242. chromaticAberration: number;
  119243. /**
  119244. * Gets or sets the depth of field aperture
  119245. */
  119246. dofAperture: number;
  119247. /**
  119248. * Gets or sets the edge distortion
  119249. */
  119250. edgeDistortion: number;
  119251. /**
  119252. * Gets or sets the depth of field distortion
  119253. */
  119254. dofDistortion: number;
  119255. /**
  119256. * Gets or sets the darken out of focus amount
  119257. */
  119258. darkenOutOfFocus: number;
  119259. /**
  119260. * Gets or sets a boolean indicating if blur noise is enabled
  119261. */
  119262. blurNoise: boolean;
  119263. /**
  119264. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119265. */
  119266. pentagonBokeh: boolean;
  119267. /**
  119268. * Gets or sets the highlight grain amount
  119269. */
  119270. highlightsGain: number;
  119271. /**
  119272. * Gets or sets the highlight threshold
  119273. */
  119274. highlightsThreshold: number;
  119275. /**
  119276. * Sets the amount of blur at the edges
  119277. * @param amount blur amount
  119278. */
  119279. setEdgeBlur(amount: number): void;
  119280. /**
  119281. * Sets edge blur to 0
  119282. */
  119283. disableEdgeBlur(): void;
  119284. /**
  119285. * Sets the amout of grain
  119286. * @param amount Amount of grain
  119287. */
  119288. setGrainAmount(amount: number): void;
  119289. /**
  119290. * Set grain amount to 0
  119291. */
  119292. disableGrain(): void;
  119293. /**
  119294. * Sets the chromatic aberration amount
  119295. * @param amount amount of chromatic aberration
  119296. */
  119297. setChromaticAberration(amount: number): void;
  119298. /**
  119299. * Sets chromatic aberration amount to 0
  119300. */
  119301. disableChromaticAberration(): void;
  119302. /**
  119303. * Sets the EdgeDistortion amount
  119304. * @param amount amount of EdgeDistortion
  119305. */
  119306. setEdgeDistortion(amount: number): void;
  119307. /**
  119308. * Sets edge distortion to 0
  119309. */
  119310. disableEdgeDistortion(): void;
  119311. /**
  119312. * Sets the FocusDistance amount
  119313. * @param amount amount of FocusDistance
  119314. */
  119315. setFocusDistance(amount: number): void;
  119316. /**
  119317. * Disables depth of field
  119318. */
  119319. disableDepthOfField(): void;
  119320. /**
  119321. * Sets the Aperture amount
  119322. * @param amount amount of Aperture
  119323. */
  119324. setAperture(amount: number): void;
  119325. /**
  119326. * Sets the DarkenOutOfFocus amount
  119327. * @param amount amount of DarkenOutOfFocus
  119328. */
  119329. setDarkenOutOfFocus(amount: number): void;
  119330. private _pentagonBokehIsEnabled;
  119331. /**
  119332. * Creates a pentagon bokeh effect
  119333. */
  119334. enablePentagonBokeh(): void;
  119335. /**
  119336. * Disables the pentagon bokeh effect
  119337. */
  119338. disablePentagonBokeh(): void;
  119339. /**
  119340. * Enables noise blur
  119341. */
  119342. enableNoiseBlur(): void;
  119343. /**
  119344. * Disables noise blur
  119345. */
  119346. disableNoiseBlur(): void;
  119347. /**
  119348. * Sets the HighlightsGain amount
  119349. * @param amount amount of HighlightsGain
  119350. */
  119351. setHighlightsGain(amount: number): void;
  119352. /**
  119353. * Sets the HighlightsThreshold amount
  119354. * @param amount amount of HighlightsThreshold
  119355. */
  119356. setHighlightsThreshold(amount: number): void;
  119357. /**
  119358. * Disables highlights
  119359. */
  119360. disableHighlights(): void;
  119361. /**
  119362. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119363. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119364. */
  119365. dispose(disableDepthRender?: boolean): void;
  119366. private _createChromaticAberrationPostProcess;
  119367. private _createHighlightsPostProcess;
  119368. private _createDepthOfFieldPostProcess;
  119369. private _createGrainTexture;
  119370. }
  119371. }
  119372. declare module BABYLON {
  119373. /** @hidden */
  119374. export var ssao2PixelShader: {
  119375. name: string;
  119376. shader: string;
  119377. };
  119378. }
  119379. declare module BABYLON {
  119380. /** @hidden */
  119381. export var ssaoCombinePixelShader: {
  119382. name: string;
  119383. shader: string;
  119384. };
  119385. }
  119386. declare module BABYLON {
  119387. /**
  119388. * Render pipeline to produce ssao effect
  119389. */
  119390. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119391. /**
  119392. * @ignore
  119393. * The PassPostProcess id in the pipeline that contains the original scene color
  119394. */
  119395. SSAOOriginalSceneColorEffect: string;
  119396. /**
  119397. * @ignore
  119398. * The SSAO PostProcess id in the pipeline
  119399. */
  119400. SSAORenderEffect: string;
  119401. /**
  119402. * @ignore
  119403. * The horizontal blur PostProcess id in the pipeline
  119404. */
  119405. SSAOBlurHRenderEffect: string;
  119406. /**
  119407. * @ignore
  119408. * The vertical blur PostProcess id in the pipeline
  119409. */
  119410. SSAOBlurVRenderEffect: string;
  119411. /**
  119412. * @ignore
  119413. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119414. */
  119415. SSAOCombineRenderEffect: string;
  119416. /**
  119417. * The output strength of the SSAO post-process. Default value is 1.0.
  119418. */
  119419. totalStrength: number;
  119420. /**
  119421. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119422. */
  119423. maxZ: number;
  119424. /**
  119425. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119426. */
  119427. minZAspect: number;
  119428. private _samples;
  119429. /**
  119430. * Number of samples used for the SSAO calculations. Default value is 8
  119431. */
  119432. samples: number;
  119433. private _textureSamples;
  119434. /**
  119435. * Number of samples to use for antialiasing
  119436. */
  119437. textureSamples: number;
  119438. /**
  119439. * Ratio object used for SSAO ratio and blur ratio
  119440. */
  119441. private _ratio;
  119442. /**
  119443. * Dynamically generated sphere sampler.
  119444. */
  119445. private _sampleSphere;
  119446. /**
  119447. * Blur filter offsets
  119448. */
  119449. private _samplerOffsets;
  119450. private _expensiveBlur;
  119451. /**
  119452. * If bilateral blur should be used
  119453. */
  119454. expensiveBlur: boolean;
  119455. /**
  119456. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119457. */
  119458. radius: number;
  119459. /**
  119460. * The base color of the SSAO post-process
  119461. * The final result is "base + ssao" between [0, 1]
  119462. */
  119463. base: number;
  119464. /**
  119465. * Support test.
  119466. */
  119467. static readonly IsSupported: boolean;
  119468. private _scene;
  119469. private _depthTexture;
  119470. private _normalTexture;
  119471. private _randomTexture;
  119472. private _originalColorPostProcess;
  119473. private _ssaoPostProcess;
  119474. private _blurHPostProcess;
  119475. private _blurVPostProcess;
  119476. private _ssaoCombinePostProcess;
  119477. private _firstUpdate;
  119478. /**
  119479. * Gets active scene
  119480. */
  119481. readonly scene: Scene;
  119482. /**
  119483. * @constructor
  119484. * @param name The rendering pipeline name
  119485. * @param scene The scene linked to this pipeline
  119486. * @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 }
  119487. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119488. */
  119489. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119490. /**
  119491. * Get the class name
  119492. * @returns "SSAO2RenderingPipeline"
  119493. */
  119494. getClassName(): string;
  119495. /**
  119496. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119497. */
  119498. dispose(disableGeometryBufferRenderer?: boolean): void;
  119499. private _createBlurPostProcess;
  119500. /** @hidden */
  119501. _rebuild(): void;
  119502. private _bits;
  119503. private _radicalInverse_VdC;
  119504. private _hammersley;
  119505. private _hemisphereSample_uniform;
  119506. private _generateHemisphere;
  119507. private _createSSAOPostProcess;
  119508. private _createSSAOCombinePostProcess;
  119509. private _createRandomTexture;
  119510. /**
  119511. * Serialize the rendering pipeline (Used when exporting)
  119512. * @returns the serialized object
  119513. */
  119514. serialize(): any;
  119515. /**
  119516. * Parse the serialized pipeline
  119517. * @param source Source pipeline.
  119518. * @param scene The scene to load the pipeline to.
  119519. * @param rootUrl The URL of the serialized pipeline.
  119520. * @returns An instantiated pipeline from the serialized object.
  119521. */
  119522. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119523. }
  119524. }
  119525. declare module BABYLON {
  119526. /** @hidden */
  119527. export var ssaoPixelShader: {
  119528. name: string;
  119529. shader: string;
  119530. };
  119531. }
  119532. declare module BABYLON {
  119533. /**
  119534. * Render pipeline to produce ssao effect
  119535. */
  119536. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119537. /**
  119538. * @ignore
  119539. * The PassPostProcess id in the pipeline that contains the original scene color
  119540. */
  119541. SSAOOriginalSceneColorEffect: string;
  119542. /**
  119543. * @ignore
  119544. * The SSAO PostProcess id in the pipeline
  119545. */
  119546. SSAORenderEffect: string;
  119547. /**
  119548. * @ignore
  119549. * The horizontal blur PostProcess id in the pipeline
  119550. */
  119551. SSAOBlurHRenderEffect: string;
  119552. /**
  119553. * @ignore
  119554. * The vertical blur PostProcess id in the pipeline
  119555. */
  119556. SSAOBlurVRenderEffect: string;
  119557. /**
  119558. * @ignore
  119559. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119560. */
  119561. SSAOCombineRenderEffect: string;
  119562. /**
  119563. * The output strength of the SSAO post-process. Default value is 1.0.
  119564. */
  119565. totalStrength: number;
  119566. /**
  119567. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119568. */
  119569. radius: number;
  119570. /**
  119571. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119572. * Must not be equal to fallOff and superior to fallOff.
  119573. * Default value is 0.0075
  119574. */
  119575. area: number;
  119576. /**
  119577. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119578. * Must not be equal to area and inferior to area.
  119579. * Default value is 0.000001
  119580. */
  119581. fallOff: number;
  119582. /**
  119583. * The base color of the SSAO post-process
  119584. * The final result is "base + ssao" between [0, 1]
  119585. */
  119586. base: number;
  119587. private _scene;
  119588. private _depthTexture;
  119589. private _randomTexture;
  119590. private _originalColorPostProcess;
  119591. private _ssaoPostProcess;
  119592. private _blurHPostProcess;
  119593. private _blurVPostProcess;
  119594. private _ssaoCombinePostProcess;
  119595. private _firstUpdate;
  119596. /**
  119597. * Gets active scene
  119598. */
  119599. readonly scene: Scene;
  119600. /**
  119601. * @constructor
  119602. * @param name - The rendering pipeline name
  119603. * @param scene - The scene linked to this pipeline
  119604. * @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 }
  119605. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119606. */
  119607. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119608. /**
  119609. * Get the class name
  119610. * @returns "SSAORenderingPipeline"
  119611. */
  119612. getClassName(): string;
  119613. /**
  119614. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119615. */
  119616. dispose(disableDepthRender?: boolean): void;
  119617. private _createBlurPostProcess;
  119618. /** @hidden */
  119619. _rebuild(): void;
  119620. private _createSSAOPostProcess;
  119621. private _createSSAOCombinePostProcess;
  119622. private _createRandomTexture;
  119623. }
  119624. }
  119625. declare module BABYLON {
  119626. /** @hidden */
  119627. export var standardPixelShader: {
  119628. name: string;
  119629. shader: string;
  119630. };
  119631. }
  119632. declare module BABYLON {
  119633. /**
  119634. * Standard rendering pipeline
  119635. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119636. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119637. */
  119638. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119639. /**
  119640. * Public members
  119641. */
  119642. /**
  119643. * Post-process which contains the original scene color before the pipeline applies all the effects
  119644. */
  119645. originalPostProcess: Nullable<PostProcess>;
  119646. /**
  119647. * Post-process used to down scale an image x4
  119648. */
  119649. downSampleX4PostProcess: Nullable<PostProcess>;
  119650. /**
  119651. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119652. */
  119653. brightPassPostProcess: Nullable<PostProcess>;
  119654. /**
  119655. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119656. */
  119657. blurHPostProcesses: PostProcess[];
  119658. /**
  119659. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119660. */
  119661. blurVPostProcesses: PostProcess[];
  119662. /**
  119663. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119664. */
  119665. textureAdderPostProcess: Nullable<PostProcess>;
  119666. /**
  119667. * Post-process used to create volumetric lighting effect
  119668. */
  119669. volumetricLightPostProcess: Nullable<PostProcess>;
  119670. /**
  119671. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119672. */
  119673. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119674. /**
  119675. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119676. */
  119677. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119678. /**
  119679. * Post-process used to merge the volumetric light effect and the real scene color
  119680. */
  119681. volumetricLightMergePostProces: Nullable<PostProcess>;
  119682. /**
  119683. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119684. */
  119685. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119686. /**
  119687. * Base post-process used to calculate the average luminance of the final image for HDR
  119688. */
  119689. luminancePostProcess: Nullable<PostProcess>;
  119690. /**
  119691. * Post-processes used to create down sample post-processes in order to get
  119692. * the average luminance of the final image for HDR
  119693. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119694. */
  119695. luminanceDownSamplePostProcesses: PostProcess[];
  119696. /**
  119697. * Post-process used to create a HDR effect (light adaptation)
  119698. */
  119699. hdrPostProcess: Nullable<PostProcess>;
  119700. /**
  119701. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119702. */
  119703. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119704. /**
  119705. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119706. */
  119707. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119708. /**
  119709. * Post-process used to merge the final HDR post-process and the real scene color
  119710. */
  119711. hdrFinalPostProcess: Nullable<PostProcess>;
  119712. /**
  119713. * Post-process used to create a lens flare effect
  119714. */
  119715. lensFlarePostProcess: Nullable<PostProcess>;
  119716. /**
  119717. * Post-process that merges the result of the lens flare post-process and the real scene color
  119718. */
  119719. lensFlareComposePostProcess: Nullable<PostProcess>;
  119720. /**
  119721. * Post-process used to create a motion blur effect
  119722. */
  119723. motionBlurPostProcess: Nullable<PostProcess>;
  119724. /**
  119725. * Post-process used to create a depth of field effect
  119726. */
  119727. depthOfFieldPostProcess: Nullable<PostProcess>;
  119728. /**
  119729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119730. */
  119731. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119732. /**
  119733. * Represents the brightness threshold in order to configure the illuminated surfaces
  119734. */
  119735. brightThreshold: number;
  119736. /**
  119737. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119738. */
  119739. blurWidth: number;
  119740. /**
  119741. * Sets if the blur for highlighted surfaces must be only horizontal
  119742. */
  119743. horizontalBlur: boolean;
  119744. /**
  119745. * Gets the overall exposure used by the pipeline
  119746. */
  119747. /**
  119748. * Sets the overall exposure used by the pipeline
  119749. */
  119750. exposure: number;
  119751. /**
  119752. * Texture used typically to simulate "dirty" on camera lens
  119753. */
  119754. lensTexture: Nullable<Texture>;
  119755. /**
  119756. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119757. */
  119758. volumetricLightCoefficient: number;
  119759. /**
  119760. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119761. */
  119762. volumetricLightPower: number;
  119763. /**
  119764. * Used the set the blur intensity to smooth the volumetric lights
  119765. */
  119766. volumetricLightBlurScale: number;
  119767. /**
  119768. * Light (spot or directional) used to generate the volumetric lights rays
  119769. * The source light must have a shadow generate so the pipeline can get its
  119770. * depth map
  119771. */
  119772. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119773. /**
  119774. * For eye adaptation, represents the minimum luminance the eye can see
  119775. */
  119776. hdrMinimumLuminance: number;
  119777. /**
  119778. * For eye adaptation, represents the decrease luminance speed
  119779. */
  119780. hdrDecreaseRate: number;
  119781. /**
  119782. * For eye adaptation, represents the increase luminance speed
  119783. */
  119784. hdrIncreaseRate: number;
  119785. /**
  119786. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119787. */
  119788. /**
  119789. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119790. */
  119791. hdrAutoExposure: boolean;
  119792. /**
  119793. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119794. */
  119795. lensColorTexture: Nullable<Texture>;
  119796. /**
  119797. * The overall strengh for the lens flare effect
  119798. */
  119799. lensFlareStrength: number;
  119800. /**
  119801. * Dispersion coefficient for lens flare ghosts
  119802. */
  119803. lensFlareGhostDispersal: number;
  119804. /**
  119805. * Main lens flare halo width
  119806. */
  119807. lensFlareHaloWidth: number;
  119808. /**
  119809. * Based on the lens distortion effect, defines how much the lens flare result
  119810. * is distorted
  119811. */
  119812. lensFlareDistortionStrength: number;
  119813. /**
  119814. * Lens star texture must be used to simulate rays on the flares and is available
  119815. * in the documentation
  119816. */
  119817. lensStarTexture: Nullable<Texture>;
  119818. /**
  119819. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119820. * flare effect by taking account of the dirt texture
  119821. */
  119822. lensFlareDirtTexture: Nullable<Texture>;
  119823. /**
  119824. * Represents the focal length for the depth of field effect
  119825. */
  119826. depthOfFieldDistance: number;
  119827. /**
  119828. * Represents the blur intensity for the blurred part of the depth of field effect
  119829. */
  119830. depthOfFieldBlurWidth: number;
  119831. /**
  119832. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119833. */
  119834. /**
  119835. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119836. */
  119837. motionStrength: number;
  119838. /**
  119839. * Gets wether or not the motion blur post-process is object based or screen based.
  119840. */
  119841. /**
  119842. * Sets wether or not the motion blur post-process should be object based or screen based
  119843. */
  119844. objectBasedMotionBlur: boolean;
  119845. /**
  119846. * List of animations for the pipeline (IAnimatable implementation)
  119847. */
  119848. animations: Animation[];
  119849. /**
  119850. * Private members
  119851. */
  119852. private _scene;
  119853. private _currentDepthOfFieldSource;
  119854. private _basePostProcess;
  119855. private _fixedExposure;
  119856. private _currentExposure;
  119857. private _hdrAutoExposure;
  119858. private _hdrCurrentLuminance;
  119859. private _motionStrength;
  119860. private _isObjectBasedMotionBlur;
  119861. private _floatTextureType;
  119862. private _ratio;
  119863. private _bloomEnabled;
  119864. private _depthOfFieldEnabled;
  119865. private _vlsEnabled;
  119866. private _lensFlareEnabled;
  119867. private _hdrEnabled;
  119868. private _motionBlurEnabled;
  119869. private _fxaaEnabled;
  119870. private _motionBlurSamples;
  119871. private _volumetricLightStepsCount;
  119872. private _samples;
  119873. /**
  119874. * @ignore
  119875. * Specifies if the bloom pipeline is enabled
  119876. */
  119877. BloomEnabled: boolean;
  119878. /**
  119879. * @ignore
  119880. * Specifies if the depth of field pipeline is enabed
  119881. */
  119882. DepthOfFieldEnabled: boolean;
  119883. /**
  119884. * @ignore
  119885. * Specifies if the lens flare pipeline is enabed
  119886. */
  119887. LensFlareEnabled: boolean;
  119888. /**
  119889. * @ignore
  119890. * Specifies if the HDR pipeline is enabled
  119891. */
  119892. HDREnabled: boolean;
  119893. /**
  119894. * @ignore
  119895. * Specifies if the volumetric lights scattering effect is enabled
  119896. */
  119897. VLSEnabled: boolean;
  119898. /**
  119899. * @ignore
  119900. * Specifies if the motion blur effect is enabled
  119901. */
  119902. MotionBlurEnabled: boolean;
  119903. /**
  119904. * Specifies if anti-aliasing is enabled
  119905. */
  119906. fxaaEnabled: boolean;
  119907. /**
  119908. * Specifies the number of steps used to calculate the volumetric lights
  119909. * Typically in interval [50, 200]
  119910. */
  119911. volumetricLightStepsCount: number;
  119912. /**
  119913. * Specifies the number of samples used for the motion blur effect
  119914. * Typically in interval [16, 64]
  119915. */
  119916. motionBlurSamples: number;
  119917. /**
  119918. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119919. */
  119920. samples: number;
  119921. /**
  119922. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119923. * @constructor
  119924. * @param name The rendering pipeline name
  119925. * @param scene The scene linked to this pipeline
  119926. * @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)
  119927. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119928. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119929. */
  119930. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119931. private _buildPipeline;
  119932. private _createDownSampleX4PostProcess;
  119933. private _createBrightPassPostProcess;
  119934. private _createBlurPostProcesses;
  119935. private _createTextureAdderPostProcess;
  119936. private _createVolumetricLightPostProcess;
  119937. private _createLuminancePostProcesses;
  119938. private _createHdrPostProcess;
  119939. private _createLensFlarePostProcess;
  119940. private _createDepthOfFieldPostProcess;
  119941. private _createMotionBlurPostProcess;
  119942. private _getDepthTexture;
  119943. private _disposePostProcesses;
  119944. /**
  119945. * Dispose of the pipeline and stop all post processes
  119946. */
  119947. dispose(): void;
  119948. /**
  119949. * Serialize the rendering pipeline (Used when exporting)
  119950. * @returns the serialized object
  119951. */
  119952. serialize(): any;
  119953. /**
  119954. * Parse the serialized pipeline
  119955. * @param source Source pipeline.
  119956. * @param scene The scene to load the pipeline to.
  119957. * @param rootUrl The URL of the serialized pipeline.
  119958. * @returns An instantiated pipeline from the serialized object.
  119959. */
  119960. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119961. /**
  119962. * Luminance steps
  119963. */
  119964. static LuminanceSteps: number;
  119965. }
  119966. }
  119967. declare module BABYLON {
  119968. /** @hidden */
  119969. export var tonemapPixelShader: {
  119970. name: string;
  119971. shader: string;
  119972. };
  119973. }
  119974. declare module BABYLON {
  119975. /** Defines operator used for tonemapping */
  119976. export enum TonemappingOperator {
  119977. /** Hable */
  119978. Hable = 0,
  119979. /** Reinhard */
  119980. Reinhard = 1,
  119981. /** HejiDawson */
  119982. HejiDawson = 2,
  119983. /** Photographic */
  119984. Photographic = 3
  119985. }
  119986. /**
  119987. * Defines a post process to apply tone mapping
  119988. */
  119989. export class TonemapPostProcess extends PostProcess {
  119990. private _operator;
  119991. /** Defines the required exposure adjustement */
  119992. exposureAdjustment: number;
  119993. /**
  119994. * Creates a new TonemapPostProcess
  119995. * @param name defines the name of the postprocess
  119996. * @param _operator defines the operator to use
  119997. * @param exposureAdjustment defines the required exposure adjustement
  119998. * @param camera defines the camera to use (can be null)
  119999. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120000. * @param engine defines the hosting engine (can be ignore if camera is set)
  120001. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120002. */
  120003. constructor(name: string, _operator: TonemappingOperator,
  120004. /** Defines the required exposure adjustement */
  120005. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  120006. }
  120007. }
  120008. declare module BABYLON {
  120009. /** @hidden */
  120010. export var depthVertexShader: {
  120011. name: string;
  120012. shader: string;
  120013. };
  120014. }
  120015. declare module BABYLON {
  120016. /** @hidden */
  120017. export var volumetricLightScatteringPixelShader: {
  120018. name: string;
  120019. shader: string;
  120020. };
  120021. }
  120022. declare module BABYLON {
  120023. /** @hidden */
  120024. export var volumetricLightScatteringPassPixelShader: {
  120025. name: string;
  120026. shader: string;
  120027. };
  120028. }
  120029. declare module BABYLON {
  120030. /**
  120031. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120032. */
  120033. export class VolumetricLightScatteringPostProcess extends PostProcess {
  120034. private _volumetricLightScatteringPass;
  120035. private _volumetricLightScatteringRTT;
  120036. private _viewPort;
  120037. private _screenCoordinates;
  120038. private _cachedDefines;
  120039. /**
  120040. * If not undefined, the mesh position is computed from the attached node position
  120041. */
  120042. attachedNode: {
  120043. position: Vector3;
  120044. };
  120045. /**
  120046. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120047. */
  120048. customMeshPosition: Vector3;
  120049. /**
  120050. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120051. */
  120052. useCustomMeshPosition: boolean;
  120053. /**
  120054. * If the post-process should inverse the light scattering direction
  120055. */
  120056. invert: boolean;
  120057. /**
  120058. * The internal mesh used by the post-process
  120059. */
  120060. mesh: Mesh;
  120061. /**
  120062. * @hidden
  120063. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120064. */
  120065. useDiffuseColor: boolean;
  120066. /**
  120067. * Array containing the excluded meshes not rendered in the internal pass
  120068. */
  120069. excludedMeshes: AbstractMesh[];
  120070. /**
  120071. * Controls the overall intensity of the post-process
  120072. */
  120073. exposure: number;
  120074. /**
  120075. * Dissipates each sample's contribution in range [0, 1]
  120076. */
  120077. decay: number;
  120078. /**
  120079. * Controls the overall intensity of each sample
  120080. */
  120081. weight: number;
  120082. /**
  120083. * Controls the density of each sample
  120084. */
  120085. density: number;
  120086. /**
  120087. * @constructor
  120088. * @param name The post-process name
  120089. * @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)
  120090. * @param camera The camera that the post-process will be attached to
  120091. * @param mesh The mesh used to create the light scattering
  120092. * @param samples The post-process quality, default 100
  120093. * @param samplingModeThe post-process filtering mode
  120094. * @param engine The babylon engine
  120095. * @param reusable If the post-process is reusable
  120096. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120097. */
  120098. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120099. /**
  120100. * Returns the string "VolumetricLightScatteringPostProcess"
  120101. * @returns "VolumetricLightScatteringPostProcess"
  120102. */
  120103. getClassName(): string;
  120104. private _isReady;
  120105. /**
  120106. * Sets the new light position for light scattering effect
  120107. * @param position The new custom light position
  120108. */
  120109. setCustomMeshPosition(position: Vector3): void;
  120110. /**
  120111. * Returns the light position for light scattering effect
  120112. * @return Vector3 The custom light position
  120113. */
  120114. getCustomMeshPosition(): Vector3;
  120115. /**
  120116. * Disposes the internal assets and detaches the post-process from the camera
  120117. */
  120118. dispose(camera: Camera): void;
  120119. /**
  120120. * Returns the render target texture used by the post-process
  120121. * @return the render target texture used by the post-process
  120122. */
  120123. getPass(): RenderTargetTexture;
  120124. private _meshExcluded;
  120125. private _createPass;
  120126. private _updateMeshScreenCoordinates;
  120127. /**
  120128. * Creates a default mesh for the Volumeric Light Scattering post-process
  120129. * @param name The mesh name
  120130. * @param scene The scene where to create the mesh
  120131. * @return the default mesh
  120132. */
  120133. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120134. }
  120135. }
  120136. declare module BABYLON {
  120137. interface Scene {
  120138. /** @hidden (Backing field) */
  120139. _boundingBoxRenderer: BoundingBoxRenderer;
  120140. /** @hidden (Backing field) */
  120141. _forceShowBoundingBoxes: boolean;
  120142. /**
  120143. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120144. */
  120145. forceShowBoundingBoxes: boolean;
  120146. /**
  120147. * Gets the bounding box renderer associated with the scene
  120148. * @returns a BoundingBoxRenderer
  120149. */
  120150. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120151. }
  120152. interface AbstractMesh {
  120153. /** @hidden (Backing field) */
  120154. _showBoundingBox: boolean;
  120155. /**
  120156. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120157. */
  120158. showBoundingBox: boolean;
  120159. }
  120160. /**
  120161. * Component responsible of rendering the bounding box of the meshes in a scene.
  120162. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120163. */
  120164. export class BoundingBoxRenderer implements ISceneComponent {
  120165. /**
  120166. * The component name helpfull to identify the component in the list of scene components.
  120167. */
  120168. readonly name: string;
  120169. /**
  120170. * The scene the component belongs to.
  120171. */
  120172. scene: Scene;
  120173. /**
  120174. * Color of the bounding box lines placed in front of an object
  120175. */
  120176. frontColor: Color3;
  120177. /**
  120178. * Color of the bounding box lines placed behind an object
  120179. */
  120180. backColor: Color3;
  120181. /**
  120182. * Defines if the renderer should show the back lines or not
  120183. */
  120184. showBackLines: boolean;
  120185. /**
  120186. * @hidden
  120187. */
  120188. renderList: SmartArray<BoundingBox>;
  120189. private _colorShader;
  120190. private _vertexBuffers;
  120191. private _indexBuffer;
  120192. private _fillIndexBuffer;
  120193. private _fillIndexData;
  120194. /**
  120195. * Instantiates a new bounding box renderer in a scene.
  120196. * @param scene the scene the renderer renders in
  120197. */
  120198. constructor(scene: Scene);
  120199. /**
  120200. * Registers the component in a given scene
  120201. */
  120202. register(): void;
  120203. private _evaluateSubMesh;
  120204. private _activeMesh;
  120205. private _prepareRessources;
  120206. private _createIndexBuffer;
  120207. /**
  120208. * Rebuilds the elements related to this component in case of
  120209. * context lost for instance.
  120210. */
  120211. rebuild(): void;
  120212. /**
  120213. * @hidden
  120214. */
  120215. reset(): void;
  120216. /**
  120217. * Render the bounding boxes of a specific rendering group
  120218. * @param renderingGroupId defines the rendering group to render
  120219. */
  120220. render(renderingGroupId: number): void;
  120221. /**
  120222. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120223. * @param mesh Define the mesh to render the occlusion bounding box for
  120224. */
  120225. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120226. /**
  120227. * Dispose and release the resources attached to this renderer.
  120228. */
  120229. dispose(): void;
  120230. }
  120231. }
  120232. declare module BABYLON {
  120233. /** @hidden */
  120234. export var depthPixelShader: {
  120235. name: string;
  120236. shader: string;
  120237. };
  120238. }
  120239. declare module BABYLON {
  120240. /**
  120241. * This represents a depth renderer in Babylon.
  120242. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120243. */
  120244. export class DepthRenderer {
  120245. private _scene;
  120246. private _depthMap;
  120247. private _effect;
  120248. private _cachedDefines;
  120249. private _camera;
  120250. /**
  120251. * Specifiess that the depth renderer will only be used within
  120252. * the camera it is created for.
  120253. * This can help forcing its rendering during the camera processing.
  120254. */
  120255. useOnlyInActiveCamera: boolean;
  120256. /** @hidden */
  120257. static _SceneComponentInitialization: (scene: Scene) => void;
  120258. /**
  120259. * Instantiates a depth renderer
  120260. * @param scene The scene the renderer belongs to
  120261. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120262. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120263. */
  120264. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120265. /**
  120266. * Creates the depth rendering effect and checks if the effect is ready.
  120267. * @param subMesh The submesh to be used to render the depth map of
  120268. * @param useInstances If multiple world instances should be used
  120269. * @returns if the depth renderer is ready to render the depth map
  120270. */
  120271. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120272. /**
  120273. * Gets the texture which the depth map will be written to.
  120274. * @returns The depth map texture
  120275. */
  120276. getDepthMap(): RenderTargetTexture;
  120277. /**
  120278. * Disposes of the depth renderer.
  120279. */
  120280. dispose(): void;
  120281. }
  120282. }
  120283. declare module BABYLON {
  120284. interface Scene {
  120285. /** @hidden (Backing field) */
  120286. _depthRenderer: {
  120287. [id: string]: DepthRenderer;
  120288. };
  120289. /**
  120290. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120291. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120292. * @returns the created depth renderer
  120293. */
  120294. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120295. /**
  120296. * Disables a depth renderer for a given camera
  120297. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120298. */
  120299. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120300. }
  120301. /**
  120302. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120303. * in several rendering techniques.
  120304. */
  120305. export class DepthRendererSceneComponent implements ISceneComponent {
  120306. /**
  120307. * The component name helpfull to identify the component in the list of scene components.
  120308. */
  120309. readonly name: string;
  120310. /**
  120311. * The scene the component belongs to.
  120312. */
  120313. scene: Scene;
  120314. /**
  120315. * Creates a new instance of the component for the given scene
  120316. * @param scene Defines the scene to register the component in
  120317. */
  120318. constructor(scene: Scene);
  120319. /**
  120320. * Registers the component in a given scene
  120321. */
  120322. register(): void;
  120323. /**
  120324. * Rebuilds the elements related to this component in case of
  120325. * context lost for instance.
  120326. */
  120327. rebuild(): void;
  120328. /**
  120329. * Disposes the component and the associated ressources
  120330. */
  120331. dispose(): void;
  120332. private _gatherRenderTargets;
  120333. private _gatherActiveCameraRenderTargets;
  120334. }
  120335. }
  120336. declare module BABYLON {
  120337. /** @hidden */
  120338. export var outlinePixelShader: {
  120339. name: string;
  120340. shader: string;
  120341. };
  120342. }
  120343. declare module BABYLON {
  120344. /** @hidden */
  120345. export var outlineVertexShader: {
  120346. name: string;
  120347. shader: string;
  120348. };
  120349. }
  120350. declare module BABYLON {
  120351. interface Scene {
  120352. /** @hidden */
  120353. _outlineRenderer: OutlineRenderer;
  120354. /**
  120355. * Gets the outline renderer associated with the scene
  120356. * @returns a OutlineRenderer
  120357. */
  120358. getOutlineRenderer(): OutlineRenderer;
  120359. }
  120360. interface AbstractMesh {
  120361. /** @hidden (Backing field) */
  120362. _renderOutline: boolean;
  120363. /**
  120364. * Gets or sets a boolean indicating if the outline must be rendered as well
  120365. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120366. */
  120367. renderOutline: boolean;
  120368. /** @hidden (Backing field) */
  120369. _renderOverlay: boolean;
  120370. /**
  120371. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120372. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120373. */
  120374. renderOverlay: boolean;
  120375. }
  120376. /**
  120377. * This class is responsible to draw bothe outline/overlay of meshes.
  120378. * It should not be used directly but through the available method on mesh.
  120379. */
  120380. export class OutlineRenderer implements ISceneComponent {
  120381. /**
  120382. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120383. */
  120384. private static _StencilReference;
  120385. /**
  120386. * The name of the component. Each component must have a unique name.
  120387. */
  120388. name: string;
  120389. /**
  120390. * The scene the component belongs to.
  120391. */
  120392. scene: Scene;
  120393. /**
  120394. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120395. */
  120396. zOffset: number;
  120397. private _engine;
  120398. private _effect;
  120399. private _cachedDefines;
  120400. private _savedDepthWrite;
  120401. /**
  120402. * Instantiates a new outline renderer. (There could be only one per scene).
  120403. * @param scene Defines the scene it belongs to
  120404. */
  120405. constructor(scene: Scene);
  120406. /**
  120407. * Register the component to one instance of a scene.
  120408. */
  120409. register(): void;
  120410. /**
  120411. * Rebuilds the elements related to this component in case of
  120412. * context lost for instance.
  120413. */
  120414. rebuild(): void;
  120415. /**
  120416. * Disposes the component and the associated ressources.
  120417. */
  120418. dispose(): void;
  120419. /**
  120420. * Renders the outline in the canvas.
  120421. * @param subMesh Defines the sumesh to render
  120422. * @param batch Defines the batch of meshes in case of instances
  120423. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120424. */
  120425. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120426. /**
  120427. * Returns whether or not the outline renderer is ready for a given submesh.
  120428. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120429. * @param subMesh Defines the submesh to check readyness for
  120430. * @param useInstances Defines wheter wee are trying to render instances or not
  120431. * @returns true if ready otherwise false
  120432. */
  120433. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120434. private _beforeRenderingMesh;
  120435. private _afterRenderingMesh;
  120436. }
  120437. }
  120438. declare module BABYLON {
  120439. /**
  120440. * Defines the list of states available for a task inside a AssetsManager
  120441. */
  120442. export enum AssetTaskState {
  120443. /**
  120444. * Initialization
  120445. */
  120446. INIT = 0,
  120447. /**
  120448. * Running
  120449. */
  120450. RUNNING = 1,
  120451. /**
  120452. * Done
  120453. */
  120454. DONE = 2,
  120455. /**
  120456. * Error
  120457. */
  120458. ERROR = 3
  120459. }
  120460. /**
  120461. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120462. */
  120463. export abstract class AbstractAssetTask {
  120464. /**
  120465. * Task name
  120466. */ name: string;
  120467. /**
  120468. * Callback called when the task is successful
  120469. */
  120470. onSuccess: (task: any) => void;
  120471. /**
  120472. * Callback called when the task is not successful
  120473. */
  120474. onError: (task: any, message?: string, exception?: any) => void;
  120475. /**
  120476. * Creates a new AssetsManager
  120477. * @param name defines the name of the task
  120478. */
  120479. constructor(
  120480. /**
  120481. * Task name
  120482. */ name: string);
  120483. private _isCompleted;
  120484. private _taskState;
  120485. private _errorObject;
  120486. /**
  120487. * Get if the task is completed
  120488. */
  120489. readonly isCompleted: boolean;
  120490. /**
  120491. * Gets the current state of the task
  120492. */
  120493. readonly taskState: AssetTaskState;
  120494. /**
  120495. * Gets the current error object (if task is in error)
  120496. */
  120497. readonly errorObject: {
  120498. message?: string;
  120499. exception?: any;
  120500. };
  120501. /**
  120502. * Internal only
  120503. * @hidden
  120504. */
  120505. _setErrorObject(message?: string, exception?: any): void;
  120506. /**
  120507. * Execute the current task
  120508. * @param scene defines the scene where you want your assets to be loaded
  120509. * @param onSuccess is a callback called when the task is successfully executed
  120510. * @param onError is a callback called if an error occurs
  120511. */
  120512. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120513. /**
  120514. * Execute the current task
  120515. * @param scene defines the scene where you want your assets to be loaded
  120516. * @param onSuccess is a callback called when the task is successfully executed
  120517. * @param onError is a callback called if an error occurs
  120518. */
  120519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120520. /**
  120521. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120522. * This can be used with failed tasks that have the reason for failure fixed.
  120523. */
  120524. reset(): void;
  120525. private onErrorCallback;
  120526. private onDoneCallback;
  120527. }
  120528. /**
  120529. * Define the interface used by progress events raised during assets loading
  120530. */
  120531. export interface IAssetsProgressEvent {
  120532. /**
  120533. * Defines the number of remaining tasks to process
  120534. */
  120535. remainingCount: number;
  120536. /**
  120537. * Defines the total number of tasks
  120538. */
  120539. totalCount: number;
  120540. /**
  120541. * Defines the task that was just processed
  120542. */
  120543. task: AbstractAssetTask;
  120544. }
  120545. /**
  120546. * Class used to share progress information about assets loading
  120547. */
  120548. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120549. /**
  120550. * Defines the number of remaining tasks to process
  120551. */
  120552. remainingCount: number;
  120553. /**
  120554. * Defines the total number of tasks
  120555. */
  120556. totalCount: number;
  120557. /**
  120558. * Defines the task that was just processed
  120559. */
  120560. task: AbstractAssetTask;
  120561. /**
  120562. * Creates a AssetsProgressEvent
  120563. * @param remainingCount defines the number of remaining tasks to process
  120564. * @param totalCount defines the total number of tasks
  120565. * @param task defines the task that was just processed
  120566. */
  120567. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120568. }
  120569. /**
  120570. * Define a task used by AssetsManager to load meshes
  120571. */
  120572. export class MeshAssetTask extends AbstractAssetTask {
  120573. /**
  120574. * Defines the name of the task
  120575. */
  120576. name: string;
  120577. /**
  120578. * Defines the list of mesh's names you want to load
  120579. */
  120580. meshesNames: any;
  120581. /**
  120582. * Defines the root url to use as a base to load your meshes and associated resources
  120583. */
  120584. rootUrl: string;
  120585. /**
  120586. * Defines the filename of the scene to load from
  120587. */
  120588. sceneFilename: string;
  120589. /**
  120590. * Gets the list of loaded meshes
  120591. */
  120592. loadedMeshes: Array<AbstractMesh>;
  120593. /**
  120594. * Gets the list of loaded particle systems
  120595. */
  120596. loadedParticleSystems: Array<IParticleSystem>;
  120597. /**
  120598. * Gets the list of loaded skeletons
  120599. */
  120600. loadedSkeletons: Array<Skeleton>;
  120601. /**
  120602. * Gets the list of loaded animation groups
  120603. */
  120604. loadedAnimationGroups: Array<AnimationGroup>;
  120605. /**
  120606. * Callback called when the task is successful
  120607. */
  120608. onSuccess: (task: MeshAssetTask) => void;
  120609. /**
  120610. * Callback called when the task is successful
  120611. */
  120612. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120613. /**
  120614. * Creates a new MeshAssetTask
  120615. * @param name defines the name of the task
  120616. * @param meshesNames defines the list of mesh's names you want to load
  120617. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120618. * @param sceneFilename defines the filename of the scene to load from
  120619. */
  120620. constructor(
  120621. /**
  120622. * Defines the name of the task
  120623. */
  120624. name: string,
  120625. /**
  120626. * Defines the list of mesh's names you want to load
  120627. */
  120628. meshesNames: any,
  120629. /**
  120630. * Defines the root url to use as a base to load your meshes and associated resources
  120631. */
  120632. rootUrl: string,
  120633. /**
  120634. * Defines the filename of the scene to load from
  120635. */
  120636. sceneFilename: string);
  120637. /**
  120638. * Execute the current task
  120639. * @param scene defines the scene where you want your assets to be loaded
  120640. * @param onSuccess is a callback called when the task is successfully executed
  120641. * @param onError is a callback called if an error occurs
  120642. */
  120643. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120644. }
  120645. /**
  120646. * Define a task used by AssetsManager to load text content
  120647. */
  120648. export class TextFileAssetTask extends AbstractAssetTask {
  120649. /**
  120650. * Defines the name of the task
  120651. */
  120652. name: string;
  120653. /**
  120654. * Defines the location of the file to load
  120655. */
  120656. url: string;
  120657. /**
  120658. * Gets the loaded text string
  120659. */
  120660. text: string;
  120661. /**
  120662. * Callback called when the task is successful
  120663. */
  120664. onSuccess: (task: TextFileAssetTask) => void;
  120665. /**
  120666. * Callback called when the task is successful
  120667. */
  120668. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120669. /**
  120670. * Creates a new TextFileAssetTask object
  120671. * @param name defines the name of the task
  120672. * @param url defines the location of the file to load
  120673. */
  120674. constructor(
  120675. /**
  120676. * Defines the name of the task
  120677. */
  120678. name: string,
  120679. /**
  120680. * Defines the location of the file to load
  120681. */
  120682. url: string);
  120683. /**
  120684. * Execute the current task
  120685. * @param scene defines the scene where you want your assets to be loaded
  120686. * @param onSuccess is a callback called when the task is successfully executed
  120687. * @param onError is a callback called if an error occurs
  120688. */
  120689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120690. }
  120691. /**
  120692. * Define a task used by AssetsManager to load binary data
  120693. */
  120694. export class BinaryFileAssetTask extends AbstractAssetTask {
  120695. /**
  120696. * Defines the name of the task
  120697. */
  120698. name: string;
  120699. /**
  120700. * Defines the location of the file to load
  120701. */
  120702. url: string;
  120703. /**
  120704. * Gets the lodaded data (as an array buffer)
  120705. */
  120706. data: ArrayBuffer;
  120707. /**
  120708. * Callback called when the task is successful
  120709. */
  120710. onSuccess: (task: BinaryFileAssetTask) => void;
  120711. /**
  120712. * Callback called when the task is successful
  120713. */
  120714. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120715. /**
  120716. * Creates a new BinaryFileAssetTask object
  120717. * @param name defines the name of the new task
  120718. * @param url defines the location of the file to load
  120719. */
  120720. constructor(
  120721. /**
  120722. * Defines the name of the task
  120723. */
  120724. name: string,
  120725. /**
  120726. * Defines the location of the file to load
  120727. */
  120728. url: string);
  120729. /**
  120730. * Execute the current task
  120731. * @param scene defines the scene where you want your assets to be loaded
  120732. * @param onSuccess is a callback called when the task is successfully executed
  120733. * @param onError is a callback called if an error occurs
  120734. */
  120735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120736. }
  120737. /**
  120738. * Define a task used by AssetsManager to load images
  120739. */
  120740. export class ImageAssetTask extends AbstractAssetTask {
  120741. /**
  120742. * Defines the name of the task
  120743. */
  120744. name: string;
  120745. /**
  120746. * Defines the location of the image to load
  120747. */
  120748. url: string;
  120749. /**
  120750. * Gets the loaded images
  120751. */
  120752. image: HTMLImageElement;
  120753. /**
  120754. * Callback called when the task is successful
  120755. */
  120756. onSuccess: (task: ImageAssetTask) => void;
  120757. /**
  120758. * Callback called when the task is successful
  120759. */
  120760. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120761. /**
  120762. * Creates a new ImageAssetTask
  120763. * @param name defines the name of the task
  120764. * @param url defines the location of the image to load
  120765. */
  120766. constructor(
  120767. /**
  120768. * Defines the name of the task
  120769. */
  120770. name: string,
  120771. /**
  120772. * Defines the location of the image to load
  120773. */
  120774. url: string);
  120775. /**
  120776. * Execute the current task
  120777. * @param scene defines the scene where you want your assets to be loaded
  120778. * @param onSuccess is a callback called when the task is successfully executed
  120779. * @param onError is a callback called if an error occurs
  120780. */
  120781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120782. }
  120783. /**
  120784. * Defines the interface used by texture loading tasks
  120785. */
  120786. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120787. /**
  120788. * Gets the loaded texture
  120789. */
  120790. texture: TEX;
  120791. }
  120792. /**
  120793. * Define a task used by AssetsManager to load 2D textures
  120794. */
  120795. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120796. /**
  120797. * Defines the name of the task
  120798. */
  120799. name: string;
  120800. /**
  120801. * Defines the location of the file to load
  120802. */
  120803. url: string;
  120804. /**
  120805. * Defines if mipmap should not be generated (default is false)
  120806. */
  120807. noMipmap?: boolean | undefined;
  120808. /**
  120809. * Defines if texture must be inverted on Y axis (default is false)
  120810. */
  120811. invertY?: boolean | undefined;
  120812. /**
  120813. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120814. */
  120815. samplingMode: number;
  120816. /**
  120817. * Gets the loaded texture
  120818. */
  120819. texture: Texture;
  120820. /**
  120821. * Callback called when the task is successful
  120822. */
  120823. onSuccess: (task: TextureAssetTask) => void;
  120824. /**
  120825. * Callback called when the task is successful
  120826. */
  120827. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120828. /**
  120829. * Creates a new TextureAssetTask object
  120830. * @param name defines the name of the task
  120831. * @param url defines the location of the file to load
  120832. * @param noMipmap defines if mipmap should not be generated (default is false)
  120833. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120834. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120835. */
  120836. constructor(
  120837. /**
  120838. * Defines the name of the task
  120839. */
  120840. name: string,
  120841. /**
  120842. * Defines the location of the file to load
  120843. */
  120844. url: string,
  120845. /**
  120846. * Defines if mipmap should not be generated (default is false)
  120847. */
  120848. noMipmap?: boolean | undefined,
  120849. /**
  120850. * Defines if texture must be inverted on Y axis (default is false)
  120851. */
  120852. invertY?: boolean | undefined,
  120853. /**
  120854. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120855. */
  120856. samplingMode?: number);
  120857. /**
  120858. * Execute the current task
  120859. * @param scene defines the scene where you want your assets to be loaded
  120860. * @param onSuccess is a callback called when the task is successfully executed
  120861. * @param onError is a callback called if an error occurs
  120862. */
  120863. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120864. }
  120865. /**
  120866. * Define a task used by AssetsManager to load cube textures
  120867. */
  120868. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120869. /**
  120870. * Defines the name of the task
  120871. */
  120872. name: string;
  120873. /**
  120874. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120875. */
  120876. url: string;
  120877. /**
  120878. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120879. */
  120880. extensions?: string[] | undefined;
  120881. /**
  120882. * Defines if mipmaps should not be generated (default is false)
  120883. */
  120884. noMipmap?: boolean | undefined;
  120885. /**
  120886. * Defines the explicit list of files (undefined by default)
  120887. */
  120888. files?: string[] | undefined;
  120889. /**
  120890. * Gets the loaded texture
  120891. */
  120892. texture: CubeTexture;
  120893. /**
  120894. * Callback called when the task is successful
  120895. */
  120896. onSuccess: (task: CubeTextureAssetTask) => void;
  120897. /**
  120898. * Callback called when the task is successful
  120899. */
  120900. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120901. /**
  120902. * Creates a new CubeTextureAssetTask
  120903. * @param name defines the name of the task
  120904. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120905. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120906. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120907. * @param files defines the explicit list of files (undefined by default)
  120908. */
  120909. constructor(
  120910. /**
  120911. * Defines the name of the task
  120912. */
  120913. name: string,
  120914. /**
  120915. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120916. */
  120917. url: string,
  120918. /**
  120919. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120920. */
  120921. extensions?: string[] | undefined,
  120922. /**
  120923. * Defines if mipmaps should not be generated (default is false)
  120924. */
  120925. noMipmap?: boolean | undefined,
  120926. /**
  120927. * Defines the explicit list of files (undefined by default)
  120928. */
  120929. files?: string[] | undefined);
  120930. /**
  120931. * Execute the current task
  120932. * @param scene defines the scene where you want your assets to be loaded
  120933. * @param onSuccess is a callback called when the task is successfully executed
  120934. * @param onError is a callback called if an error occurs
  120935. */
  120936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120937. }
  120938. /**
  120939. * Define a task used by AssetsManager to load HDR cube textures
  120940. */
  120941. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120942. /**
  120943. * Defines the name of the task
  120944. */
  120945. name: string;
  120946. /**
  120947. * Defines the location of the file to load
  120948. */
  120949. url: string;
  120950. /**
  120951. * Defines the desired size (the more it increases the longer the generation will be)
  120952. */
  120953. size: number;
  120954. /**
  120955. * Defines if mipmaps should not be generated (default is false)
  120956. */
  120957. noMipmap: boolean;
  120958. /**
  120959. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120960. */
  120961. generateHarmonics: boolean;
  120962. /**
  120963. * 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)
  120964. */
  120965. gammaSpace: boolean;
  120966. /**
  120967. * Internal Use Only
  120968. */
  120969. reserved: boolean;
  120970. /**
  120971. * Gets the loaded texture
  120972. */
  120973. texture: HDRCubeTexture;
  120974. /**
  120975. * Callback called when the task is successful
  120976. */
  120977. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120978. /**
  120979. * Callback called when the task is successful
  120980. */
  120981. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120982. /**
  120983. * Creates a new HDRCubeTextureAssetTask object
  120984. * @param name defines the name of the task
  120985. * @param url defines the location of the file to load
  120986. * @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.
  120987. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120988. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120989. * @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)
  120990. * @param reserved Internal use only
  120991. */
  120992. constructor(
  120993. /**
  120994. * Defines the name of the task
  120995. */
  120996. name: string,
  120997. /**
  120998. * Defines the location of the file to load
  120999. */
  121000. url: string,
  121001. /**
  121002. * Defines the desired size (the more it increases the longer the generation will be)
  121003. */
  121004. size: number,
  121005. /**
  121006. * Defines if mipmaps should not be generated (default is false)
  121007. */
  121008. noMipmap?: boolean,
  121009. /**
  121010. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  121011. */
  121012. generateHarmonics?: boolean,
  121013. /**
  121014. * 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)
  121015. */
  121016. gammaSpace?: boolean,
  121017. /**
  121018. * Internal Use Only
  121019. */
  121020. reserved?: boolean);
  121021. /**
  121022. * Execute the current task
  121023. * @param scene defines the scene where you want your assets to be loaded
  121024. * @param onSuccess is a callback called when the task is successfully executed
  121025. * @param onError is a callback called if an error occurs
  121026. */
  121027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121028. }
  121029. /**
  121030. * Define a task used by AssetsManager to load Equirectangular cube textures
  121031. */
  121032. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  121033. /**
  121034. * Defines the name of the task
  121035. */
  121036. name: string;
  121037. /**
  121038. * Defines the location of the file to load
  121039. */
  121040. url: string;
  121041. /**
  121042. * Defines the desired size (the more it increases the longer the generation will be)
  121043. */
  121044. size: number;
  121045. /**
  121046. * Defines if mipmaps should not be generated (default is false)
  121047. */
  121048. noMipmap: boolean;
  121049. /**
  121050. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121051. * but the standard material would require them in Gamma space) (default is true)
  121052. */
  121053. gammaSpace: boolean;
  121054. /**
  121055. * Gets the loaded texture
  121056. */
  121057. texture: EquiRectangularCubeTexture;
  121058. /**
  121059. * Callback called when the task is successful
  121060. */
  121061. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  121062. /**
  121063. * Callback called when the task is successful
  121064. */
  121065. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  121066. /**
  121067. * Creates a new EquiRectangularCubeTextureAssetTask object
  121068. * @param name defines the name of the task
  121069. * @param url defines the location of the file to load
  121070. * @param size defines the desired size (the more it increases the longer the generation will be)
  121071. * If the size is omitted this implies you are using a preprocessed cubemap.
  121072. * @param noMipmap defines if mipmaps should not be generated (default is false)
  121073. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  121074. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  121075. * (default is true)
  121076. */
  121077. constructor(
  121078. /**
  121079. * Defines the name of the task
  121080. */
  121081. name: string,
  121082. /**
  121083. * Defines the location of the file to load
  121084. */
  121085. url: string,
  121086. /**
  121087. * Defines the desired size (the more it increases the longer the generation will be)
  121088. */
  121089. size: number,
  121090. /**
  121091. * Defines if mipmaps should not be generated (default is false)
  121092. */
  121093. noMipmap?: boolean,
  121094. /**
  121095. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121096. * but the standard material would require them in Gamma space) (default is true)
  121097. */
  121098. gammaSpace?: boolean);
  121099. /**
  121100. * Execute the current task
  121101. * @param scene defines the scene where you want your assets to be loaded
  121102. * @param onSuccess is a callback called when the task is successfully executed
  121103. * @param onError is a callback called if an error occurs
  121104. */
  121105. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121106. }
  121107. /**
  121108. * This class can be used to easily import assets into a scene
  121109. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121110. */
  121111. export class AssetsManager {
  121112. private _scene;
  121113. private _isLoading;
  121114. protected _tasks: AbstractAssetTask[];
  121115. protected _waitingTasksCount: number;
  121116. protected _totalTasksCount: number;
  121117. /**
  121118. * Callback called when all tasks are processed
  121119. */
  121120. onFinish: (tasks: AbstractAssetTask[]) => void;
  121121. /**
  121122. * Callback called when a task is successful
  121123. */
  121124. onTaskSuccess: (task: AbstractAssetTask) => void;
  121125. /**
  121126. * Callback called when a task had an error
  121127. */
  121128. onTaskError: (task: AbstractAssetTask) => void;
  121129. /**
  121130. * Callback called when a task is done (whatever the result is)
  121131. */
  121132. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121133. /**
  121134. * Observable called when all tasks are processed
  121135. */
  121136. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121137. /**
  121138. * Observable called when a task had an error
  121139. */
  121140. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121141. /**
  121142. * Observable called when all tasks were executed
  121143. */
  121144. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121145. /**
  121146. * Observable called when a task is done (whatever the result is)
  121147. */
  121148. onProgressObservable: Observable<IAssetsProgressEvent>;
  121149. /**
  121150. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121151. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121152. */
  121153. useDefaultLoadingScreen: boolean;
  121154. /**
  121155. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  121156. * when all assets have been downloaded.
  121157. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  121158. */
  121159. autoHideLoadingUI: boolean;
  121160. /**
  121161. * Creates a new AssetsManager
  121162. * @param scene defines the scene to work on
  121163. */
  121164. constructor(scene: Scene);
  121165. /**
  121166. * Add a MeshAssetTask to the list of active tasks
  121167. * @param taskName defines the name of the new task
  121168. * @param meshesNames defines the name of meshes to load
  121169. * @param rootUrl defines the root url to use to locate files
  121170. * @param sceneFilename defines the filename of the scene file
  121171. * @returns a new MeshAssetTask object
  121172. */
  121173. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121174. /**
  121175. * Add a TextFileAssetTask to the list of active tasks
  121176. * @param taskName defines the name of the new task
  121177. * @param url defines the url of the file to load
  121178. * @returns a new TextFileAssetTask object
  121179. */
  121180. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121181. /**
  121182. * Add a BinaryFileAssetTask to the list of active tasks
  121183. * @param taskName defines the name of the new task
  121184. * @param url defines the url of the file to load
  121185. * @returns a new BinaryFileAssetTask object
  121186. */
  121187. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121188. /**
  121189. * Add a ImageAssetTask to the list of active tasks
  121190. * @param taskName defines the name of the new task
  121191. * @param url defines the url of the file to load
  121192. * @returns a new ImageAssetTask object
  121193. */
  121194. addImageTask(taskName: string, url: string): ImageAssetTask;
  121195. /**
  121196. * Add a TextureAssetTask to the list of active tasks
  121197. * @param taskName defines the name of the new task
  121198. * @param url defines the url of the file to load
  121199. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121200. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121201. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121202. * @returns a new TextureAssetTask object
  121203. */
  121204. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121205. /**
  121206. * Add a CubeTextureAssetTask to the list of active tasks
  121207. * @param taskName defines the name of the new task
  121208. * @param url defines the url of the file to load
  121209. * @param extensions defines the extension to use to load the cube map (can be null)
  121210. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121211. * @param files defines the list of files to load (can be null)
  121212. * @returns a new CubeTextureAssetTask object
  121213. */
  121214. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121215. /**
  121216. *
  121217. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121218. * @param taskName defines the name of the new task
  121219. * @param url defines the url of the file to load
  121220. * @param size defines the size you want for the cubemap (can be null)
  121221. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121222. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121223. * @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)
  121224. * @param reserved Internal use only
  121225. * @returns a new HDRCubeTextureAssetTask object
  121226. */
  121227. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121228. /**
  121229. *
  121230. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121231. * @param taskName defines the name of the new task
  121232. * @param url defines the url of the file to load
  121233. * @param size defines the size you want for the cubemap (can be null)
  121234. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121235. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121236. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121237. * @returns a new EquiRectangularCubeTextureAssetTask object
  121238. */
  121239. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121240. /**
  121241. * Remove a task from the assets manager.
  121242. * @param task the task to remove
  121243. */
  121244. removeTask(task: AbstractAssetTask): void;
  121245. private _decreaseWaitingTasksCount;
  121246. private _runTask;
  121247. /**
  121248. * Reset the AssetsManager and remove all tasks
  121249. * @return the current instance of the AssetsManager
  121250. */
  121251. reset(): AssetsManager;
  121252. /**
  121253. * Start the loading process
  121254. * @return the current instance of the AssetsManager
  121255. */
  121256. load(): AssetsManager;
  121257. /**
  121258. * Start the loading process as an async operation
  121259. * @return a promise returning the list of failed tasks
  121260. */
  121261. loadAsync(): Promise<void>;
  121262. }
  121263. }
  121264. declare module BABYLON {
  121265. /**
  121266. * Wrapper class for promise with external resolve and reject.
  121267. */
  121268. export class Deferred<T> {
  121269. /**
  121270. * The promise associated with this deferred object.
  121271. */
  121272. readonly promise: Promise<T>;
  121273. private _resolve;
  121274. private _reject;
  121275. /**
  121276. * The resolve method of the promise associated with this deferred object.
  121277. */
  121278. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121279. /**
  121280. * The reject method of the promise associated with this deferred object.
  121281. */
  121282. readonly reject: (reason?: any) => void;
  121283. /**
  121284. * Constructor for this deferred object.
  121285. */
  121286. constructor();
  121287. }
  121288. }
  121289. declare module BABYLON {
  121290. /**
  121291. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121292. */
  121293. export class MeshExploder {
  121294. private _centerMesh;
  121295. private _meshes;
  121296. private _meshesOrigins;
  121297. private _toCenterVectors;
  121298. private _scaledDirection;
  121299. private _newPosition;
  121300. private _centerPosition;
  121301. /**
  121302. * Explodes meshes from a center mesh.
  121303. * @param meshes The meshes to explode.
  121304. * @param centerMesh The mesh to be center of explosion.
  121305. */
  121306. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121307. private _setCenterMesh;
  121308. /**
  121309. * Get class name
  121310. * @returns "MeshExploder"
  121311. */
  121312. getClassName(): string;
  121313. /**
  121314. * "Exploded meshes"
  121315. * @returns Array of meshes with the centerMesh at index 0.
  121316. */
  121317. getMeshes(): Array<Mesh>;
  121318. /**
  121319. * Explodes meshes giving a specific direction
  121320. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121321. */
  121322. explode(direction?: number): void;
  121323. }
  121324. }
  121325. declare module BABYLON {
  121326. /**
  121327. * Class used to help managing file picking and drag'n'drop
  121328. */
  121329. export class FilesInput {
  121330. /**
  121331. * List of files ready to be loaded
  121332. */
  121333. static readonly FilesToLoad: {
  121334. [key: string]: File;
  121335. };
  121336. /**
  121337. * Callback called when a file is processed
  121338. */
  121339. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121340. private _engine;
  121341. private _currentScene;
  121342. private _sceneLoadedCallback;
  121343. private _progressCallback;
  121344. private _additionalRenderLoopLogicCallback;
  121345. private _textureLoadingCallback;
  121346. private _startingProcessingFilesCallback;
  121347. private _onReloadCallback;
  121348. private _errorCallback;
  121349. private _elementToMonitor;
  121350. private _sceneFileToLoad;
  121351. private _filesToLoad;
  121352. /**
  121353. * Creates a new FilesInput
  121354. * @param engine defines the rendering engine
  121355. * @param scene defines the hosting scene
  121356. * @param sceneLoadedCallback callback called when scene is loaded
  121357. * @param progressCallback callback called to track progress
  121358. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121359. * @param textureLoadingCallback callback called when a texture is loading
  121360. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121361. * @param onReloadCallback callback called when a reload is requested
  121362. * @param errorCallback callback call if an error occurs
  121363. */
  121364. 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);
  121365. private _dragEnterHandler;
  121366. private _dragOverHandler;
  121367. private _dropHandler;
  121368. /**
  121369. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121370. * @param elementToMonitor defines the DOM element to track
  121371. */
  121372. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121373. /**
  121374. * Release all associated resources
  121375. */
  121376. dispose(): void;
  121377. private renderFunction;
  121378. private drag;
  121379. private drop;
  121380. private _traverseFolder;
  121381. private _processFiles;
  121382. /**
  121383. * Load files from a drop event
  121384. * @param event defines the drop event to use as source
  121385. */
  121386. loadFiles(event: any): void;
  121387. private _processReload;
  121388. /**
  121389. * Reload the current scene from the loaded files
  121390. */
  121391. reload(): void;
  121392. }
  121393. }
  121394. declare module BABYLON {
  121395. /**
  121396. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121397. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121398. */
  121399. export class SceneOptimization {
  121400. /**
  121401. * Defines the priority of this optimization (0 by default which means first in the list)
  121402. */
  121403. priority: number;
  121404. /**
  121405. * Gets a string describing the action executed by the current optimization
  121406. * @returns description string
  121407. */
  121408. getDescription(): string;
  121409. /**
  121410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121411. * @param scene defines the current scene where to apply this optimization
  121412. * @param optimizer defines the current optimizer
  121413. * @returns true if everything that can be done was applied
  121414. */
  121415. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121416. /**
  121417. * Creates the SceneOptimization object
  121418. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121419. * @param desc defines the description associated with the optimization
  121420. */
  121421. constructor(
  121422. /**
  121423. * Defines the priority of this optimization (0 by default which means first in the list)
  121424. */
  121425. priority?: number);
  121426. }
  121427. /**
  121428. * Defines an optimization used to reduce the size of render target textures
  121429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121430. */
  121431. export class TextureOptimization extends SceneOptimization {
  121432. /**
  121433. * Defines the priority of this optimization (0 by default which means first in the list)
  121434. */
  121435. priority: number;
  121436. /**
  121437. * 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
  121438. */
  121439. maximumSize: number;
  121440. /**
  121441. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121442. */
  121443. step: number;
  121444. /**
  121445. * Gets a string describing the action executed by the current optimization
  121446. * @returns description string
  121447. */
  121448. getDescription(): string;
  121449. /**
  121450. * Creates the TextureOptimization object
  121451. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121452. * @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
  121453. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121454. */
  121455. constructor(
  121456. /**
  121457. * Defines the priority of this optimization (0 by default which means first in the list)
  121458. */
  121459. priority?: number,
  121460. /**
  121461. * 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
  121462. */
  121463. maximumSize?: number,
  121464. /**
  121465. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121466. */
  121467. step?: number);
  121468. /**
  121469. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121470. * @param scene defines the current scene where to apply this optimization
  121471. * @param optimizer defines the current optimizer
  121472. * @returns true if everything that can be done was applied
  121473. */
  121474. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121475. }
  121476. /**
  121477. * Defines an optimization used to increase or decrease the rendering resolution
  121478. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121479. */
  121480. export class HardwareScalingOptimization extends SceneOptimization {
  121481. /**
  121482. * Defines the priority of this optimization (0 by default which means first in the list)
  121483. */
  121484. priority: number;
  121485. /**
  121486. * Defines the maximum scale to use (2 by default)
  121487. */
  121488. maximumScale: number;
  121489. /**
  121490. * Defines the step to use between two passes (0.5 by default)
  121491. */
  121492. step: number;
  121493. private _currentScale;
  121494. private _directionOffset;
  121495. /**
  121496. * Gets a string describing the action executed by the current optimization
  121497. * @return description string
  121498. */
  121499. getDescription(): string;
  121500. /**
  121501. * Creates the HardwareScalingOptimization object
  121502. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121503. * @param maximumScale defines the maximum scale to use (2 by default)
  121504. * @param step defines the step to use between two passes (0.5 by default)
  121505. */
  121506. constructor(
  121507. /**
  121508. * Defines the priority of this optimization (0 by default which means first in the list)
  121509. */
  121510. priority?: number,
  121511. /**
  121512. * Defines the maximum scale to use (2 by default)
  121513. */
  121514. maximumScale?: number,
  121515. /**
  121516. * Defines the step to use between two passes (0.5 by default)
  121517. */
  121518. step?: number);
  121519. /**
  121520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121521. * @param scene defines the current scene where to apply this optimization
  121522. * @param optimizer defines the current optimizer
  121523. * @returns true if everything that can be done was applied
  121524. */
  121525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121526. }
  121527. /**
  121528. * Defines an optimization used to remove shadows
  121529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121530. */
  121531. export class ShadowsOptimization extends SceneOptimization {
  121532. /**
  121533. * Gets a string describing the action executed by the current optimization
  121534. * @return description string
  121535. */
  121536. getDescription(): string;
  121537. /**
  121538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121539. * @param scene defines the current scene where to apply this optimization
  121540. * @param optimizer defines the current optimizer
  121541. * @returns true if everything that can be done was applied
  121542. */
  121543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121544. }
  121545. /**
  121546. * Defines an optimization used to turn post-processes off
  121547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121548. */
  121549. export class PostProcessesOptimization extends SceneOptimization {
  121550. /**
  121551. * Gets a string describing the action executed by the current optimization
  121552. * @return description string
  121553. */
  121554. getDescription(): string;
  121555. /**
  121556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121557. * @param scene defines the current scene where to apply this optimization
  121558. * @param optimizer defines the current optimizer
  121559. * @returns true if everything that can be done was applied
  121560. */
  121561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121562. }
  121563. /**
  121564. * Defines an optimization used to turn lens flares off
  121565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121566. */
  121567. export class LensFlaresOptimization extends SceneOptimization {
  121568. /**
  121569. * Gets a string describing the action executed by the current optimization
  121570. * @return description string
  121571. */
  121572. getDescription(): string;
  121573. /**
  121574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121575. * @param scene defines the current scene where to apply this optimization
  121576. * @param optimizer defines the current optimizer
  121577. * @returns true if everything that can be done was applied
  121578. */
  121579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121580. }
  121581. /**
  121582. * Defines an optimization based on user defined callback.
  121583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121584. */
  121585. export class CustomOptimization extends SceneOptimization {
  121586. /**
  121587. * Callback called to apply the custom optimization.
  121588. */
  121589. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121590. /**
  121591. * Callback called to get custom description
  121592. */
  121593. onGetDescription: () => string;
  121594. /**
  121595. * Gets a string describing the action executed by the current optimization
  121596. * @returns 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 particles off
  121609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121610. */
  121611. export class ParticlesOptimization 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 used to turn render targets off
  121627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121628. */
  121629. export class RenderTargetsOptimization extends SceneOptimization {
  121630. /**
  121631. * Gets a string describing the action executed by the current optimization
  121632. * @return description string
  121633. */
  121634. getDescription(): string;
  121635. /**
  121636. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121637. * @param scene defines the current scene where to apply this optimization
  121638. * @param optimizer defines the current optimizer
  121639. * @returns true if everything that can be done was applied
  121640. */
  121641. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121642. }
  121643. /**
  121644. * Defines an optimization used to merge meshes with compatible materials
  121645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121646. */
  121647. export class MergeMeshesOptimization extends SceneOptimization {
  121648. private static _UpdateSelectionTree;
  121649. /**
  121650. * Gets or sets a boolean which defines if optimization octree has to be updated
  121651. */
  121652. /**
  121653. * Gets or sets a boolean which defines if optimization octree has to be updated
  121654. */
  121655. static UpdateSelectionTree: boolean;
  121656. /**
  121657. * Gets a string describing the action executed by the current optimization
  121658. * @return description string
  121659. */
  121660. getDescription(): string;
  121661. private _canBeMerged;
  121662. /**
  121663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121664. * @param scene defines the current scene where to apply this optimization
  121665. * @param optimizer defines the current optimizer
  121666. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121667. * @returns true if everything that can be done was applied
  121668. */
  121669. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121670. }
  121671. /**
  121672. * Defines a list of options used by SceneOptimizer
  121673. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121674. */
  121675. export class SceneOptimizerOptions {
  121676. /**
  121677. * Defines the target frame rate to reach (60 by default)
  121678. */
  121679. targetFrameRate: number;
  121680. /**
  121681. * Defines the interval between two checkes (2000ms by default)
  121682. */
  121683. trackerDuration: number;
  121684. /**
  121685. * Gets the list of optimizations to apply
  121686. */
  121687. optimizations: SceneOptimization[];
  121688. /**
  121689. * Creates a new list of options used by SceneOptimizer
  121690. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121691. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121692. */
  121693. constructor(
  121694. /**
  121695. * Defines the target frame rate to reach (60 by default)
  121696. */
  121697. targetFrameRate?: number,
  121698. /**
  121699. * Defines the interval between two checkes (2000ms by default)
  121700. */
  121701. trackerDuration?: number);
  121702. /**
  121703. * Add a new optimization
  121704. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121705. * @returns the current SceneOptimizerOptions
  121706. */
  121707. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121708. /**
  121709. * Add a new custom optimization
  121710. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121711. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121713. * @returns the current SceneOptimizerOptions
  121714. */
  121715. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121716. /**
  121717. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121718. * @param targetFrameRate defines the target frame rate (60 by default)
  121719. * @returns a SceneOptimizerOptions object
  121720. */
  121721. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121722. /**
  121723. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121724. * @param targetFrameRate defines the target frame rate (60 by default)
  121725. * @returns a SceneOptimizerOptions object
  121726. */
  121727. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121728. /**
  121729. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121730. * @param targetFrameRate defines the target frame rate (60 by default)
  121731. * @returns a SceneOptimizerOptions object
  121732. */
  121733. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121734. }
  121735. /**
  121736. * Class used to run optimizations in order to reach a target frame rate
  121737. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121738. */
  121739. export class SceneOptimizer implements IDisposable {
  121740. private _isRunning;
  121741. private _options;
  121742. private _scene;
  121743. private _currentPriorityLevel;
  121744. private _targetFrameRate;
  121745. private _trackerDuration;
  121746. private _currentFrameRate;
  121747. private _sceneDisposeObserver;
  121748. private _improvementMode;
  121749. /**
  121750. * Defines an observable called when the optimizer reaches the target frame rate
  121751. */
  121752. onSuccessObservable: Observable<SceneOptimizer>;
  121753. /**
  121754. * Defines an observable called when the optimizer enables an optimization
  121755. */
  121756. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121757. /**
  121758. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121759. */
  121760. onFailureObservable: Observable<SceneOptimizer>;
  121761. /**
  121762. * Gets a boolean indicating if the optimizer is in improvement mode
  121763. */
  121764. readonly isInImprovementMode: boolean;
  121765. /**
  121766. * Gets the current priority level (0 at start)
  121767. */
  121768. readonly currentPriorityLevel: number;
  121769. /**
  121770. * Gets the current frame rate checked by the SceneOptimizer
  121771. */
  121772. readonly currentFrameRate: number;
  121773. /**
  121774. * Gets or sets the current target frame rate (60 by default)
  121775. */
  121776. /**
  121777. * Gets or sets the current target frame rate (60 by default)
  121778. */
  121779. targetFrameRate: number;
  121780. /**
  121781. * Gets or sets the current interval between two checks (every 2000ms by default)
  121782. */
  121783. /**
  121784. * Gets or sets the current interval between two checks (every 2000ms by default)
  121785. */
  121786. trackerDuration: number;
  121787. /**
  121788. * Gets the list of active optimizations
  121789. */
  121790. readonly optimizations: SceneOptimization[];
  121791. /**
  121792. * Creates a new SceneOptimizer
  121793. * @param scene defines the scene to work on
  121794. * @param options defines the options to use with the SceneOptimizer
  121795. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121796. * @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)
  121797. */
  121798. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121799. /**
  121800. * Stops the current optimizer
  121801. */
  121802. stop(): void;
  121803. /**
  121804. * Reset the optimizer to initial step (current priority level = 0)
  121805. */
  121806. reset(): void;
  121807. /**
  121808. * Start the optimizer. By default it will try to reach a specific framerate
  121809. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121810. */
  121811. start(): void;
  121812. private _checkCurrentState;
  121813. /**
  121814. * Release all resources
  121815. */
  121816. dispose(): void;
  121817. /**
  121818. * Helper function to create a SceneOptimizer with one single line of code
  121819. * @param scene defines the scene to work on
  121820. * @param options defines the options to use with the SceneOptimizer
  121821. * @param onSuccess defines a callback to call on success
  121822. * @param onFailure defines a callback to call on failure
  121823. * @returns the new SceneOptimizer object
  121824. */
  121825. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121826. }
  121827. }
  121828. declare module BABYLON {
  121829. /**
  121830. * Class used to serialize a scene into a string
  121831. */
  121832. export class SceneSerializer {
  121833. /**
  121834. * Clear cache used by a previous serialization
  121835. */
  121836. static ClearCache(): void;
  121837. /**
  121838. * Serialize a scene into a JSON compatible object
  121839. * @param scene defines the scene to serialize
  121840. * @returns a JSON compatible object
  121841. */
  121842. static Serialize(scene: Scene): any;
  121843. /**
  121844. * Serialize a mesh into a JSON compatible object
  121845. * @param toSerialize defines the mesh to serialize
  121846. * @param withParents defines if parents must be serialized as well
  121847. * @param withChildren defines if children must be serialized as well
  121848. * @returns a JSON compatible object
  121849. */
  121850. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121851. }
  121852. }
  121853. declare module BABYLON {
  121854. /**
  121855. * Class used to host texture specific utilities
  121856. */
  121857. export class TextureTools {
  121858. /**
  121859. * Uses the GPU to create a copy texture rescaled at a given size
  121860. * @param texture Texture to copy from
  121861. * @param width defines the desired width
  121862. * @param height defines the desired height
  121863. * @param useBilinearMode defines if bilinear mode has to be used
  121864. * @return the generated texture
  121865. */
  121866. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121867. }
  121868. }
  121869. declare module BABYLON {
  121870. /**
  121871. * This represents the different options available for the video capture.
  121872. */
  121873. export interface VideoRecorderOptions {
  121874. /** Defines the mime type of the video. */
  121875. mimeType: string;
  121876. /** Defines the FPS the video should be recorded at. */
  121877. fps: number;
  121878. /** Defines the chunk size for the recording data. */
  121879. recordChunckSize: number;
  121880. /** The audio tracks to attach to the recording. */
  121881. audioTracks?: MediaStreamTrack[];
  121882. }
  121883. /**
  121884. * This can help with recording videos from BabylonJS.
  121885. * This is based on the available WebRTC functionalities of the browser.
  121886. *
  121887. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121888. */
  121889. export class VideoRecorder {
  121890. private static readonly _defaultOptions;
  121891. /**
  121892. * Returns whether or not the VideoRecorder is available in your browser.
  121893. * @param engine Defines the Babylon Engine.
  121894. * @returns true if supported otherwise false.
  121895. */
  121896. static IsSupported(engine: Engine): boolean;
  121897. private readonly _options;
  121898. private _canvas;
  121899. private _mediaRecorder;
  121900. private _recordedChunks;
  121901. private _fileName;
  121902. private _resolve;
  121903. private _reject;
  121904. /**
  121905. * True when a recording is already in progress.
  121906. */
  121907. readonly isRecording: boolean;
  121908. /**
  121909. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  121910. * @param engine Defines the BabylonJS Engine you wish to record.
  121911. * @param options Defines options that can be used to customize the capture.
  121912. */
  121913. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121914. /**
  121915. * Stops the current recording before the default capture timeout passed in the startRecording function.
  121916. */
  121917. stopRecording(): void;
  121918. /**
  121919. * Starts recording the canvas for a max duration specified in parameters.
  121920. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  121921. * If null no automatic download will start and you can rely on the promise to get the data back.
  121922. * @param maxDuration Defines the maximum recording time in seconds.
  121923. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121924. * @return A promise callback at the end of the recording with the video data in Blob.
  121925. */
  121926. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121927. /**
  121928. * Releases internal resources used during the recording.
  121929. */
  121930. dispose(): void;
  121931. private _handleDataAvailable;
  121932. private _handleError;
  121933. private _handleStop;
  121934. }
  121935. }
  121936. declare module BABYLON {
  121937. /**
  121938. * Class containing a set of static utilities functions for screenshots
  121939. */
  121940. export class ScreenshotTools {
  121941. /**
  121942. * Captures a screenshot of the current rendering
  121943. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121944. * @param engine defines the rendering engine
  121945. * @param camera defines the source camera
  121946. * @param size This parameter can be set to a single number or to an object with the
  121947. * following (optional) properties: precision, width, height. If a single number is passed,
  121948. * it will be used for both width and height. If an object is passed, the screenshot size
  121949. * will be derived from the parameters. The precision property is a multiplier allowing
  121950. * rendering at a higher or lower resolution
  121951. * @param successCallback defines the callback receives a single parameter which contains the
  121952. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121953. * src parameter of an <img> to display it
  121954. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121955. * Check your browser for supported MIME types
  121956. */
  121957. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121958. /**
  121959. * Generates an image screenshot from the specified camera.
  121960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121961. * @param engine The engine to use for rendering
  121962. * @param camera The camera to use for rendering
  121963. * @param size This parameter can be set to a single number or to an object with the
  121964. * following (optional) properties: precision, width, height. If a single number is passed,
  121965. * it will be used for both width and height. If an object is passed, the screenshot size
  121966. * will be derived from the parameters. The precision property is a multiplier allowing
  121967. * rendering at a higher or lower resolution
  121968. * @param successCallback The callback receives a single parameter which contains the
  121969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121970. * src parameter of an <img> to display it
  121971. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121972. * Check your browser for supported MIME types
  121973. * @param samples Texture samples (default: 1)
  121974. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121975. * @param fileName A name for for the downloaded file.
  121976. */
  121977. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121978. }
  121979. }
  121980. declare module BABYLON {
  121981. /**
  121982. * A cursor which tracks a point on a path
  121983. */
  121984. export class PathCursor {
  121985. private path;
  121986. /**
  121987. * Stores path cursor callbacks for when an onchange event is triggered
  121988. */
  121989. private _onchange;
  121990. /**
  121991. * The value of the path cursor
  121992. */
  121993. value: number;
  121994. /**
  121995. * The animation array of the path cursor
  121996. */
  121997. animations: Animation[];
  121998. /**
  121999. * Initializes the path cursor
  122000. * @param path The path to track
  122001. */
  122002. constructor(path: Path2);
  122003. /**
  122004. * Gets the cursor point on the path
  122005. * @returns A point on the path cursor at the cursor location
  122006. */
  122007. getPoint(): Vector3;
  122008. /**
  122009. * Moves the cursor ahead by the step amount
  122010. * @param step The amount to move the cursor forward
  122011. * @returns This path cursor
  122012. */
  122013. moveAhead(step?: number): PathCursor;
  122014. /**
  122015. * Moves the cursor behind by the step amount
  122016. * @param step The amount to move the cursor back
  122017. * @returns This path cursor
  122018. */
  122019. moveBack(step?: number): PathCursor;
  122020. /**
  122021. * Moves the cursor by the step amount
  122022. * If the step amount is greater than one, an exception is thrown
  122023. * @param step The amount to move the cursor
  122024. * @returns This path cursor
  122025. */
  122026. move(step: number): PathCursor;
  122027. /**
  122028. * Ensures that the value is limited between zero and one
  122029. * @returns This path cursor
  122030. */
  122031. private ensureLimits;
  122032. /**
  122033. * Runs onchange callbacks on change (used by the animation engine)
  122034. * @returns This path cursor
  122035. */
  122036. private raiseOnChange;
  122037. /**
  122038. * Executes a function on change
  122039. * @param f A path cursor onchange callback
  122040. * @returns This path cursor
  122041. */
  122042. onchange(f: (cursor: PathCursor) => void): PathCursor;
  122043. }
  122044. }
  122045. declare module BABYLON {
  122046. /** @hidden */
  122047. export var blurPixelShader: {
  122048. name: string;
  122049. shader: string;
  122050. };
  122051. }
  122052. declare module BABYLON {
  122053. /** @hidden */
  122054. export var pointCloudVertexDeclaration: {
  122055. name: string;
  122056. shader: string;
  122057. };
  122058. }
  122059. // Mixins
  122060. interface Window {
  122061. mozIndexedDB: IDBFactory;
  122062. webkitIndexedDB: IDBFactory;
  122063. msIndexedDB: IDBFactory;
  122064. webkitURL: typeof URL;
  122065. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  122066. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  122067. WebGLRenderingContext: WebGLRenderingContext;
  122068. MSGesture: MSGesture;
  122069. CANNON: any;
  122070. AudioContext: AudioContext;
  122071. webkitAudioContext: AudioContext;
  122072. PointerEvent: any;
  122073. Math: Math;
  122074. Uint8Array: Uint8ArrayConstructor;
  122075. Float32Array: Float32ArrayConstructor;
  122076. mozURL: typeof URL;
  122077. msURL: typeof URL;
  122078. VRFrameData: any; // WebVR, from specs 1.1
  122079. DracoDecoderModule: any;
  122080. setImmediate(handler: (...args: any[]) => void): number;
  122081. }
  122082. interface HTMLCanvasElement {
  122083. requestPointerLock(): void;
  122084. msRequestPointerLock?(): void;
  122085. mozRequestPointerLock?(): void;
  122086. webkitRequestPointerLock?(): void;
  122087. /** Track wether a record is in progress */
  122088. isRecording: boolean;
  122089. /** Capture Stream method defined by some browsers */
  122090. captureStream(fps?: number): MediaStream;
  122091. }
  122092. interface CanvasRenderingContext2D {
  122093. msImageSmoothingEnabled: boolean;
  122094. }
  122095. interface MouseEvent {
  122096. mozMovementX: number;
  122097. mozMovementY: number;
  122098. webkitMovementX: number;
  122099. webkitMovementY: number;
  122100. msMovementX: number;
  122101. msMovementY: number;
  122102. }
  122103. interface Navigator {
  122104. mozGetVRDevices: (any: any) => any;
  122105. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122106. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122107. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122108. webkitGetGamepads(): Gamepad[];
  122109. msGetGamepads(): Gamepad[];
  122110. webkitGamepads(): Gamepad[];
  122111. }
  122112. interface HTMLVideoElement {
  122113. mozSrcObject: any;
  122114. }
  122115. interface Math {
  122116. fround(x: number): number;
  122117. imul(a: number, b: number): number;
  122118. }
  122119. interface WebGLRenderingContext {
  122120. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122121. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122122. vertexAttribDivisor(index: number, divisor: number): void;
  122123. createVertexArray(): any;
  122124. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122125. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122126. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122127. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122128. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122129. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122130. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122131. // Queries
  122132. createQuery(): WebGLQuery;
  122133. deleteQuery(query: WebGLQuery): void;
  122134. beginQuery(target: number, query: WebGLQuery): void;
  122135. endQuery(target: number): void;
  122136. getQueryParameter(query: WebGLQuery, pname: number): any;
  122137. getQuery(target: number, pname: number): any;
  122138. MAX_SAMPLES: number;
  122139. RGBA8: number;
  122140. READ_FRAMEBUFFER: number;
  122141. DRAW_FRAMEBUFFER: number;
  122142. UNIFORM_BUFFER: number;
  122143. HALF_FLOAT_OES: number;
  122144. RGBA16F: number;
  122145. RGBA32F: number;
  122146. R32F: number;
  122147. RG32F: number;
  122148. RGB32F: number;
  122149. R16F: number;
  122150. RG16F: number;
  122151. RGB16F: number;
  122152. RED: number;
  122153. RG: number;
  122154. R8: number;
  122155. RG8: number;
  122156. UNSIGNED_INT_24_8: number;
  122157. DEPTH24_STENCIL8: number;
  122158. /* Multiple Render Targets */
  122159. drawBuffers(buffers: number[]): void;
  122160. readBuffer(src: number): void;
  122161. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122162. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122163. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122164. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122165. // Occlusion Query
  122166. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122167. ANY_SAMPLES_PASSED: number;
  122168. QUERY_RESULT_AVAILABLE: number;
  122169. QUERY_RESULT: number;
  122170. }
  122171. interface WebGLProgram {
  122172. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122173. }
  122174. interface EXT_disjoint_timer_query {
  122175. QUERY_COUNTER_BITS_EXT: number;
  122176. TIME_ELAPSED_EXT: number;
  122177. TIMESTAMP_EXT: number;
  122178. GPU_DISJOINT_EXT: number;
  122179. QUERY_RESULT_EXT: number;
  122180. QUERY_RESULT_AVAILABLE_EXT: number;
  122181. queryCounterEXT(query: WebGLQuery, target: number): void;
  122182. createQueryEXT(): WebGLQuery;
  122183. beginQueryEXT(target: number, query: WebGLQuery): void;
  122184. endQueryEXT(target: number): void;
  122185. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122186. deleteQueryEXT(query: WebGLQuery): void;
  122187. }
  122188. interface WebGLUniformLocation {
  122189. _currentState: any;
  122190. }
  122191. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122192. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122193. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122194. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122195. interface WebGLRenderingContext {
  122196. readonly RASTERIZER_DISCARD: number;
  122197. readonly DEPTH_COMPONENT24: number;
  122198. readonly TEXTURE_3D: number;
  122199. readonly TEXTURE_2D_ARRAY: number;
  122200. readonly TEXTURE_COMPARE_FUNC: number;
  122201. readonly TEXTURE_COMPARE_MODE: number;
  122202. readonly COMPARE_REF_TO_TEXTURE: number;
  122203. readonly TEXTURE_WRAP_R: number;
  122204. readonly HALF_FLOAT: number;
  122205. readonly RGB8: number;
  122206. readonly RED_INTEGER: number;
  122207. readonly RG_INTEGER: number;
  122208. readonly RGB_INTEGER: number;
  122209. readonly RGBA_INTEGER: number;
  122210. readonly R8_SNORM: number;
  122211. readonly RG8_SNORM: number;
  122212. readonly RGB8_SNORM: number;
  122213. readonly RGBA8_SNORM: number;
  122214. readonly R8I: number;
  122215. readonly RG8I: number;
  122216. readonly RGB8I: number;
  122217. readonly RGBA8I: number;
  122218. readonly R8UI: number;
  122219. readonly RG8UI: number;
  122220. readonly RGB8UI: number;
  122221. readonly RGBA8UI: number;
  122222. readonly R16I: number;
  122223. readonly RG16I: number;
  122224. readonly RGB16I: number;
  122225. readonly RGBA16I: number;
  122226. readonly R16UI: number;
  122227. readonly RG16UI: number;
  122228. readonly RGB16UI: number;
  122229. readonly RGBA16UI: number;
  122230. readonly R32I: number;
  122231. readonly RG32I: number;
  122232. readonly RGB32I: number;
  122233. readonly RGBA32I: number;
  122234. readonly R32UI: number;
  122235. readonly RG32UI: number;
  122236. readonly RGB32UI: number;
  122237. readonly RGBA32UI: number;
  122238. readonly RGB10_A2UI: number;
  122239. readonly R11F_G11F_B10F: number;
  122240. readonly RGB9_E5: number;
  122241. readonly RGB10_A2: number;
  122242. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122243. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122244. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122245. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122246. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122247. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122248. 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;
  122249. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122250. readonly TRANSFORM_FEEDBACK: number;
  122251. readonly INTERLEAVED_ATTRIBS: number;
  122252. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122253. createTransformFeedback(): WebGLTransformFeedback;
  122254. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122255. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122256. beginTransformFeedback(primitiveMode: number): void;
  122257. endTransformFeedback(): void;
  122258. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122259. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122260. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122261. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122262. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122263. }
  122264. interface ImageBitmap {
  122265. readonly width: number;
  122266. readonly height: number;
  122267. close(): void;
  122268. }
  122269. interface WebGLQuery extends WebGLObject {
  122270. }
  122271. declare var WebGLQuery: {
  122272. prototype: WebGLQuery;
  122273. new(): WebGLQuery;
  122274. };
  122275. interface WebGLSampler extends WebGLObject {
  122276. }
  122277. declare var WebGLSampler: {
  122278. prototype: WebGLSampler;
  122279. new(): WebGLSampler;
  122280. };
  122281. interface WebGLSync extends WebGLObject {
  122282. }
  122283. declare var WebGLSync: {
  122284. prototype: WebGLSync;
  122285. new(): WebGLSync;
  122286. };
  122287. interface WebGLTransformFeedback extends WebGLObject {
  122288. }
  122289. declare var WebGLTransformFeedback: {
  122290. prototype: WebGLTransformFeedback;
  122291. new(): WebGLTransformFeedback;
  122292. };
  122293. interface WebGLVertexArrayObject extends WebGLObject {
  122294. }
  122295. declare var WebGLVertexArrayObject: {
  122296. prototype: WebGLVertexArrayObject;
  122297. new(): WebGLVertexArrayObject;
  122298. };
  122299. // Type definitions for WebVR API
  122300. // Project: https://w3c.github.io/webvr/
  122301. // Definitions by: six a <https://github.com/lostfictions>
  122302. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122303. interface VRDisplay extends EventTarget {
  122304. /**
  122305. * Dictionary of capabilities describing the VRDisplay.
  122306. */
  122307. readonly capabilities: VRDisplayCapabilities;
  122308. /**
  122309. * z-depth defining the far plane of the eye view frustum
  122310. * enables mapping of values in the render target depth
  122311. * attachment to scene coordinates. Initially set to 10000.0.
  122312. */
  122313. depthFar: number;
  122314. /**
  122315. * z-depth defining the near plane of the eye view frustum
  122316. * enables mapping of values in the render target depth
  122317. * attachment to scene coordinates. Initially set to 0.01.
  122318. */
  122319. depthNear: number;
  122320. /**
  122321. * An identifier for this distinct VRDisplay. Used as an
  122322. * association point in the Gamepad API.
  122323. */
  122324. readonly displayId: number;
  122325. /**
  122326. * A display name, a user-readable name identifying it.
  122327. */
  122328. readonly displayName: string;
  122329. readonly isConnected: boolean;
  122330. readonly isPresenting: boolean;
  122331. /**
  122332. * If this VRDisplay supports room-scale experiences, the optional
  122333. * stage attribute contains details on the room-scale parameters.
  122334. */
  122335. readonly stageParameters: VRStageParameters | null;
  122336. /**
  122337. * Passing the value returned by `requestAnimationFrame` to
  122338. * `cancelAnimationFrame` will unregister the callback.
  122339. * @param handle Define the hanle of the request to cancel
  122340. */
  122341. cancelAnimationFrame(handle: number): void;
  122342. /**
  122343. * Stops presenting to the VRDisplay.
  122344. * @returns a promise to know when it stopped
  122345. */
  122346. exitPresent(): Promise<void>;
  122347. /**
  122348. * Return the current VREyeParameters for the given eye.
  122349. * @param whichEye Define the eye we want the parameter for
  122350. * @returns the eye parameters
  122351. */
  122352. getEyeParameters(whichEye: string): VREyeParameters;
  122353. /**
  122354. * Populates the passed VRFrameData with the information required to render
  122355. * the current frame.
  122356. * @param frameData Define the data structure to populate
  122357. * @returns true if ok otherwise false
  122358. */
  122359. getFrameData(frameData: VRFrameData): boolean;
  122360. /**
  122361. * Get the layers currently being presented.
  122362. * @returns the list of VR layers
  122363. */
  122364. getLayers(): VRLayer[];
  122365. /**
  122366. * Return a VRPose containing the future predicted pose of the VRDisplay
  122367. * when the current frame will be presented. The value returned will not
  122368. * change until JavaScript has returned control to the browser.
  122369. *
  122370. * The VRPose will contain the position, orientation, velocity,
  122371. * and acceleration of each of these properties.
  122372. * @returns the pose object
  122373. */
  122374. getPose(): VRPose;
  122375. /**
  122376. * Return the current instantaneous pose of the VRDisplay, with no
  122377. * prediction applied.
  122378. * @returns the current instantaneous pose
  122379. */
  122380. getImmediatePose(): VRPose;
  122381. /**
  122382. * The callback passed to `requestAnimationFrame` will be called
  122383. * any time a new frame should be rendered. When the VRDisplay is
  122384. * presenting the callback will be called at the native refresh
  122385. * rate of the HMD. When not presenting this function acts
  122386. * identically to how window.requestAnimationFrame acts. Content should
  122387. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122388. * asynchronously from other displays and at differing refresh rates.
  122389. * @param callback Define the eaction to run next frame
  122390. * @returns the request handle it
  122391. */
  122392. requestAnimationFrame(callback: FrameRequestCallback): number;
  122393. /**
  122394. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122395. * Repeat calls while already presenting will update the VRLayers being displayed.
  122396. * @param layers Define the list of layer to present
  122397. * @returns a promise to know when the request has been fulfilled
  122398. */
  122399. requestPresent(layers: VRLayer[]): Promise<void>;
  122400. /**
  122401. * Reset the pose for this display, treating its current position and
  122402. * orientation as the "origin/zero" values. VRPose.position,
  122403. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122404. * updated when calling resetPose(). This should be called in only
  122405. * sitting-space experiences.
  122406. */
  122407. resetPose(): void;
  122408. /**
  122409. * The VRLayer provided to the VRDisplay will be captured and presented
  122410. * in the HMD. Calling this function has the same effect on the source
  122411. * canvas as any other operation that uses its source image, and canvases
  122412. * created without preserveDrawingBuffer set to true will be cleared.
  122413. * @param pose Define the pose to submit
  122414. */
  122415. submitFrame(pose?: VRPose): void;
  122416. }
  122417. declare var VRDisplay: {
  122418. prototype: VRDisplay;
  122419. new(): VRDisplay;
  122420. };
  122421. interface VRLayer {
  122422. leftBounds?: number[] | Float32Array | null;
  122423. rightBounds?: number[] | Float32Array | null;
  122424. source?: HTMLCanvasElement | null;
  122425. }
  122426. interface VRDisplayCapabilities {
  122427. readonly canPresent: boolean;
  122428. readonly hasExternalDisplay: boolean;
  122429. readonly hasOrientation: boolean;
  122430. readonly hasPosition: boolean;
  122431. readonly maxLayers: number;
  122432. }
  122433. interface VREyeParameters {
  122434. /** @deprecated */
  122435. readonly fieldOfView: VRFieldOfView;
  122436. readonly offset: Float32Array;
  122437. readonly renderHeight: number;
  122438. readonly renderWidth: number;
  122439. }
  122440. interface VRFieldOfView {
  122441. readonly downDegrees: number;
  122442. readonly leftDegrees: number;
  122443. readonly rightDegrees: number;
  122444. readonly upDegrees: number;
  122445. }
  122446. interface VRFrameData {
  122447. readonly leftProjectionMatrix: Float32Array;
  122448. readonly leftViewMatrix: Float32Array;
  122449. readonly pose: VRPose;
  122450. readonly rightProjectionMatrix: Float32Array;
  122451. readonly rightViewMatrix: Float32Array;
  122452. readonly timestamp: number;
  122453. }
  122454. interface VRPose {
  122455. readonly angularAcceleration: Float32Array | null;
  122456. readonly angularVelocity: Float32Array | null;
  122457. readonly linearAcceleration: Float32Array | null;
  122458. readonly linearVelocity: Float32Array | null;
  122459. readonly orientation: Float32Array | null;
  122460. readonly position: Float32Array | null;
  122461. readonly timestamp: number;
  122462. }
  122463. interface VRStageParameters {
  122464. sittingToStandingTransform?: Float32Array;
  122465. sizeX?: number;
  122466. sizeY?: number;
  122467. }
  122468. interface Navigator {
  122469. getVRDisplays(): Promise<VRDisplay[]>;
  122470. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122471. }
  122472. interface Window {
  122473. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122474. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122475. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122476. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122477. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122478. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122479. }
  122480. interface Gamepad {
  122481. readonly displayId: number;
  122482. }
  122483. type XRSessionMode =
  122484. | "inline"
  122485. | "immersive-vr"
  122486. | "immersive-ar";
  122487. type XRReferenceSpaceType =
  122488. | "viewer"
  122489. | "local"
  122490. | "local-floor"
  122491. | "bounded-floor"
  122492. | "unbounded";
  122493. type XREnvironmentBlendMode =
  122494. | "opaque"
  122495. | "additive"
  122496. | "alpha-blend";
  122497. type XRVisibilityState =
  122498. | "visible"
  122499. | "visible-blurred"
  122500. | "hidden";
  122501. type XRHandedness =
  122502. | "none"
  122503. | "left"
  122504. | "right";
  122505. type XRTargetRayMode =
  122506. | "gaze"
  122507. | "tracked-pointer"
  122508. | "screen";
  122509. type XREye =
  122510. | "none"
  122511. | "left"
  122512. | "right";
  122513. interface XRSpace extends EventTarget {
  122514. }
  122515. interface XRRenderState {
  122516. depthNear: number ;
  122517. depthFar: number ;
  122518. inlineVerticalFieldOfView: number | undefined;
  122519. baseLayer: XRWebGLLayer | undefined;
  122520. }
  122521. interface XRInputSource {
  122522. handedness: XRHandedness;
  122523. targetRayMode: XRTargetRayMode;
  122524. targetRaySpace: XRSpace;
  122525. gripSpace: XRSpace | undefined;
  122526. gamepad: Gamepad | undefined;
  122527. profiles: Array<string>;
  122528. }
  122529. interface XRSession {
  122530. addEventListener: Function;
  122531. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  122532. updateRenderState(XRRenderStateInit: any): Promise<void>;
  122533. requestAnimationFrame: Function;
  122534. end(): Promise<void>;
  122535. renderState: XRRenderState;
  122536. inputSources: Array<XRInputSource>;
  122537. }
  122538. interface XRReferenceSpace extends XRSpace {
  122539. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  122540. onreset: any;
  122541. }
  122542. interface XRFrame {
  122543. session: XRSession;
  122544. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  122545. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  122546. }
  122547. interface XRViewerPose extends XRPose {
  122548. views: Array<XRView>;
  122549. }
  122550. interface XRPose {
  122551. transform: XRRigidTransform;
  122552. emulatedPosition: boolean;
  122553. }
  122554. declare var XRWebGLLayer: {
  122555. prototype: XRWebGLLayer;
  122556. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  122557. };
  122558. interface XRWebGLLayer {
  122559. framebuffer: WebGLFramebuffer;
  122560. framebufferWidth: number;
  122561. framebufferHeight: number;
  122562. getViewport: Function;
  122563. }
  122564. interface XRRigidTransform {
  122565. position: DOMPointReadOnly;
  122566. orientation: DOMPointReadOnly;
  122567. matrix: Float32Array;
  122568. inverse: XRRigidTransform;
  122569. }
  122570. interface XRView {
  122571. eye: XREye;
  122572. projectionMatrix: Float32Array;
  122573. transform: XRRigidTransform;
  122574. }
  122575. interface XRInputSourceChangeEvent {
  122576. session: XRSession;
  122577. removed: Array<XRInputSource>;
  122578. added: Array<XRInputSource>;
  122579. }